Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA
What is the length of the longest common substring (contiguous) of "abcdef" and "zcdemf"?
- A. 4
- B. 2
- C. 3
- D. 5
Correct answer: C. 3
The common contiguous block is "cde" of length 3. The longest common subsequence ("cdef" of length 4 is not contiguous in both) is a different quantity.
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
- When converting the infix expression "(a+b)(c-d)/e" to postfix, how many operator symbols appear in the postfix output?
- What is the sum of all odd positive divisors of 180?
- How many distinct sums arise from the length-3 windows of [1, 1, 2, 2, 3, 3, 1]?
- Among index pairs i < j of [-8, -3, -1, 2, 5, 9], how many pairs have the minimum possible absolute value of their sum?
- For [4, 1, 3, 7, 2], what is the maximum over index pairs i < j of min(a[i], a[j]) times (j - i)?
- How many non-empty substrings of "aabcab" are already in non-decreasing (sorted) order?