Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 C
Unit-time tasks have deadlines [1, 2, 2, 3, 3, 3, 5, 6] (a task must finish by its deadline, and only one task runs at a time from time 1). What is the maximum number of tasks that can be completed on time?
- A. 8
- B. 6
- C. 4
- D. 5
Correct answer: D. 5
Sort the deadlines and keep a count of tasks taken so far; take a task only when it can still finish by its deadline. Counting the tasks with a valid deadline ignores that too many share the same early slot.
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 minimum number of characters you must DELETE from "aabbbcaaddd" so that no two adjacent characters are equal?
- What is the 10-th smallest positive integer that is divisible by NEITHER 3 nor 5?
- What is the length of the longest substring of "abcbxaxba" that becomes a palindrome after deleting AT MOST ONE character from it?
- How many pairs of positions (i < j) in [5, 2, 7, 2, 9, 1, 6] have a[i] < a[j]?
- Items as (weight, value) are [(4, 6), (2, 3), (5, 9), (3, 4), (6, 10), (1, 1)]. You must take EXACTLY 3 different items with total weight…
- In one operation you may choose a contiguous subarray and increase every element in it by 1. Starting from [0, 0, 0, 0], what is the…