Skip to content

VMware Coding Questions - DSA Problems & Solutions

Practice VMware placement paper coding questions with detailed solutions. Access VMware OA coding problems in Java, C++, Python.

This page contains VMware coding questions from VMware OA placement papers with detailed solutions.

VMware OA Coding Section:

  • Problems: 2-3 coding problems
  • Time: 90 minutes
  • Languages: C++, Java, Python
Q1: Given n virtual machines and their resource requirements, schedule them optimally on k hosts.

Solution (Java):

public int scheduleVMs(int[] vms, int k) {
// Greedy approach: assign VMs to least loaded host
PriorityQueue<Integer> hosts = new PriorityQueue<>();
for (int i = 0; i < k; i++) {
hosts.offer(0);
}
for (int vm : vms) {
int minLoad = hosts.poll();
hosts.offer(minLoad + vm);
}
int maxLoad = 0;
while (!hosts.isEmpty()) {
maxLoad = Math.max(maxLoad, hosts.poll());
}
return maxLoad;
}

Time Complexity: O(n log k)


Practice VMware coding questions regularly!