Arrays, Strings, and Linked Lists Mastery Questions
Foundational data structures: arrays, strings, and linked lists. Covers core operations (insertion, deletion, traversal, searching), pattern usage, edge cases, and time/space complexity analysis, with a focus on practical implementation and common interview-style problems across mainstream programming languages.
MediumTechnical
33 practiced
Given an array of k sorted linked lists, implement mergeKLists(lists) in Java to merge them into one sorted linked list. Discuss possible approaches: iteratively merging pairs, divide-and-conquer, and using a min-heap (priority queue). Analyze time and space complexity of each approach and choose the best for large k.
EasyTechnical
46 practiced
Implement mergeSortedArrays(a, b) in C++ to merge two sorted integer arrays into a new sorted array and return it. Target O(n + m) time and O(n + m) space. Example: a = [1,3,5], b = [2,4] -> [1,2,3,4,5]. Discuss stability, handling duplicates, and behavior when one array is empty.
EasyTechnical
27 practiced
Implement reverse_array(arr) in Python that reverses an array of integers in-place without allocating another array. Constraints: O(n) time, O(1) extra space. Example: Input: arr = [1, 2, 3, 4, 5] -> Output: [5, 4, 3, 2, 1]. Describe behavior for empty arrays, arrays with one element, and odd/even lengths. Discuss time/space complexity and write brief tests.
EasyTechnical
27 practiced
Implement stringToInt(str) in Java (similar to atoi). Parse leading whitespace, optional '+' or '-', then digit sequence. Stop at first non-digit. Clamp results to 32-bit signed integer range on overflow. Example: ' -42' -> -42, '4193 with words' -> 4193, '2147483648' -> 2147483647. Discuss edge cases and time complexity.
MediumTechnical
31 practiced
Given singly linked list L: L0->L1->...->Ln, implement reorderList(head) in C++ to transform it to L0->Ln->L1->Ln-1->... in-place without changing node values and using O(1) extra memory. Explain steps: find middle, reverse second half, merge halves and discuss correctness and complexity.
Unlock Full Question Bank
Get access to hundreds of Arrays, Strings, and Linked Lists Mastery interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.