Most asked on strings in coding interviews.
A string is traditionally a sequence of characters, either as a literal constant or as some kind of variable.1)Check the given string is a palindrome or not
Ex:- input: popoutput:true
2)Check the given two strings is an Anagram or not
An anagram of a string is another string that contains the same characters, only the order of characters can be different. For example, “abcd” and “dabc” are an anagram of each other.3)Check the given string is balanced or not
Input String will contain "a-z", "( )","[ ]" and "{ }" .The brackets must close in the correct order.
Ex: input: abc(){[]} output: valid
input: (zyx)[{)}] output: invalid
4)Print the most repeated character in a given string
Ex: input: Apple output: p
input: Google output: o
5)Print the occurrence of each character in a given string
Ex:input: Apple output: A-1,p-2,l-1,e-1
6)Remove the substring
Given two strings s1 and s2.where s1 is the main string and s2 is a substring print string after removing s2 in s1
Ex: input: s1=String is loving
s2=ing
output: Str is lov
7)Print the first non-repeating character in a given string
Ex: input: java output: j
input: options output: p
8)Reverse the given sentence
Ex: input-1: I love coding
output-1: coding love I
input-2: support.mission.hack
output-2: hack.mission.support
9)Compress the given string
Ex: input: aabbbccdd
output: a2b3c2d2
Some more questions will be added soon.
Cheers keep coding
Comments
Post a Comment