InternDoor

GlobalLogic interview prep

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

Practise them as a timed round25 roles open at GlobalLogic

DSA 4

  1. DSAEasy

    The positive numbers divisible by 2 or by 3, in order, are 2, 3, 4, 6, 8, 9, ... What is the 10th one?

    1. 14
    2. 15
    3. 16
    4. 18
    Show the answer

    B. 15

    Listing them: 2, 3, 4, 6, 8, 9, 10, 12, 14, 15. For large n, binary search on x with count(x) = x/2 + x/3 - x/6 finds the answer without listing.

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

  2. DSAMedium

    An array holds only the values 3, 4 and 5, in any order. What sorts it in a single pass with O(1) extra space?

    1. Merge sort
    2. Building a balanced binary search tree
    3. Bubble sort with an early exit
    4. Dutch national flag partitioning with three pointers (low, mid, high)
    Show the answer

    D. Dutch national flag partitioning with three pointers (low, mid, high)

    mid scans the array: a 3 is swapped to low, a 5 to high, a 4 is left in place. Each element is handled once, so the pass is O(n) with three indices of extra space.

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

  3. DSAMedium

    The diameter of a binary tree is the number of edges on the longest path between any two nodes. A root has a left child L and a right child R, and L has a left child LL. What is the diameter?

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

    D. 3

    The longest path is LL - L - root - R, which has 3 edges. In general, for each node take (height of left subtree) + (height of right subtree) and keep the maximum, all in one O(n) traversal.

    This topic is named in a candidate’s interview report: Pool campus interview, 2019, on GeeksforGeeks.

  4. DSAMedium

    Mirroring a binary tree swaps the left and right children of every node. If a tree's in-order traversal is 1 2 3 4 5, what is the in-order traversal of its mirror?

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

    B. 5 4 3 2 1

    In-order visits left, node, right. In the mirror every left and right are exchanged, so the same visit happens in exactly the reverse order.

    This topic is named in a candidate’s interview report: Pool campus interview, 2019, on GeeksforGeeks.

Python 3

  1. PythonEasy

    What does this print?

    a, b = 5, 9
    a = a + b
    b = a - b
    a = a - b
    print(a, b)
    1. 5 9
    2. 14 5
    3. 9 5
    4. 9 14
    Show the answer

    C. 9 5

    After a = a + b, a is 14. b = 14 - 9 = 5, the old a. a = 14 - 5 = 9, the old b. The values are swapped without a third variable (in fixed-size integer languages the sum can overflow, which is why XOR swaps are also taught).

    This topic is named in a candidate’s interview report: Software engineer trainee interview, 2023, on GeeksforGeeks.

  2. PythonEasy

    What does this print?

    s = "  I love  coding "
    print(" ".join(s.split()[::-1]))
    1. coding love I
    2. gnidoc evol I
    3. coding love I
    4. I love coding
    Show the answer

    A. coding love I

    split() with no argument splits on any run of whitespace and drops the empty pieces, giving ['I', 'love', 'coding']. [::-1] reverses the list and join puts single spaces back.

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

  3. 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: Software engineer trainee interview, 2023, on GeeksforGeeks.

Aptitude 2

  1. AptitudeMedium

    Nine balls look the same, but one is heavier. With a balance scale, what is the fewest number of weighings that always finds the heavy ball?

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

    C. 2

    Weigh 3 against 3. If they balance, the heavy ball is in the other 3; otherwise it is in the heavier group. Then weigh 1 against 1 from that group the same way. Each weighing has 3 outcomes, and 3 x 3 = 9.

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

  2. AptitudeHard

    25 horses, a track that races 5 at a time and no timer. What is the minimum number of races needed to find the 3 fastest?

    1. 6
    2. 7
    3. 8
    4. 11
    Show the answer

    B. 7

    5 heats rank every horse within its group. Race 6, the five heat winners, finds the fastest overall. Only 5 horses can still be second or third: the 2nd and 3rd of the winner's heat, the winner and 2nd of the runner-up's heat, and the winner of the 3rd-place heat. Race 7 settles them.

    This topic is named in a candidate’s interview report: Pool campus interview, 2019, on GeeksforGeeks.

Prep for other employers

All employers
See who is hiring after GlobalLogic

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