Programming interview questions and answers

Reverse words of a string without using stack

Write a program to reverse words of a string without using stack The approach:- Reverse the entire string. Scan the string from beginning. On reaching a word (space) reverse the sub string. Continue till end of the string. C++ program to reverse words of a string without using stack #include <iostream>#include <cstring>using namespace std;void reversestring(char* …

Reverse words of a string without using stack Read More »

Find the longest palindrome in a string

Write a program to find the longest palindrome in a string The approach:- From each character location, compare the left and right locations for equality. Remember the location and maximum size of equality. Print the string starting from the location minus maximum size to location plus maximum size, which is the longest palindrome. C++ program …

Find the longest palindrome in a string Read More »