Problems
A quick reference to known problems and their solutions, ordered by the type of problem.
Verify if list of items can be represented by blocks of items
- Inputs:
- A: List of unique integers
- B: List of integer sequences (e.g.
[1,3]
) comprising of unique integers
- Task:
- Verify A can be created by only concatenating the sequences in B
- Solution: Amortized Time & Space O(n)
- Assume uniqueness of items and correctness of input (e.g. A and B's contents are of the same length, all items unique)
- Create an index lookup for A using a hashtable.
- blocks in B, verify that items,
index > -1
and items have consecutive indexes (i.e.index == prevIndex + 1
except the first index)