Data Structures & AlgorithmsHardProduct placement · Amazon/Microsoft
Only the lower triangle (including the diagonal) of a 12 × 12 matrix is stored row by row in a 1-D array B starting at B[0] (indices 0-based). At which index of B is element (4, 3) stored?
- A. 13
- B. 34
- C. 14
- D. 9
Correct answer: A. 13
Rows 0..3 before row 4 hold 1 + 2 + … + 4 = 10 elements, then 3 more in row 4: index 13.
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
- Count palindromic substrings by expanding around all 2n − 1 centres, and also count DISTINCT palindromic substrings. What is printed?…
- You need to sort 10⁷ integers, each in the range 0 to 999. Which approach is asymptotically fastest?
- Count pairs with a given difference k (k > 0) among DISTINCT values using a hash set. What is printed? python a, k = [8, 7, 7, 10, 5, 11…
- Why is a tombstone (a 'deleted' marker) used instead of emptying a slot when deleting from an open-addressing hash table?
- Which statement about using a hash set versus sorting to detect duplicates in an array of n integers is correct?
- Can a string become a palindrome by deleting at most one character? Two pointers try skipping either side on the first mismatch. What is…