Data Structures & AlgorithmsHardTCS NQT · Linked List
Seven people numbered 1 to 7 stand in a circle (a circular linked list). Counting starts at person 1, and every 3rd person is removed, counting continues from the next person, until one remains. Who survives?
- A. 1
- B. 5
- C. 6
- D. 4
Correct answer: D. 4
Removal order is 3, 6, 2, 7, 5, 1, leaving person 4.
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 area of the largest rectangle in a histogram with bar heights [3, 6, 5, 7, 4, 8, 1, 0, 6] and unit width?
- What is the maximum sum of a non-empty contiguous subarray of [3, -4, 2, -3, -1, 7, -5] if you may delete at most one element from the…
- How many contiguous subarrays of [2, 3, 4, 1, 5, 2, 6] have a product strictly less than 50?
- How many contiguous subarrays of [4, 5, 0, -2, -3, 1] have a sum divisible by 5?
- How many inversions (pairs i < j with a[i] > a[j]) does [8, 4, 2, 1, 7, 3, 6, 5] have?
- Eight trains have arrival times 900, 915, 930, 945, 1000, 1010, 1030, 1100 and departure times (in some order) 930, 1000, 1015, 1000…