Skip to content

Walmart Coding Questions - DSA Problems & Solutions

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

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

Walmart OA Coding Section:

  • Problems: 2-3 coding problems
  • Time: 90 minutes
  • Languages: Java, Python
Q1: Optimize supply chain routes to minimize delivery time.

Solution (Java):

public int minDeliveryTime(int[][] graph, int source, int destination) {
int n = graph.length;
int[] dist = new int[n];
Arrays.fill(dist, Integer.MAX_VALUE);
dist[source] = 0;
PriorityQueue<int[]> pq = new PriorityQueue<>((a, b) -> a[1] - b[1]);
pq.offer(new int[]{source, 0});
while (!pq.isEmpty()) {
int[] curr = pq.poll();
int node = curr[0], time = curr[1];
if (node == destination) return time;
for (int i = 0; i < n; i++) {
if (graph[node][i] > 0) {
int newTime = time + graph[node][i];
if (newTime < dist[i]) {
dist[i] = newTime;
pq.offer(new int[]{i, newTime});
}
}
}
}
return -1;
}

Time Complexity: O((V + E) log V)


Practice Walmart coding questions regularly!