InterviewStack.io LogoInterviewStack.io

Array and String Manipulation Questions

Comprehensive coverage of language level operations and algorithmic techniques for arrays and strings that are commonly evaluated in coding interviews. Candidates should understand common language methods for arrays and strings, including their parameters and return values, chaining of operations, and the implications of mutable versus immutable types for in place versus extra space solutions. Core algorithmic patterns include iteration and traversal, index based and pointer based approaches, two pointer strategies, sliding window, prefix and suffix sums, sorting and partitioning, and cumulative or running sums. Problem classes include traversal, insertion and deletion, reversing and rotating, merging and deduplicating, subarray and substring search, anagram detection, palindrome detection, longest substring and maximum subarray problems, and pointer based reordering and partitioning tasks. Pattern matching techniques include naive matching, Knuth Morris Pratt and rolling hash approaches, and hashing for frequency and membership checks. String transformation and comparison topics include edit distance, sequence transformation problems such as word ladder, and parsing and validation tasks. Candidates should be prepared to implement correct and efficient solutions in common programming languages, reason about time and space complexity, optimize for input size and memory constraints, handle edge cases such as empty inputs and boundary conditions, and address character level concerns such as encoding differences, multibyte characters, surrogate pairs and unicode normalization. Interviewers may probe language specific implementation details, in place mutation versus copying, fixed buffer strategies, streaming or incremental algorithms for large inputs, and trade offs between clarity and performance. Expect questions that require selecting the right algorithmic pattern, implementing a robust solution, and justifying complexity and memory decisions.

MediumTechnical
62 practiced
Implement a Rabin-Karp rolling-hash based function in Python to find the first occurrence of a pattern in a text. Your implementation should compute rolling hashes in O(1) per step, handle collisions by verification, and work with Unicode by mapping codepoints to integers. Explain choice of base and modulus and how to reduce collision probability.
EasyTechnical
53 practiced
In C, implement a routine that replaces all spaces in a fixed-size character buffer with '%20' in place, given the true length of the string and enough buffer capacity. This is the classic URL-encode-in-place task often used in tight-memory systems. Carefully describe how you compute the new length and perform the copy safely.
EasyTechnical
54 practiced
Write a Python function that receives a Unicode string and returns the k most frequent characters (or codepoints) with their counts. Your solution should do a single pass over the data and be streaming friendly (constant memory relative to input size except for the output). Explain trade-offs when k is large and how you'd approximate when memory is constrained.
HardTechnical
58 practiced
Explain suffix arrays and how to construct them (e.g., prefix-doubling algorithm) and how to compute the LCP array. Then describe how to use SA + LCP to compute the number of distinct substrings in O(n log n) or O(n) time. Provide high-level pseudocode and complexity analysis.
EasyTechnical
48 practiced
Given a sorted list of integers and a target integer, implement an O(n) time, O(1) extra space function in Python that returns a pair of indices (i, j) such that nums[i] + nums[j] == target. If no such pair exists, return (-1, -1). Provide example input/output and explain edge cases (duplicates, negative numbers).

Unlock Full Question Bank

Get access to hundreds of Array and String Manipulation interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.