Professional Documents
Culture Documents
Strings 2 Annoted
Strings 2 Annoted
Strings 2
Lecture- 18
Raghav Garg
Warmup Problem : Input a string and return the
number of times the neighbouring characters are
different from each other.
string
"abb
str: deffghh";
A&BYS
count=
Sorting a string
A
function
de
dega
strings:"name";
Sort (S. begin(), s.end());
S -aemn
Ques : Given two strings s and t, return true if t is an
anagram of s, and false otherwise. leet code 242
+
Sorting - builtin
aba ca b
-
anagrams
a
Ques : Given Ne
n stringsYe consisting of lowercase
English alphabets. Print the character that is
occurring most number of times. Extra space 26 size ->
strings:"leetcode";
space
special away - int air (267
b d e f g h i j k
1mnopqrsturwx 2
a c
y
10/01010101011010111101010/11010101010)
6 8 9 11 12 13 14 15
0 1 2 3 4 5 7 10
16171819204222324 2S
Stringstream
class
strings:"Raghar
is a mathe teacher";
d
to the words
⑨ is calculate no.
of
Ques : Given a sentence, split every single
word of the sentence and print in a new line.
done
Already
strings;
getline (cin,s);
string temp;
stringstream ss(S);
While (stemp)
cout
tempendl;
Ques : Given a sentence ‘str’, return the word
that is occurring most number of times in that
sentence.
string str:
"Raghar is a maths teacher. He is a DSA
"
AIIXAR
y VIX I
stre=
->
"add" true
S: "egg" t =
"bar" false
S "foo"
= t =
true
t :"title"
s =
"paper"
#Hint: special away
Ques : Given two strings s and t, determine if
they are isomorphic.
S "title"
= t "paper"
=
(t)
#
Ques : Given two strings s and t, determine if
X
S = "bade" t "baba"
=
alado
e
Thank you!