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.

MediumSystem Design
48 practiced
You have a very large read-only text stored in external flash accessible only via a block-read API:
ssize_t read_block(off_t offset, void *buf, size_t size);
Design an algorithm to search for a pattern of length m (m <= 512) in the huge text using <4KB RAM and minimizing block reads. Provide high-level pseudocode and explain how you handle block boundaries and state retention between reads.
EasyTechnical
48 practiced
Write a C implementation of a naive substring search:
int naive_strstr(const char *haystack, const char *needle);
Return the index of the first occurrence of needle in haystack or -1 if not found. Do not call library search functions. Handle empty needle (return 0) and avoid reading past terminators. This will be used in embedded code with small stacks.
HardTechnical
84 practiced
Implement in C an in-place POSIX-style path canonicalizer:
size_t canonicalize_path(char *path);
Given a null-terminated path that may contain "/", "//", ".", and ".." components, transform it in-place to the canonical path (no trailing slash unless root) and return the new length. No heap allocation; the path buffer has a fixed size—ensure you never write past the original buffer.
MediumTechnical
60 practiced
Implement UTF-8 validation and codepoint counting in C:
ssize_t utf8_validate_and_count(const uint8_t *buf, size_t len);
Return the number of Unicode codepoints if the byte sequence is valid UTF-8, otherwise return -1. Validate against overlong encodings, invalid continuation bytes, and surrogate halves. Target correctness over exotic performance features.
MediumTechnical
49 practiced
Implement a function that computes the length of the longest substring without repeating characters for an ASCII string:
size_t longest_unique_substr_len(const char *s);
Aim for O(n) time and O(1) extra memory (bounded by a 256-entry table). This is intended for an embedded device where heap usage is undesirable. Discuss how to adapt the solution for full Unicode codepoints and for very large alphabets when memory is constrained.

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.