Algorithm Group 9
Algorithm Group 9 contains five exercises focused on implementing string-searching, indexing, replacement, and occurrence-analysis algorithms manually.
The main objective of this group is to practice the underlying algorithms instead of delegating the work to existing string-processing helpers.
Important Restriction
For this group, built-in or standard-library functions that directly perform the required string-processing operation must not be used.
This includes helpers that directly perform operations such as:
- substring search
- substring containment checks
- occurrence counting
- string replacement
- string splitting for the purpose of solving the search
- regular-expression matching
Examples of functions that should not be used to directly solve these tasks include APIs equivalent to:
Index
Contains
Count
Replace
ReplaceAll
Split
Find
Match
The exact names depend on the programming language.
Basic language operations required to implement the algorithm are allowed.
These include operations such as:
- loops
- conditions
- indexing
- character or byte comparison
- collection creation
- collection insertion
- reading the length of a collection
- manually building an output string
The purpose of the restriction is to implement the search and replacement logic yourself, not to make basic language usage impossible.
Tasks
Task 1 — Manual Substring Search
Find every starting index where one search string occurs inside another string.
Task 2 — Multiple Substring Search
Search the same source string for multiple target strings and return the indexes associated with each target.
Task 3 — Match Range Collection
Search for multiple values and return the start and end indexes of every match using a structured result.
Task 4 — Manual String Replacement
Receive replacement pairs and manually replace all matching values inside a source string.
Task 5 — Multi-Source Search Analysis
Search multiple source strings for multiple values and produce detailed occurrence information for each search request.
Objectives
The exercises in this group provide practice with:
- manual substring matching
- string indexing
- sequential scanning
- multiple search patterns
- match-range calculation
- structured search results
- manual replacement
- output construction
- occurrence counting
- searching across multiple sources
- deterministic reporting
Indexing Convention
Unless an individual task states otherwise, indexes in this group use:
zero-based indexing
For ranges, this documentation uses:
[start, end)
where:
start
is the index of the first matched character and:
end
is the index immediately after the matched value.
For example, a three-character match beginning at index 8 has the range:
[8, 11)
This convention makes the match length directly calculable as:
end - start
String Representation
The provided examples contain ASCII characters only.
When implementing the tasks in a language where strings are encoded as UTF-8, consider the distinction between:
- byte indexes
- character indexes
- Unicode code-point indexes
For the exact ASCII examples in this group, byte indexes and character indexes are identical.
An implementation intended to support arbitrary Unicode text should explicitly define which indexing model it uses.
Implementation
The examples define the expected behavior for the provided data.
The implementation should solve the general problem manually without relying on string-processing helpers that directly perform the required operation.
Where the original task contains an incorrect type or inconsistent index example, the individual task page defines the corrected behavior.