Data Structures & AlgorithmsHardTCS NQT · Accenture
Two sorted linked lists are [1, 5, 9, 12] and [2, 3, 8]. They are merged into one sorted list. What is the 5th value of the merged list (1-based)?
- A. 9
- B. 10
- C. 12
- D. 8
Correct answer: D. 8
The merged list is 1, 2, 3, 5, 8, 9, 12, so the 5th value is 8. Taking the 5th value of the first list gives a different answer.
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 the array [2, 8, 5, 5, 3, 7, 5], how many index pairs i < j have a[i] + a[j] = 10?
- How many distinct sums are obtained by contiguous non-empty subarrays of [1, -1, 2, -2]?
- What is the length of the longest substring of aabbcaabcc in which every character occurs at least twice?
- How many palindromic substrings of length at least 2 does abcbaccab contain (counted by position)?
- How many distinct substrings of length 3 of abcabcabc occur at least twice in the string?
- How many ways can the digit string 226 be decoded when 1 to 26 map to A to Z?