Reverse words in a given string

Given a string, write a function that will print the words of a string in reverse order Example INPUT s = “tutorial cup makes programming easy” OUTPUT “easy programming makes cup tutorial” Time Complexity : O(n) Algorithm Traverse the string 1. Reverse the individual words 2. After reversing the words, …

Read more

Divide a string in N equal parts

Write a program to divide the given string into N equal parts. (N is input) Examples a) Input string : “stringlength”, N = 2 Output : string length b) Input string : “tutorialcup”, N = 3 Output : Invalid input! Because, string cannot be divided into N equal parts. Algorithm …

Read more

Sorting the array of strings

Given an array which contains strings, this function will sort the array. This can be clearly shown in below example Example INPUT S[] = {“Abhishek”, “Zeroess”,”Hello”,”Amit”,”Bananan”,”Problem”,”Ankush”,”Ahmed”} OUTPUT Abhishek  Ahmed  Amit  Ankush  Bananan  Hello  Problem  Zeroess In the above example we can see that the strings in the array are sorted …

Read more

Remove duplicates from a string

Given a string, this function removes all the duplicates in the string and prints the string which has no duplcates. Here, duplicates are the elements which occur more than once in the string Time Complexity: O(nlogn), if we use some nlogn sorting algorithm Algorithm1(Using Sorting) Example INPUT s = tutorialcup …

Read more

Translate »