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

Concatenation of two strings

Given a two strings, this function will concatenate the two strings into one string. Example INPUT s1= cat s2 = dog OUTPUT catdog In the above example, the two strings cat and dog are concatenated Time Complexity: O(n), where n is the size of the largest string Algorthm1 1. Create …

Read more

Reverse a String

Reverse the given string. Example Method 1 Algorithm Use inbuilt STL functions. (Standard library functions) Reverse(position 1, position 2)  → Reverses from position 1 to position 2 Let string be S Call function like this: reverse(S.begin(), S.end()) Print S, it will be reversed. C++ Program #include <bits/stdc++.h> using namespace std; int …

Read more

Most repeating character in a string

In the given string find the maximum occurring character Maximum occurring character: character which is coming more number of times. (Case sensitivity is present, “D” and “d” are not the same.) Note: If there are more than one character repeated more than once then it prints the first most repeated …

Read more

Strings in C Programming

In datatypes of C, we have learned character datatype. It stores single character in it and occupies 1 byte of space. This will support the use of only one character at a time. But any programs will not end with single characters. There will be words and sentences to be …

Read more

String Pointer in C

String Pointer in C – Character datatypes are used to hold only 1 byte of character. It holds only one character in a variable. But we need to have more features from this character datatype as we have words / sentences to  be used in the programs. In such cases …

Read more

Translate »