InternDoor

PhonePe interview prep

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

Practise them as a timed round2 roles open at PhonePe

DSA 6

  1. DSAMedium

    What is the time complexity of inserting one element into a binary heap of n elements?

    1. O(n log n)
    2. O(1)
    3. O(n)
    4. O(log n)
    Show the answer

    D. O(log n)

    The new element goes at the end and is swapped upward while it beats its parent. The heap is a complete tree of height log n, so there are at most log n swaps.

    This topic is named in a candidate’s interview report: SDE (Android) interview, 2025, on Reddit.

  2. DSAEasy

    Which data structure is the natural fit for checking whether brackets like ([]{}) are balanced?

    1. A stack
    2. A queue
    3. A hash set
    4. A binary search tree
    Show the answer

    A. A stack

    Push each opening bracket. Each closing bracket must match the bracket on top, which is popped. The string is balanced if every bracket matched and the stack ends empty.

    This topic is named in a candidate’s interview report: On-campus interview, 2023, on GeeksforGeeks.

  3. DSAMedium

    A spell checker must say whether a word is in its dictionary and list the dictionary words that start with what was typed. Which data structure suits this best?

    1. A trie (prefix tree)
    2. A stack
    3. A min-heap
    4. A queue
    Show the answer

    A. A trie (prefix tree)

    A trie answers both "is this a word?" and "which words start with this?" in time proportional to the word's length. For "Did you mean" suggestions, spell checkers add an edit-distance search over the trie.

    This topic is named in a candidate’s interview report: On-campus interview, 2023, on GeeksforGeeks.

  4. DSAMedium

    Each element of [2, 3, 1, 1, 4] is the longest jump you can make from that position. What is the fewest jumps needed to reach the last index from index 0?

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

    D. 2

    Jump from index 0 to 1, then from 1 (which reaches up to 4) to the end: 2 jumps. The greedy BFS keeps the farthest reach of the current "level" and counts a jump each time the level ends, O(n).

    This topic is named in a candidate’s interview report: SDE (Android) interview, 2025, on Reddit.

  5. DSAMedium

    Dots are put into the digit string "25525511135" to make valid IPv4 addresses: four parts, each 0 to 255, with no leading zeros. How many valid addresses are there?

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

    C. 2

    Only 255.255.11.135 and 255.255.111.35 work. Backtracking tries 1, 2 or 3 digits for each part and drops any part above 255 or with a leading zero. With 4 parts of at most 3 digits there are at most 3^4 = 81 splits, so the work is constant.

    This topic is named in a candidate’s interview report: On-campus interview, 2024, on GeeksforGeeks.

  6. DSAEasy

    The sorted array [1, 1, 2, 3, 3, 3, 4] must have its duplicates removed in place, returning how many unique values it now keeps at the front. What does the two-pointer method return, and at what cost?

    1. 4, in O(n log n) time and O(1) extra space
    2. 7, in O(n) time and O(n) extra space
    3. 4, in O(n) time and O(1) extra space
    4. 4, in O(n) time and O(n) extra space
    Show the answer

    C. 4, in O(n) time and O(1) extra space

    A write pointer stays on the last kept value while a read pointer scans; each value that differs from the one at the write pointer is copied just after it. The front becomes 1, 2, 3, 4 and the answer is 4. Sorted input keeps duplicates side by side, so no set is needed.

    This topic is named in a candidate’s interview report: On-campus interview, 2024, on GeeksforGeeks.

Python 1

  1. PythonMedium

    What does this print?

    def follows(pattern, s):
        words = s.split()
        if len(words) != len(pattern):
            return False
        return len(set(pattern)) == len(set(words)) == len(set(zip(pattern, words)))
    
    print(follows("abba", "dog cat cat dog"), follows("abba", "dog dog dog dog"))
    1. True True
    2. True False
    3. False True
    4. False False
    Show the answer

    B. True False

    The pairs must form a one-to-one mapping: as many distinct letters as distinct words as distinct (letter, word) pairs. In the second case a and b both map to dog, so there are 2 letters but 1 word.

    This topic is named in a candidate’s interview report: SDE (Android) interview, 2025, on Reddit.

