Autocoder

Nutanix Coding Round Questions With Solutions

Last updated 2026-11-19

Nutanix coding questions are commonly reported to emphasise pointer-style problems and fundamentals: linked lists, bit manipulation, trees, dynamic programming and binary search, often expected in C or C++. The ten practice problems below follow that style, with the idea, code, complexity and a typical mistake.

They are practice problems, not real papers. For systems and design questions see Nutanix interview questions, and for general pacing read how to crack a DSA coding round.

How to practise

Write linked list and tree code without relying on a library, and dry-run it on empty, single-node and two-node inputs. In C++, be explicit about ownership, null checks and integer overflow.

Hiring status

We have no sourced Nutanix hiring dates, numbers or format details, so none are stated. Check the company's own careers site for current roles. For test strategy see how to crack the online assessment.

Nutanix Coding Round Questions With Solutions: questions with worked answers

  1. 1

    Remove the n-th node from the end of a linked list in one pass.

    medium

    Use a dummy head and two pointers. Advance the fast pointer n steps ahead, then move both until fast reaches the last node; the slow pointer is just before the node to delete. O(L) time, O(1) space. Mistake: no dummy node, which breaks when the head itself is removed.

    python
    class ListNode:
        def __init__(self, val=0, next=None):
            self.val, self.next = val, next
    
    def remove_nth_from_end(head, n):
        dummy = ListNode(0, head)
        fast = slow = dummy
        for _ in range(n):
            fast = fast.next
        while fast.next:
            fast, slow = fast.next, slow.next
        slow.next = slow.next.next
        return dummy.next
    cpp
    ListNode* removeNthFromEnd(ListNode* head, int n) {
        ListNode dummy(0, head);
        ListNode *fast = &dummy, *slow = &dummy;
        for (int i = 0; i < n; i++) fast = fast->next;
        while (fast->next) { fast = fast->next; slow = slow->next; }
        ListNode* del = slow->next;
        slow->next = del->next;
        delete del;
        return dummy.next;
    }
  2. 2

    Add two numbers stored as reversed linked lists.

    medium

    Walk both lists with a carry, creating a node for each digit sum modulo 10, and keep going while either list or the carry remains. O(max(m, n)). Mistake: dropping the final carry, so 5 plus 5 returns 0 instead of 01 reversed.

    python
    def add_two(a, b):
        dummy = tail = ListNode()
        carry = 0
        while a or b or carry:
            s = carry + (a.val if a else 0) + (b.val if b else 0)
            carry, digit = divmod(s, 10)
            tail.next = ListNode(digit)
            tail = tail.next
            a = a.next if a else None
            b = b.next if b else None
        return dummy.next
  3. 3

    Sort a linked list in O(n log n) with O(1) extra space apart from recursion.

    hard

    Use merge sort: split at the middle with slow and fast pointers (cutting the link), sort each half recursively, and merge. The recursion depth is O(log n). Mistake: finding the middle without cutting the list, which recurses forever on the same nodes.

    python
    def sort_list(head):
        if not head or not head.next:
            return head
        slow, fast = head, head.next
        while fast and fast.next:
            slow, fast = slow.next, fast.next.next
        mid, slow.next = slow.next, None
        a, b = sort_list(head), sort_list(mid)
        dummy = tail = ListNode()
        while a and b:
            if a.val <= b.val:
                tail.next, a = a, a.next
            else:
                tail.next, b = b, b.next
            tail = tail.next
        tail.next = a or b
        return dummy.next
  4. 4

    Reverse the bits of a 32-bit unsigned integer.

    easy

    Build the result by shifting it left and appending the lowest bit of the input, 32 times, shifting the input right each time. O(32), which is constant. Mistake: using signed integers in Java or C++ and mishandling the sign bit; use unsigned types or masks.

    python
    def reverse_bits(n):
        r = 0
        for _ in range(32):
            r = (r << 1) | (n & 1)
            n >>= 1
        return r
    cpp
    uint32_t reverseBits(uint32_t n) {
        uint32_t r = 0;
        for (int i = 0; i < 32; i++) {
            r = (r << 1) | (n & 1);
            n >>= 1;
        }
        return r;
    }
  5. 5

    Diameter of a binary tree.

    easy

    The diameter through a node is the left height plus the right height (in edges). Compute heights bottom-up with DFS and update a global best at every node. O(n) time, O(h) space. Mistake: computing height separately at every node, which makes it O(n squared) on skewed trees.

    python
    def diameter(root):
        best = 0
        def height(n):
            nonlocal best
            if not n:
                return 0
            l, r = height(n.left), height(n.right)
            best = max(best, l + r)
            return 1 + max(l, r)
        height(root)
        return best
  6. 6

    Find a peak element in O(log n).

    medium

    A peak is greater than its neighbours. Binary search: if a[mid] is less than a[mid+1], a peak lies to the right; otherwise one lies at mid or to the left. This works because the ends are treated as negative infinity. Mistake: comparing with mid minus one only, which can loop forever.

    python
    def find_peak(a):
        lo, hi = 0, len(a) - 1
        while lo < hi:
            mid = (lo + hi) // 2
            if a[mid] < a[mid + 1]:
                lo = mid + 1
            else:
                hi = mid
        return lo
  7. 7

    Count unique binary search trees with n keys.

    medium

    The count is the n-th Catalan number: for each root i, multiply the number of left subtrees with i - 1 keys and right subtrees with n - i keys, summed over roots. dp[0] = dp[1] = 1. O(n squared). Mistake: forgetting that an empty subtree counts as one way.

    python
    def num_trees(n):
        dp = [1, 1] + [0] * (n - 1)
        for k in range(2, n + 1):
            dp[k] = sum(dp[i - 1] * dp[k - i] for i in range(1, k + 1))
        return dp[n]
  8. 8

    Compute x to the power n (fast exponentiation, negative n allowed).

    medium

    Square the base and halve the exponent, multiplying into the result when the exponent is odd. For negative n, invert the base and negate n. O(log n). Mistake: negating n = -2^31 in a 32-bit integer, which overflows; use a wider type.

    python
    def my_pow(x, n):
        if n < 0:
            x, n = 1 / x, -n
        r = 1.0
        while n:
            if n & 1:
                r *= x
            x *= x
            n >>= 1
        return r
  9. 9

    Copy a linked list with random pointers.

    hard

    Use a dictionary from original node to copy: first pass creates copies, second pass sets next and random. O(n) time and space. An O(1) space variant weaves each copy after its original, sets random pointers, then unweaves. Mistake: copying only next pointers and sharing random pointers with the original.

    python
    class RNode:
        def __init__(self, val, next=None, random=None):
            self.val, self.next, self.random = val, next, random
    
    def copy_random_list(head):
        m, cur = {None: None}, head
        while cur:
            m[cur] = RNode(cur.val)
            cur = cur.next
        cur = head
        while cur:
            m[cur].next = m[cur.next]
            m[cur].random = m[cur.random]
            cur = cur.next
        return m[head]
  10. 10

    Flatten a binary tree to a linked list in preorder, in place.

    medium

    Use a Morris-style approach: for each node with a left child, find the rightmost node of the left subtree, link it to the node's right child, move the left subtree to the right, and set left to null. O(n) time, O(1) space. Mistake: losing the original right child before attaching it.

    python
    def flatten(root):
        cur = root
        while cur:
            if cur.left:
                p = cur.left
                while p.right:
                    p = p.right
                p.right = cur.right
                cur.right, cur.left = cur.left, None
            cur = cur.right

Frequently asked questions

Are Nutanix coding questions hard?

Commonly reported as medium level with strong fundamentals expected, in particular linked lists, trees and bit manipulation.

Should I use C++?

If the role is core systems, C++ is a natural choice. Otherwise use the language you are fastest in, if the platform allows it.

Are there MCQs?

Candidate accounts mention technical MCQs alongside coding in the online assessment. Check your invitation.

Which topics come up most?

Linked lists, trees, bits, binary search and dynamic programming, plus OS fundamentals in interviews.

Related guides

More in Company Interview Questions

See all in this section