Problem Statement: You are given a string, you need to find all the subsequence of it. A subsequence in a string is generated by deleting someof the characters without changing it’s order. Example Input: abc Output: a, b, c, ab, bc, ac, abc Solution The …
Problem Statement: You are given a binary string, you need to return true if the longest contiguous sequence of 1s is greater than the longest contiguous sequence of 0. Example Input: s = "1101" Output: true Beause longest continious segment of 1 is 2, and 0 …
Problem Statement: You are given a strings, your task is to find the second most repeated string in the given sequence. Example Input : {"aaa", "bbb", "ccc", "bbb", "aaa", "aaa"} Output : bbb Solution The solution is very simple. Store all the words in …
Problem Statement: Given 2 strings str1 and str2, you need to write a program to check if s2 is a rotation of s1. Example str1 = ABCD str2 = CDAB Output: true Solution Solution is very simple, we will concatenate the first string with …
Problem Statement: Given a string convert into its equivalent ASCII format. Example Input : hello, world! Output : 104101108108111443211911111410810033 Solution The solution is very simple. Iterate over the string and take each character and subtract NULL character. Print the result. Solution in C++ …
Problem Statement: Given a string, get all the duplicates and print their count. Example String: helloo l = 2 o = 2 Solution Solution is very simple. Take an array whose size is 256. Then initialize it to 0. Then convert the character into its …
Problem Statement: Given a string, remove all the consecutive duplicates Example Input : aaaaabbbbbb Output : ab Solution Solution is very simple. If the string is empty return. else, compare the adjacent character of the string. If they are same then shift the character one …
Problem Statement: Given an array of characters reverse them in-place without taking extra space. Example Input: Output: Solution The solution is very simple. Take 2 pointers, first pointer pointing to the start of the array. second pointer pointing at the end of the array. Then …
Problem Statement: You are given an m*n matrix, you need to print all the common elements present in all the rows. Example: mat = {{1, 2, 1, 8}, {3, 7, 8, 5}, {8, 7, 7, 3}, {8, 1, 2, 7}, }; Output: 8 Solution …
Problem Statement: You are given a m*n binary matrix, you need to find a row that has maximum number of 1’s in it. Each row in the matrix is sorted. Example: Solution: This can be solved in 2 different ways. 1. Brute force approach 2. …