InternDoor

KPIT interview prep

5 practice questions on the topics candidates reported from KPIT interviews, with answers. The questions are ours; each one links to the interview report that names its topic.

Practise them as a timed round

DSA 4

  1. DSAMedium

    A frog starts on stone 0 and must reach the last stone. From stone i it can jump to stone i + 1 or i + 2, paying |h[i] - h[j]| to land on stone j. The heights are [10, 20, 30, 10]. What is the least total cost?

    1. 30
    2. 40
    3. 20
    4. 10
    Show the answer

    C. 20

    dp[i] = min(dp[i-1] + |h[i] - h[i-1]|, dp[i-2] + |h[i] - h[i-2]|), giving dp = [0, 10, 20, 20]: jump 0 -> 1 -> 3 for 10 + 10. Each stone needs only the two before it, so O(n) time and O(1) space.

    This topic is named in a candidate’s interview report: Associate software engineer online test, 2026, on Reddit.

  2. DSAMedium

    In this grid, 1 is land and 0 is water, and land joins up, down, left and right. How many islands are there?

    1 1 0 0
    0 1 0 1
    1 0 0 1
    0 0 1 0
    1. 3
    2. 5
    3. 4
    4. 2
    Show the answer

    C. 4

    The top-left 1s form one island; the two 1s in the right column form another; the lone 1 at row 3, column 1 and the lone 1 at row 4, column 3 are one each: 4. A DFS from each unvisited land cell is O(rows x columns).

    This topic is named in a candidate’s interview report: Campus interview, 2026, on Reddit.

  3. DSAEasy

    Plain selection sort (find the smallest remaining element, swap it to the front) sorts an array of 6 elements. How many passes does it make?

    1. 6
    2. 3
    3. 5
    4. It depends on the order of the elements
    Show the answer

    C. 5

    Each pass fixes one position, and once 5 are in place the last is too, so n - 1 = 5 passes whatever the input. It always makes about n^2 / 2 comparisons but at most n - 1 swaps, which is its one strength when writes are costly.

    This topic is named in a candidate’s interview report: Associate software engineer online test, 2026, on Reddit.

  4. DSAMedium

    For [40, 10, 30, 20], write for each element its position (0-based) in the sorted array. What do you get?

    1. [1, 3, 2, 0]
    2. [3, 0, 2, 1]
    3. [0, 1, 2, 3]
    4. [3, 1, 2, 0]
    Show the answer

    B. [3, 0, 2, 1]

    Sorted, the array is [10, 20, 30, 40], so 40 sits at 3, 10 at 0, 30 at 2 and 20 at 1. Sort pairs of (value, original index), then write each sorted position back at its original index: O(n log n). With repeated values, decide first whether ties share a rank.

    This topic is named in a candidate’s interview report: Campus interview, 2026, on Reddit.

Java 1

  1. JavaMedium

    How long does get(key) usually take on a java.util.HashMap and on a java.util.TreeMap, each with n entries?

    1. Both O(1)
    2. Both O(log n)
    3. HashMap O(log n); TreeMap O(1)
    4. HashMap O(1) on average; TreeMap O(log n)
    Show the answer

    D. HashMap O(1) on average; TreeMap O(log n)

    HashMap hashes the key straight to a bucket. TreeMap is a red-black tree kept sorted by key, so every get and put costs O(log n), but it can also give the keys in order, the first or last key, or every key in a range.

    This topic is named in a candidate’s interview report: Campus interview, 2026, on Reddit.

Prep for other employers

All employers
See who is hiring after KPIT

Engineering internships and entry-level jobs in India, newest first.