Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 C
Which problem is the standard application of 'binary search on the answer' where the feasibility test itself is a greedy scan?
- A. Finding the longest common subsequence of two strings
- B. Computing the number of inversions in an array
- C. Counting the number of distinct subsequences of a string
- D. Splitting an array into K contiguous parts minimising the largest part sum
Correct answer: D. Splitting an array into K contiguous parts minimising the largest part sum
For a candidate maximum part sum, a greedy left-to-right scan counts how many parts are needed; the smallest feasible cap is the answer. The other three are DP or counting problems without a monotone feasibility test.
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
- In bitmask DP over subsets of n items, what is the typical total time for the TSP-style recurrence dp[mask][last] with transitions to…
- Which statement about the 'house robber' DP on a line is correct?
- A greedy solution to a scheduling problem sorts jobs by profit and places each into the latest free slot before its deadline. What must…
- A coin-change problem uses coins {1, 3, 4} and asks for the minimum number of coins for each amount. Which statement is correct?
- In the circular array [1, 2, 1], what is the next greater element of the element at index 2 (search continues around the circle, -1 if no…
- Looking from the right, a building is seen if it is strictly taller than every building to its right (the rightmost is always seen). How…