OOP 3

  1. OOPMedium

    What is the difference between static (early) and dynamic (late) binding?

    1. Static binding picks the method when the program is compiled, as for overloads; dynamic binding picks the override at run time from the object's real type
    2. Dynamic binding happens at compile time
    3. They are the same thing
    4. Static binding only applies to variables
    Show the answer

    A. Static binding picks the method when the program is compiled, as for overloads; dynamic binding picks the override at run time from the object's real type

    In Java, overloaded, static, private and final methods are bound at compile time. A call to an overridable instance method through a parent reference is bound at run time, which is what makes polymorphism work.

    This topic is named in a candidate’s interview report: On-campus interview, 2024, on GeeksforGeeks.

  2. OOPMedium

    Which lazily created Java singleton is thread-safe without taking a lock on every call?

    1. if (inst == null) inst = new Logger(); return inst; inside a static get()
    2. A public constructor that callers agree to call only once
    3. A holder class: private static class Holder { static final Logger I = new Logger(); } and get() returns Holder.I
    4. A static field that every constructor call overwrites
    Show the answer

    C. A holder class: private static class Holder { static final Logger I = new Logger(); } and get() returns Holder.I

    The JVM initialises Holder only when get() first touches it, and class initialisation is thread-safe, so the Logger is made once, lazily, with no lock afterwards. The plain null check can build two objects when two threads pass the check together. An enum with one constant is the other safe choice.

    This topic is named in a candidate’s interview report: On-campus interview, 2024, on GeeksforGeeks.

  3. OOPEasy

    How does abstraction differ from encapsulation?

    1. They are two names for the same idea
    2. Abstraction needs inheritance and encapsulation needs interfaces
    3. Abstraction shows what an object does and hides how; encapsulation keeps an object's data together with its methods and stops outside code from changing the data directly
    4. Encapsulation hides whole classes from other packages, nothing more
    Show the answer

    C. Abstraction shows what an object does and hides how; encapsulation keeps an object's data together with its methods and stops outside code from changing the data directly

    A List interface is abstraction: you call add() without knowing whether an array or linked nodes sit behind it. A BankAccount with a private balance changed only through deposit() is encapsulation: the class can refuse a negative deposit because nobody else touches the field.

    This topic is named in a candidate’s interview report: On-campus interview, 2024, on GeeksforGeeks.

DBMS and SQL 1

  1. DBMS and SQLMedium

    scores holds 95, 90, 90, 85 and 80. What does this return?

    SELECT score FROM scores
    ORDER BY score DESC
    LIMIT 1 OFFSET 2;
    1. 85
    2. 90
    3. 80
    4. 95
    Show the answer

    B. 90

    OFFSET skips rows, not values: in the order 95, 90, 90, 85, 80 the third row is the second 90. For the third-highest distinct score (85), use SELECT DISTINCT score ... LIMIT 1 OFFSET 2, or DENSE_RANK. The N-th highest needs OFFSET N - 1.

    This topic is named in a candidate’s interview report: On-campus interview, 2024, on GeeksforGeeks.

