Given 2 strings, check if they are isomorphic strings.

2 strings are said to be isomorphic, if one letter in the first string can be replaced by another letter in the second string. Example 1: string_1 = add string_2 = egg Output: True Here “a” can be replaced by “e” and “d” can be replaced by “g”. Example 2: string_1 = foo string_2 = […]

Given an array, find the majority element, solution in C++

A majority element, is an element that is repeated more than half of the times. Example: [1, 2, 3, 4, 4, 4, 4, 4, 5] Output: 4. Total number of elements are 9, and 4 is repeated 5 times. It has repeated more than half of the times. We can solve this problem by using […]

You are given a sentence, reverse the string word by word

Example: Input: “prodevelopertutorial is a good website”, Output: ” website good a is prodevelopertutorial”. The solution is as follows: Step 1: Reverse the whole string. Step 2: Reverse individual words in the string. Along with the above 2 steps, we need to remove leading and trailing spaces, and extra spaces in between the words. Solution […]