Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA
How many proper borders (non-empty prefixes that are also suffixes, excluding the whole string) does "abacabab" have?
- A. 2
- B. 0
- C. 1
- D. 3
Correct answer: C. 1
A border is a prefix equal to a suffix; the prefix-function chain enumerates all borders. Including the whole string as a border is the usual extra count.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- Rotate "abcabd" one step to the left, then count the distinct substrings of length 3 in the rotated string.
- Four jobs need 5, 3, 4 and 1 units of time; a round-robin scheduler gives each job one unit per turn in queue order and removes finished…
- How many windows of size 3 in [1, 3, 2, 6, 4, 5, 1] have max minus min at most 2?
- How many integers from 1 to 50 inclusive have a digit sum that is divisible by 5?
- What is the minimum value of a[i] XOR a[j] over index pairs i < j in [15, 2, 19, 6, 11, 9]?
- How many integers from 1 to 40 inclusive have exactly as many 0-bits as 1-bits in their binary representation (without leading zeros)?