DSA AND ALGO
DSA AND ALGO
9 392. Is Subsequence
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
DATE HARD DATE
TIPS
1. Identify the Problem Goal 2. Check Constraints
Final Approach:
s.length() / s.size()
s.replace(pos, len,
Example: "Count occurrences of substrings" "text")
s.find("text")
s.rfind("text")
s.substr(pos, len)
stoi(s) / stol(s) /
stoll(s)
to_string(num)
ng Functions with Examples
Description Example
Checks if the string is empty (true or false). string s = ""; s.empty(); // true
Adds text to the end of the string. string s = "hi"; s.append(" there"); // "hi there"
Another way to append text. string s = "hi"; s += " there"; // "hi there"
Replaces a part of the string with new text. string s = "abcdef"; s.replace(2, 3, "XYZ"); //
"abXYZf"
Finds the first occurrence of a substring. "hello world".find("lo") → 3
Finds the last occurrence of a substring. "banana".rfind("na") → 4