Tags

String Manipulation

String Manipulation

0 lessons
2 problems
4 code snippets
3 question banks
1 community item

string-manipulation

Practice Problems

2 problems

Encode and Decode Strings

Not Started
Medium

Design an algorithm to encode a list of strings into a single string and decode it back, handling any character content.

Strings
String Manipulation
Arrays
Intermediate

1.1k

37

Reverse Words in a String

Not Started
Medium

Reverse the order of words in a string, handling leading/trailing spaces and multiple spaces between words.

Strings
String Manipulation
Two Pointers
Intermediate

401

11

Code Snippets

4 snippets
Code Snippet

Format Strings with String.format

`String.format` is Java's printf-style formatter for building human-readable strings without ad-hoc concatenation. This snippet covers the common conversions (`%s`, `%d`, `%.2f`, `%n`), padding and alignment for table layouts, and locale-aware vs locale-independent formatting. Reach for `String.format` for any output that mixes types or needs precise width control.

Java
strings
string-manipulation
java-string-builder

299

8

Easy
Code Snippet

Split a String by Delimiter

C++ does not ship with a one-call `split` function, so this snippet shows three idiomatic alternatives: a `std::stringstream` plus `std::getline` walk for single-character delimiters, a `find`/`substr` loop for multi-character delimiters, and a regex-based split for full pattern flexibility. Pick stringstream for whitespace, find/substr for fixed strings, and regex only when the rules are genuinely complex.

C++
cpp-string-class
string-manipulation
strings

777

16

Medium
Code Snippet

Longest String and String-Length Maps

Two small but common questions on arrays of strings: which string is the longest, and how long is each one. The longest-string answer is a single `reduce`, with the tie-breaking rule explicit. The length-map answer is a single `map`, plus a tiny extension that sorts by length so the longest comes first. Both are short, but the patterns generalize to any "pick an extremum" or "shape the data for display" task.

JavaScript
arrays
string-manipulation
map-filter-reduce

1k

22

Easy
Code Snippet

String Tricks: Anagrams, Vowels, Masking, Extension Check, Find Duplicates, Extract Numbers

A grab-bag of small string utilities pulled from a much larger pool: inspecting strings (anagram check, find duplicate characters, distinguish literal from object), counting and scanning (vowels via regex, extract numbers, extension check), transforming (mask the middle, generate alphabet ranges), and order-aware tricks (remove adjacent duplicates, reverse only words longer than n). Each is short on its own; together they cover most of the string work that shows up in real code.

JavaScript
strings
string-manipulation
regex
loops

904

16

Medium