VMware Coding Round Questions with Solutions in Python and Java
Last updated 2026-11-19
VMware builds systems software, so a good practice set mixes classic data structures with problems that echo operating systems: a bounded queue with condition variables, efficient string matching, in-place rotation, list sorting and page-replacement simulation.
Solve each yourself first, then compare with the worked Python and Java solutions, which include complexity and the mistakes to avoid.
| Problems | 10, medium to hard |
|---|---|
| Languages | Python and Java |
| Patterns | Concurrency, KMP, quickselect, lists, BST, simulation |
| Official process | Not published; practice set |
Why these problems suit a systems company
There is no sourced description of VMware's coding rounds, so this is a practice set built around the themes of systems software: concurrency primitives, efficient string and numeric routines, in-place array and list manipulation, and operating-system simulations. They are practice problems, not real test content. Expect any such round to still test mainstream data structures too.
For operating-system, networking and behavioural preparation see VMware interview questions.
Mistakes in systems-flavoured problems
- Using notify where notifyAll is needed, or an if instead of a while around a wait.
- Integer overflow when negating or multiplying in Java.
- Not cutting a list before recursing on its halves.
- Forgetting to reassign a modified subtree to its parent.
- Ignoring a random pivot, which exposes quickselect to worst-case inputs.
Hiring status
There is no sourced hiring information for VMware in the records used for this site. VMware is now part of Broadcom, so check Broadcom's own careers site for current roles.
VMware Coding Round Questions with Solutions in Python and Java: questions with worked answers
1 Bounded blocking queue: implement a thread-safe queue with a maximum capacity.
hardUse one lock and a condition: put waits while the queue is full, get waits while it is empty, and each notifies waiting threads after changing the queue. Wait in a while loop, not an if, to survive spurious wake-ups. Operations are O(1). Mistake: using notify instead of notifyAll with several waiting producers and consumers, which can leave the wrong thread waiting and deadlock the system.
pythonimport threading from collections import deque class BoundedQueue: def __init__(self, cap): self.q, self.cap = deque(), cap self.cv = threading.Condition() def put(self, x): with self.cv: while len(self.q) == self.cap: self.cv.wait() self.q.append(x) self.cv.notify_all() def get(self): with self.cv: while not self.q: self.cv.wait() x = self.q.popleft() self.cv.notify_all() return xjavaimport java.util.*; class BoundedQueue<T> { private final Queue<T> q = new ArrayDeque<>(); private final int cap; BoundedQueue(int cap) { this.cap = cap; } synchronized void put(T x) throws InterruptedException { while (q.size() == cap) wait(); q.add(x); notifyAll(); } synchronized T get() throws InterruptedException { while (q.isEmpty()) wait(); T x = q.poll(); notifyAll(); return x; } }2 Implement strStr using KMP: first index of a needle in a haystack.
hardBuild the longest-proper-prefix-which-is-also-suffix (LPS) table for the needle, then scan the haystack; on a mismatch use the table to jump back in the needle instead of restarting. Time O(n + m), space O(m). Mistake: the naive nested loop is O(n m) in the worst case, and forgetting that an empty needle returns 0.
pythondef str_str(h, n): if not n: return 0 lps, k = [0] * len(n), 0 for i in range(1, len(n)): while k and n[i] != n[k]: k = lps[k - 1] if n[i] == n[k]: k += 1 lps[i] = k k = 0 for i, c in enumerate(h): while k and c != n[k]: k = lps[k - 1] if c == n[k]: k += 1 if k == len(n): return i - k + 1 return -1javaclass Solution { int strStr(String h, String n) { if (n.isEmpty()) return 0; int[] lps = new int[n.length()]; for (int i = 1, k = 0; i < n.length(); i++) { while (k > 0 && n.charAt(i) != n.charAt(k)) k = lps[k - 1]; if (n.charAt(i) == n.charAt(k)) k++; lps[i] = k; } for (int i = 0, k = 0; i < h.length(); i++) { while (k > 0 && h.charAt(i) != n.charAt(k)) k = lps[k - 1]; if (h.charAt(i) == n.charAt(k)) k++; if (k == n.length()) return i - k + 1; } return -1; } }3 Longest Valid Parentheses substring.
hardUse a stack of indices with a base marker: push -1 first; for '(' push its index; for ')' pop, and if the stack is empty push the current index as a new base, otherwise the valid length is the current index minus the new top. Track the maximum. Time O(n), space O(n). Mistake: counting matched pairs globally, which ignores that unmatched characters break the substring.
pythondef longest_valid(s): st, best = [-1], 0 for i, c in enumerate(s): if c == '(': st.append(i) else: st.pop() if not st: st.append(i) else: best = max(best, i - st[-1]) return bestjavaimport java.util.*; class Solution { int longestValid(String s) { Deque<Integer> st = new ArrayDeque<>(); st.push(-1); int best = 0; for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == '(') st.push(i); else { st.pop(); if (st.isEmpty()) st.push(i); else best = Math.max(best, i - st.peek()); } } return best; } }4 Kth Largest Element using quickselect.
mediumPartition around a pivot as in quicksort, and recurse only into the side that contains the target index (n - k in ascending order). Expected time O(n), worst case O(n squared) with bad pivots, so choose a random pivot. Space O(1) iteratively. A heap of size k gives a guaranteed O(n log k). Mistake: sorting the whole array when only one order statistic is needed.
pythonimport random def kth_largest(a, k): target, lo, hi = len(a) - k, 0, len(a) - 1 while True: p = random.randint(lo, hi) a[p], a[hi] = a[hi], a[p] store = lo for i in range(lo, hi): if a[i] < a[hi]: a[i], a[store] = a[store], a[i]; store += 1 a[store], a[hi] = a[hi], a[store] if store == target: return a[store] if store < target: lo = store + 1 else: hi = store - 1javaimport java.util.*; class Solution { int kthLargest(int[] a, int k) { int target = a.length - k, lo = 0, hi = a.length - 1; Random rnd = new Random(); while (true) { int p = lo + rnd.nextInt(hi - lo + 1); swap(a, p, hi); int store = lo; for (int i = lo; i < hi; i++) if (a[i] < a[hi]) swap(a, i, store++); swap(a, store, hi); if (store == target) return a[store]; if (store < target) lo = store + 1; else hi = store - 1; } } private void swap(int[] a, int i, int j) { int t = a[i]; a[i] = a[j]; a[j] = t; } }5 Rotate an Array right by k places in place.
mediumReverse the whole array, then reverse the first k elements and then the rest, after reducing k modulo n. Time O(n), space O(1). Mistake: using extra space or shifting one step at a time k times, which is O(n k), and forgetting k can exceed n.
pythondef rotate(a, k): n = len(a); k %= n def rev(l, r): while l < r: a[l], a[r] = a[r], a[l]; l += 1; r -= 1 rev(0, n - 1); rev(0, k - 1); rev(k, n - 1)javaclass Solution { void rotate(int[] a, int k) { int n = a.length; k %= n; rev(a, 0, n - 1); rev(a, 0, k - 1); rev(a, k, n - 1); } private void rev(int[] a, int l, int r) { while (l < r) { int t = a[l]; a[l++] = a[r]; a[r--] = t; } } }6 Sort a Linked List in O(n log n) time with merge sort.
mediumFind the middle with slow and fast pointers, cut the list in two, sort each half recursively and merge the sorted halves. Time O(n log n), space O(log n) for recursion. Merge sort suits linked lists because merging needs no random access. Mistake: not cutting the list at the middle (the first half still points into the second), which causes infinite recursion.
pythondef 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(0) 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.nextjavaclass ListNode { int val; ListNode next; ListNode(int v) { val = v; } } class Solution { ListNode sortList(ListNode head) { if (head == null || head.next == null) return head; ListNode slow = head, fast = head.next; while (fast != null && fast.next != null) { slow = slow.next; fast = fast.next.next; } ListNode mid = slow.next; slow.next = null; ListNode a = sortList(head), b = sortList(mid); ListNode dummy = new ListNode(0), tail = dummy; while (a != null && b != null) { if (a.val <= b.val) { tail.next = a; a = a.next; } else { tail.next = b; b = b.next; } tail = tail.next; } tail.next = a != null ? a : b; return dummy.next; } }7 Delete a Node from a Binary Search Tree.
mediumFind the node. If it has no left child return its right child; if no right child return its left child. With two children, replace its value with the smallest value of the right subtree (the in-order successor) and delete that value from the right subtree. Time O(h), space O(h). Mistake: forgetting to reassign the returned subtree root to the parent's pointer, so the deletion is lost.
pythondef delete_node(root, key): if not root: return None if key < root.val: root.left = delete_node(root.left, key) elif key > root.val: root.right = delete_node(root.right, key) else: if not root.left: return root.right if not root.right: return root.left s = root.right while s.left: s = s.left root.val = s.val root.right = delete_node(root.right, s.val) return rootjavaclass TreeNode { int val; TreeNode left, right; } class Solution { TreeNode deleteNode(TreeNode root, int key) { if (root == null) return null; if (key < root.val) root.left = deleteNode(root.left, key); else if (key > root.val) root.right = deleteNode(root.right, key); else { if (root.left == null) return root.right; if (root.right == null) return root.left; TreeNode s = root.right; while (s.left != null) s = s.left; root.val = s.val; root.right = deleteNode(root.right, s.val); } return root; } }8 Pow(x, n): compute x to the power n efficiently.
mediumUse exponentiation by squaring: if n is even, square x and halve n; if odd, multiply the result by x. Handle negative n by inverting x and negating n, and use a long for n in Java because negating Integer.MIN_VALUE overflows. Time O(log n), space O(1). Mistake: a loop of n multiplications, or the overflow on the minimum integer.
pythondef my_pow(x, n): if n < 0: x, n = 1 / x, -n res = 1.0 while n: if n & 1: res *= x x *= x n >>= 1 return resjavaclass Solution { double myPow(double x, int n) { long e = n; if (e < 0) { x = 1 / x; e = -e; } double res = 1.0; while (e > 0) { if ((e & 1) == 1) res *= x; x *= x; e >>= 1; } return res; } }9 Reverse Integer with overflow detection (32-bit).
mediumPop digits with n % 10 and push onto the result, but before each push check whether result x 10 + digit would overflow the 32-bit range, and return 0 if so. In Python, which has no overflow, check the final value against the range. Time O(log n). Mistake: checking after the overflow has already happened in languages where it wraps silently.
pythondef reverse(x): sign = -1 if x < 0 else 1 r, x = 0, abs(x) while x: r = r * 10 + x % 10 x //= 10 r *= sign return r if -2**31 <= r <= 2**31 - 1 else 0javaclass Solution { int reverse(int x) { int r = 0; while (x != 0) { int d = x % 10; x /= 10; if (r > Integer.MAX_VALUE / 10 || (r == Integer.MAX_VALUE / 10 && d > 7)) return 0; if (r < Integer.MIN_VALUE / 10 || (r == Integer.MIN_VALUE / 10 && d < -8)) return 0; r = r * 10 + d; } return r; } }10 Count page faults for a reference string using LRU replacement.
mediumSimulate with an ordered map of pages in memory, most recently used last. On a hit move the page to the end; on a miss count a fault, evict the first (least recently used) page if memory is full, and insert the new page at the end. Time O(n) with an ordered dictionary. Mistake: not refreshing recency on a hit, which turns the policy into FIFO.
pythonfrom collections import OrderedDict def lru_faults(refs, frames): mem, faults = OrderedDict(), 0 for p in refs: if p in mem: mem.move_to_end(p) else: faults += 1 if len(mem) == frames: mem.popitem(last=False) mem[p] = True return faultsjavaimport java.util.*; class Solution { int lruFaults(int[] refs, int frames) { LinkedHashSet<Integer> mem = new LinkedHashSet<>(); int faults = 0; for (int p : refs) { if (mem.remove(p)) { mem.add(p); continue; } faults++; if (mem.size() == frames) mem.remove(mem.iterator().next()); mem.add(p); } return faults; } }
Frequently asked questions
What coding questions does VMware ask?
There is no official list. Commonly reported are data structures problems plus topics from operating systems and concurrency. This page is a practice set.
Which language should I use?
Use the language allowed and fastest for you. Python and Java are both given for every problem.
Do I need to know threads for VMware interviews?
Basic synchronisation, such as locks, conditions and producer-consumer, is worth knowing for systems teams.
What should I read next?
Related guides
- VMware Interview Questions and Answers for Systems and SDE Roles
- Cisco Coding Round Questions with Solutions in Python and Java
- Oracle Coding Round Questions with Solutions in Python and Java
- Operating Systems Interview Questions with Worked Answers
- Linked list interview questions with worked solutions
- Bit manipulation interview questions with worked solutions
More in Company Interview Questions
- VMware Interview Questions and Answers for Systems and SDE Roles
- Walmart Coding Round Questions With Solutions
- Walmart Global Tech Interview Questions and Answers
- Wells Fargo coding round questions with solutions
- Wells Fargo interview questions with answers (technology roles)
- Wipro Coding Round Questions with Solutions
- Wipro Interview Questions for Freshers
- Workday Coding Round Questions With Solutions
- Workday Interview Questions and Answers
- Zensar Coding Round Questions with Solutions
- Zensar Interview Questions for Freshers
- Zepto Coding Round Questions with Solutions