Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA
In "abcabdabc", how many positions i >= 1 start an occurrence of the prefix "abc" (the first three characters)?
- A. 2
- B. 0
- C. 1
- D. 3
Correct answer: C. 1
Count starts i >= 1 where the length-3 window equals "abc". The window at index 3 is "abd" and does not match, while index 6 matches.
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
- What is the sum of all integers from 1 to 50 inclusive that are coprime to 50?
- Let L be the length of the longest common subsequence of "ABCBDAB" and "BDCABA". How many different index-selections in "ABCBDAB" give a…
- What is the length of the longest common subsequence of "dbacabb" and its cyclic rotation by one position (the string with its first…
- Using only insertions and deletions (no substitutions), what is the minimum number of operations needed to turn "heat" into "hit"?
- How many permutations of the numbers 1 to 6 have a longest increasing subsequence of length exactly 3?
- How many permutations of 1, 2, 3, 4, 5 have EXACTLY 4 inversions? An inversion is a pair of positions i < j with p[i] > p[j].