InternDoor

HSBC interview prep

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

Practise them as a timed round3 roles open at HSBC

DSA 2

  1. DSAEasy

    An array holds the numbers from 1 to 8 with exactly one missing: [3, 7, 1, 2, 8, 4, 5]. Using the formula for the sum 1 + 2 + ... + n, which number is missing?

    1. 5
    2. 9
    3. 4
    4. 6
    Show the answer

    D. 6

    The full sum is 8 * 9 / 2 = 36 and the array adds up to 30, so 6 is missing. XORing 1 to n with every array element gives the same answer without any risk of overflow.

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

  2. DSAMedium

    You reverse a singly linked list in place by walking it once with three pointers, prev, curr and next. At each node, what do you do?

    1. Save next = curr.next, point curr.next at prev, then move prev to curr and curr to next
    2. Swap the node's value with the value at the other end of the list
    3. Push every node onto a stack, then pop them all
    4. Point curr.next at curr.next.next
    Show the answer

    A. Save next = curr.next, point curr.next at prev, then move prev to curr and curr to next

    Saving next first keeps the rest of the list reachable after the link is turned round. When curr becomes null, prev is the new head. One pass, O(n) time, O(1) extra space.

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

Python 1

  1. PythonEasy

    What does this print?

    def is_pal(s):
        i, j = 0, len(s) - 1
        while i < j:
            if s[i] != s[j]:
                return False
            i, j = i + 1, j - 1
        return True
    
    print(is_pal("racecar"), is_pal("racecars"))
    1. True True
    2. False True
    3. True False
    4. False False
    Show the answer

    C. True False

    Two indices move inwards comparing characters. racecar matches all the way; racecars fails at once because r and s differ. This needs no extra copy, unlike s == s[::-1].

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

Operating systems 1

  1. Operating systemsEasy

    Which Linux command lists the files in the current directory sorted by last modification time, newest first?

    1. ls -S
    2. ls -t
    3. sort -t
    4. ls -r
    Show the answer

    B. ls -t

    ls -t sorts by modification time, newest first, and ls -S by size, largest first. -r reverses either order. sort sorts lines of text, for example ls -l | sort -k5 -n.

    This topic is named in a candidate’s interview report: Trainee software engineer interview, 2023 batch, on GeeksforGeeks.

Prep for other employers

All employers
See who is hiring after HSBC

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