Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
Count monotone lattice paths from (0, 0) to (3, 3) that move one step right (x+1) or up (y+1) and never touch a point (i, i) with 0 < i < 3. How many such paths are there?
- A. 4
- B. 8
- C. 20
- D. 2
Correct answer: A. 4
A valid path touches the diagonal only at its two endpoints, so it lies entirely on one side; each side is counted by a Catalan number C(n−1), and the two mirror families add up. The unrestricted count C(6, 3) = 20 includes paths that touch the diagonal.
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
- How many arrays of length 4 with entries from {0, 1, 2} have an EVEN total sum?
- Pick one number from each of the lists [4, 9, 2], [7, 3, 8] and [5, 6, 1]. The three picks must sum to at most 14. What is the largest…
- Among the windows of exactly 3 consecutive elements of [4, 2, 4, 1, 3, 5, 2, 6] whose 3 values are all different, what is the largest…
- Consider only the elements at even 0-based indices of [5, 2, 8, 1, 7, 3, 9, 4] (that is, 5, 8, 7, 9). How many inversions (pairs i < j of…
- What is the length of the longest contiguous subarray of [2, 1, 5, 1, 3, 2, 4, 1] whose sum is at most 9? All values are non-negative.
- Each operation decreases one element of [5, 3, 4, 2, 6] by exactly 1. What is the minimum number of operations needed to make the array…