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?

  1. A. Finding the longest common subsequence of two strings
  2. B. Computing the number of inversions in an array
  3. C. Counting the number of distinct subsequences of a string
  4. 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.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic