Write a program to reverse a string?


Algorithm 1 using stack :

1) Create an empty stack.
2) One by one push all characters of string to stack.
3) One by one pop all characters from stack and put 
   them back to string.
 
 
 
 
Algorithm 2 using array:
 
1. here we have to swap the elements
 
 
 
 
 

Comments

Popular posts from this blog

How to swap two numbers without using a temporary variable?

You are given a list of n-1 integers and these integers are in the range of 1 to n. There are no duplicates in list. One of the integers is missing in the list. Write an efficient code to find the missing integer.