Skip to content
Preptima

Arrays & Strings interview questions

In-place manipulation, prefix sums, and the string-scanning problems that open most coding rounds.

4 questions in Data Structures & Algorithms.

medium4

mediumCoding

Find the largest sum obtainable from a contiguous run of elements in an array.

Walk the array once, keeping the best sum ending at the current element - that element alone, or that element added to the best run ending before it. The maximum of those is the answer, and the familiar version that resets the running sum to zero is wrong when every element is negative.

4 minentry, mid, senior
mediumCoding

Rotate an array k positions to the right, in place.

Rotate array by k in place by normalising k modulo n, reversing the whole array, then reversing the first k and remaining n-k elements. It is O(n) time, O(1) extra space, and avoids the cyclic-replacement pitfalls unless write count matters. Use this ARRAYS answer to show the decision, trade-off, and evidence rather than a memorised definition.

4 minentry, mid, senior