Operating systems 3

  1. Operating systemsEasy

    Which Linux command lists the running processes with their process IDs?

    1. ls -l
    2. df -h
    3. ps aux
    4. cat /etc/passwd
    Show the answer

    C. ps aux

    ps aux shows every process with its owner, PID, CPU and memory use and command. top shows the same live, kill PID stops one, ls -l lists files and df -h shows free disk space.

    This topic is named in a candidate’s interview report: On-campus interview, 2024, on GeeksforGeeks.

  2. Operating systemsMedium

    After chmod 754 report.sh, what may members of the file's group do with it?

    1. Read, change and run it
    2. Only read it
    3. Nothing
    4. Read it and run it, but not change it
    Show the answer

    D. Read it and run it, but not change it

    Each digit is read (4) + write (2) + execute (1), for owner, group and others in turn. 7 = rwx for the owner, 5 = r-x for the group and 4 = r-- for everyone else, so ls -l shows -rwxr-xr--.

    This topic is named in a candidate’s interview report: On-campus interview, 2024, on GeeksforGeeks.

  3. Operating systemsEasy

    A line of app.log contains "error" twice and another line contains it once. What does grep -c error app.log print?

    1. 3
    2. 2
    3. Both matching lines
    4. The line numbers of the matches
    Show the answer

    B. 2

    -c counts matching LINES, not matches, so the line with two errors counts once: 2. grep -o error app.log | wc -l would count every match (3), and grep -n prints matching lines with their line numbers.

    This topic is named in a candidate’s interview report: On-campus interview, 2024, on GeeksforGeeks.

Computer networks 3

  1. Computer networksMedium

    How do the layers of the TCP/IP model line up with the OSI model?

    1. TCP/IP has the same seven layers
    2. TCP/IP's application layer covers OSI application, presentation and session; transport and internet match OSI transport and network; the link layer covers data link and physical
    3. TCP/IP has no transport layer
    4. OSI is what the internet runs on; TCP/IP is only a teaching model
    Show the answer

    B. TCP/IP's application layer covers OSI application, presentation and session; transport and internet match OSI transport and network; the link layer covers data link and physical

    It is the other way round for the last option: the internet runs TCP/IP, and OSI is the seven-layer reference model used to talk about it. HTTP sits in TCP/IP's application layer, TCP and UDP in transport, IP in the internet layer, Ethernet and Wi-Fi in the link layer.

    This topic is named in a candidate’s interview report: On-campus interview, 2024, on GeeksforGeeks.

  2. Computer networksEasy

    An API answers with a status code in the 4xx range. What does that tell the caller?

    1. The request worked
    2. The server broke while handling a valid request
    3. The resource has moved
    4. The request itself cannot be served as sent: it is malformed, lacks a login, is not allowed or names something that does not exist
    Show the answer

    D. The request itself cannot be served as sent: it is malformed, lacks a login, is not allowed or names something that does not exist

    2xx is success, 3xx a redirect, 4xx the client's fault (400, 401, 403, 404, 429) and 5xx the server's (500, 502, 503). Retrying a 4xx unchanged usually fails again; a 503 or 429 is often worth retrying after a wait.

    This topic is named in a candidate’s interview report: On-campus interview, 2024, on GeeksforGeeks.

  3. Computer networksMedium

    A browser sends If-None-Match with the ETag of its cached copy, and the page has not changed. What should the server answer?

    1. 200 OK with the whole page again
    2. 304 Not Modified, with no body, so the browser uses its cached copy
    3. 204 No Content
    4. 412 Precondition Failed
    Show the answer

    B. 304 Not Modified, with no body, so the browser uses its cached copy

    A conditional GET saves sending the body again when nothing changed. The ETag is a version tag for the response; If-Modified-Since does the same with dates. 412 is for conditional writes, such as an If-Match that no longer matches.

    This topic is named in a candidate’s interview report: On-campus interview, 2024, on GeeksforGeeks.

Aptitude 1

  1. AptitudeMedium

    With a 3-litre and a 5-litre jug: fill the 5 and pour into the 3 until it is full, empty the 3, pour the 5's remainder into the 3, then fill the 5 again and top up the 3. How much is left in the 5-litre jug?

    1. 3 litres
    2. 2 litres
    3. 4 litres
    4. 1 litre
    Show the answer

    C. 4 litres

    The first pour leaves 2 litres in the 5. Those 2 go into the empty 3, which then needs 1 more. Topping it up from a full 5 leaves exactly 4 litres.

    This topic is named in a candidate’s interview report: On-campus interview, 2024, on GeeksforGeeks.

Prep for other employers

All employers
See who is hiring after PhonePe

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