Episode 7 — DSA with JavaScript / 7.5 — Strings
7.5.a — String Methods & Manipulation
Strings overview
A string is an immutable sequence of characters. In JavaScript strings are
primitive values; in C++ std::string is a class.
Index: 0 1 2 3 4
┌───┬───┬───┬───┬───┐
│ H │ e │ l │ l │ o │
└───┴───┴───┴───┴───┘
Creating strings
const s1 = "Hello";
const s2 = 'World';
const s3 = `Hi ${s1}`; // template literal
#include <string>
using namespace std;
string s1 = "Hello";
string s2("World");
string s3 = s1 + " " + s2;
String properties and access
const str = "JavaScript";
str.length; // 10
str[0]; // "J"
str.charAt(4); // "S"
str.at(-1); // "t" (ES2022)
str.charCodeAt(0); // 74 (Unicode)
string str = "JavaScript";
str.size(); // 10
str[0]; // 'J'
str.at(4); // 'S'
str.back(); // 't'
Manipulation methods
concat()
const a = "Hello";
const b = " World";
a.concat(b); // "Hello World"
a + b; // "Hello World" (preferred)
`${a}${b}`; // "Hello World" (template literal)
string a = "Hello", b = " World";
string c = a + b; // "Hello World"
a.append(b); // modifies a in-place
slice()
const s = "Hello World";
s.slice(0, 5); // "Hello"
s.slice(6); // "World"
s.slice(-5); // "World"
s.slice(2, -2); // "llo Wor"
string s = "Hello World";
s.substr(0, 5); // "Hello"
s.substr(6); // "World"
substring() vs slice()
s.substring(0, 5); // "Hello" (same as slice for positive args)
s.substring(5, 0); // "Hello" (swaps if start > end)
s.slice(5, 0); // "" (returns empty if start > end)
replace() and replaceAll()
const s = "foo bar foo baz foo";
s.replace("foo", "qux"); // "qux bar foo baz foo" (first only)
s.replaceAll("foo", "qux"); // "qux bar qux baz qux" (all)
s.replace(/foo/g, "qux"); // "qux bar qux baz qux" (regex global)
#include <regex>
string s = "foo bar foo baz foo";
// Replace first occurrence
size_t pos = s.find("foo");
if (pos != string::npos) s.replace(pos, 3, "qux");
// Replace all — loop or use regex
regex re("foo");
string result = regex_replace(s, re, "qux");
Search and check
const s = "Hello World";
s.indexOf("World"); // 6
s.indexOf("xyz"); // -1
s.lastIndexOf("l"); // 9
s.includes("World"); // true
s.startsWith("Hello"); // true
s.endsWith("World"); // true
string s = "Hello World";
s.find("World"); // 6
s.find("xyz"); // string::npos
s.rfind("l"); // 9
// No built-in includes/startsWith — write helper or use find
bool includes = s.find("World") != string::npos;
bool startsWith = s.substr(0, 5) == "Hello";
Transformations
"hello".toUpperCase(); // "HELLO"
"HELLO".toLowerCase(); // "hello"
" hello ".trim(); // "hello"
" hello ".trimStart(); // "hello "
" hello ".trimEnd(); // " hello"
"ha".repeat(3); // "hahaha"
"7".padStart(3, "0"); // "007"
"hi".padEnd(5, "."); // "hi..."
#include <algorithm>
#include <cctype>
string s = "Hello";
transform(s.begin(), s.end(), s.begin(), ::toupper); // "HELLO"
transform(s.begin(), s.end(), s.begin(), ::tolower); // "hello"
split() and join()
const csv = "apple,banana,cherry";
const arr = csv.split(","); // ["apple", "banana", "cherry"]
arr.join(" | "); // "apple | banana | cherry"
"hello".split(""); // ["h", "e", "l", "l", "o"]
#include <sstream>
#include <vector>
string csv = "apple,banana,cherry";
vector<string> parts;
stringstream ss(csv);
string token;
while (getline(ss, token, ',')) {
parts.push_back(token);
}
Template literals (JS)
const name = "Alice";
const age = 25;
// String interpolation
console.log(`Name: ${name}, Age: ${age}`);
// Multi-line
const html = `
<div>
<h1>${name}</h1>
<p>Age: ${age}</p>
</div>
`;
// Expression evaluation
console.log(`${age >= 18 ? "Adult" : "Minor"}`);
Escape characters
| Escape | Meaning |
|---|---|
\n | Newline |
\t | Tab |
\\ | Backslash |
\' | Single quote |
\" | Double quote |
\0 | Null character |
console.log("Line 1\nLine 2");
console.log("Col1\tCol2");
console.log("He said \"hello\"");
String immutability
let s = "hello";
s[0] = "H"; // No effect — strings are immutable
console.log(s); // "hello"
s = "H" + s.slice(1); // Create new string
console.log(s); // "Hello"
string s = "hello";
s[0] = 'H'; // Works — C++ strings are mutable
cout << s; // "Hello"
Performance: string concatenation
// BAD in a loop — creates many intermediate strings
let result = "";
for (let i = 0; i < 10000; i++) {
result += i;
}
// BETTER — use array and join
const parts = [];
for (let i = 0; i < 10000; i++) {
parts.push(i);
}
const result2 = parts.join("");
// Use stringstream or string::reserve for efficiency
#include <sstream>
ostringstream oss;
for (int i = 0; i < 10000; i++) {
oss << i;
}
string result = oss.str();
Scenario bank (string methods)
7.5a-001 — Count words in a string (variation 1)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-002 — Capitalize first letter of each word (variation 2)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-003 — Remove all whitespace from a string (variation 3)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-004 — Check if a string contains only digits (variation 4)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-005 — Extract domain from an email address (variation 5)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-006 — Truncate string with ellipsis (variation 6)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-007 — Convert camelCase to kebab-case (variation 7)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-008 — Convert snake_case to camelCase (variation 8)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-009 — Mask all but last 4 chars of a credit card (variation 9)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-010 — Count occurrences of a substring (variation 10)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-011 — Remove duplicate characters (variation 11)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-012 — Check if string is a valid identifier (variation 12)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-013 — Implement a simple slug generator (variation 13)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-014 — Extract all numbers from a string (variation 14)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-015 — Reverse words in a string (keep word order or reverse it) (variation 15)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-016 — Check if two strings are rotations of each other (variation 16)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-017 — Find the longest word in a string (variation 17)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-018 — Implement basic string compression (aabccc → a2b1c3) (variation 18)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-019 — Validate a URL string format (variation 19)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-020 — Generate a random alphanumeric string (variation 20)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-021 — Count words in a string (variation 21)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-022 — Capitalize first letter of each word (variation 22)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-023 — Remove all whitespace from a string (variation 23)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-024 — Check if a string contains only digits (variation 24)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-025 — Extract domain from an email address (variation 25)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-026 — Truncate string with ellipsis (variation 26)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-027 — Convert camelCase to kebab-case (variation 27)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-028 — Convert snake_case to camelCase (variation 28)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-029 — Mask all but last 4 chars of a credit card (variation 29)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-030 — Count occurrences of a substring (variation 30)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-031 — Remove duplicate characters (variation 31)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-032 — Check if string is a valid identifier (variation 32)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-033 — Implement a simple slug generator (variation 33)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-034 — Extract all numbers from a string (variation 34)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-035 — Reverse words in a string (keep word order or reverse it) (variation 35)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-036 — Check if two strings are rotations of each other (variation 36)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-037 — Find the longest word in a string (variation 37)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-038 — Implement basic string compression (aabccc → a2b1c3) (variation 38)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-039 — Validate a URL string format (variation 39)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-040 — Generate a random alphanumeric string (variation 40)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-041 — Count words in a string (variation 41)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-042 — Capitalize first letter of each word (variation 42)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-043 — Remove all whitespace from a string (variation 43)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-044 — Check if a string contains only digits (variation 44)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-045 — Extract domain from an email address (variation 45)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-046 — Truncate string with ellipsis (variation 46)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-047 — Convert camelCase to kebab-case (variation 47)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-048 — Convert snake_case to camelCase (variation 48)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-049 — Mask all but last 4 chars of a credit card (variation 49)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-050 — Count occurrences of a substring (variation 50)
- Level: Beginner
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-051 — Remove duplicate characters (variation 51)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-052 — Check if string is a valid identifier (variation 52)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-053 — Implement a simple slug generator (variation 53)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-054 — Extract all numbers from a string (variation 54)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-055 — Reverse words in a string (keep word order or reverse it) (variation 55)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-056 — Check if two strings are rotations of each other (variation 56)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-057 — Find the longest word in a string (variation 57)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-058 — Implement basic string compression (aabccc → a2b1c3) (variation 58)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-059 — Validate a URL string format (variation 59)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-060 — Generate a random alphanumeric string (variation 60)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-061 — Count words in a string (variation 61)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-062 — Capitalize first letter of each word (variation 62)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-063 — Remove all whitespace from a string (variation 63)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-064 — Check if a string contains only digits (variation 64)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-065 — Extract domain from an email address (variation 65)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-066 — Truncate string with ellipsis (variation 66)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-067 — Convert camelCase to kebab-case (variation 67)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-068 — Convert snake_case to camelCase (variation 68)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-069 — Mask all but last 4 chars of a credit card (variation 69)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-070 — Count occurrences of a substring (variation 70)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-071 — Remove duplicate characters (variation 71)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-072 — Check if string is a valid identifier (variation 72)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-073 — Implement a simple slug generator (variation 73)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-074 — Extract all numbers from a string (variation 74)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-075 — Reverse words in a string (keep word order or reverse it) (variation 75)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-076 — Check if two strings are rotations of each other (variation 76)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-077 — Find the longest word in a string (variation 77)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-078 — Implement basic string compression (aabccc → a2b1c3) (variation 78)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-079 — Validate a URL string format (variation 79)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-080 — Generate a random alphanumeric string (variation 80)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-081 — Count words in a string (variation 81)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-082 — Capitalize first letter of each word (variation 82)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-083 — Remove all whitespace from a string (variation 83)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-084 — Check if a string contains only digits (variation 84)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-085 — Extract domain from an email address (variation 85)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-086 — Truncate string with ellipsis (variation 86)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-087 — Convert camelCase to kebab-case (variation 87)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-088 — Convert snake_case to camelCase (variation 88)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-089 — Mask all but last 4 chars of a credit card (variation 89)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-090 — Count occurrences of a substring (variation 90)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-091 — Remove duplicate characters (variation 91)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-092 — Check if string is a valid identifier (variation 92)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-093 — Implement a simple slug generator (variation 93)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-094 — Extract all numbers from a string (variation 94)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-095 — Reverse words in a string (keep word order or reverse it) (variation 95)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-096 — Check if two strings are rotations of each other (variation 96)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-097 — Find the longest word in a string (variation 97)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-098 — Implement basic string compression (aabccc → a2b1c3) (variation 98)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-099 — Validate a URL string format (variation 99)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-100 — Generate a random alphanumeric string (variation 100)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-101 — Count words in a string (variation 101)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-102 — Capitalize first letter of each word (variation 102)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-103 — Remove all whitespace from a string (variation 103)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-104 — Check if a string contains only digits (variation 104)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-105 — Extract domain from an email address (variation 105)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-106 — Truncate string with ellipsis (variation 106)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-107 — Convert camelCase to kebab-case (variation 107)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-108 — Convert snake_case to camelCase (variation 108)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-109 — Mask all but last 4 chars of a credit card (variation 109)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-110 — Count occurrences of a substring (variation 110)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-111 — Remove duplicate characters (variation 111)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-112 — Check if string is a valid identifier (variation 112)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-113 — Implement a simple slug generator (variation 113)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-114 — Extract all numbers from a string (variation 114)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-115 — Reverse words in a string (keep word order or reverse it) (variation 115)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-116 — Check if two strings are rotations of each other (variation 116)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-117 — Find the longest word in a string (variation 117)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-118 — Implement basic string compression (aabccc → a2b1c3) (variation 118)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-119 — Validate a URL string format (variation 119)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-120 — Generate a random alphanumeric string (variation 120)
- Level: Intermediate
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-121 — Count words in a string (variation 121)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-122 — Capitalize first letter of each word (variation 122)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-123 — Remove all whitespace from a string (variation 123)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-124 — Check if a string contains only digits (variation 124)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-125 — Extract domain from an email address (variation 125)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-126 — Truncate string with ellipsis (variation 126)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-127 — Convert camelCase to kebab-case (variation 127)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-128 — Convert snake_case to camelCase (variation 128)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-129 — Mask all but last 4 chars of a credit card (variation 129)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-130 — Count occurrences of a substring (variation 130)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-131 — Remove duplicate characters (variation 131)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-132 — Check if string is a valid identifier (variation 132)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-133 — Implement a simple slug generator (variation 133)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-134 — Extract all numbers from a string (variation 134)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-135 — Reverse words in a string (keep word order or reverse it) (variation 135)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-136 — Check if two strings are rotations of each other (variation 136)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-137 — Find the longest word in a string (variation 137)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-138 — Implement basic string compression (aabccc → a2b1c3) (variation 138)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-139 — Validate a URL string format (variation 139)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-140 — Generate a random alphanumeric string (variation 140)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-141 — Count words in a string (variation 141)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-142 — Capitalize first letter of each word (variation 142)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-143 — Remove all whitespace from a string (variation 143)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-144 — Check if a string contains only digits (variation 144)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-145 — Extract domain from an email address (variation 145)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-146 — Truncate string with ellipsis (variation 146)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-147 — Convert camelCase to kebab-case (variation 147)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-148 — Convert snake_case to camelCase (variation 148)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-149 — Mask all but last 4 chars of a credit card (variation 149)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-150 — Count occurrences of a substring (variation 150)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-151 — Remove duplicate characters (variation 151)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-152 — Check if string is a valid identifier (variation 152)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-153 — Implement a simple slug generator (variation 153)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-154 — Extract all numbers from a string (variation 154)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-155 — Reverse words in a string (keep word order or reverse it) (variation 155)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-156 — Check if two strings are rotations of each other (variation 156)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-157 — Find the longest word in a string (variation 157)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-158 — Implement basic string compression (aabccc → a2b1c3) (variation 158)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-159 — Validate a URL string format (variation 159)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-160 — Generate a random alphanumeric string (variation 160)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-161 — Count words in a string (variation 161)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-162 — Capitalize first letter of each word (variation 162)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-163 — Remove all whitespace from a string (variation 163)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-164 — Check if a string contains only digits (variation 164)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-165 — Extract domain from an email address (variation 165)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-166 — Truncate string with ellipsis (variation 166)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-167 — Convert camelCase to kebab-case (variation 167)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-168 — Convert snake_case to camelCase (variation 168)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-169 — Mask all but last 4 chars of a credit card (variation 169)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.
7.5a-170 — Count occurrences of a substring (variation 170)
- Level: Advanced
- Approach: Apply appropriate technique for this problem class.
- Time complexity: Analyze based on input size.
- Space complexity: Identify auxiliary space used.
- Edge cases: empty input, single element, boundary values.
- JS & C++: Implement in both languages.