Walmart interview questions

676 questions from 76 interviews · updated from reports 2014-2025

Practise Walmart-style

About

Walmart is a retail company that runs stores, wholesale clubs, and online shopping platforms selling groceries, household goods, apparel, and other products. In India, its technology teams hire software engineers, SDE-2 candidates, and software engineering interns for e-commerce, data, and platform work.

The roles that come up most are Software Engineer, SDE-2 and Software Engineering Intern. This covers 76 candidate interviews reported from 2014 to 2025. The largest group sat it at entry level (28 of 76 that recorded a level), with 19 internship interviews alongside. Among the 48 that recorded either route, arrivals split between campus drives (27, 56%) and off-campus applications (21, 44%). Most questions fall under CS fundamentals and DSA.

Category
Difficulty
Round

Interview questions

Q. Print the bottom view of a binary tree.

asked 3xmediumTreesTechnical2015-2020

Ans. Use level order traversal with a horizontal distance for each node, and keep the latest node seen at each distance. Start root at distance 0, left child at -1, right child at +1. A queue stores nodes with distances. After traversal, print map values from smallest to largest distance. Time is O(n log n).

Q. Generate all permutations of a given string.

asked 3xmediumBacktrackingTechnical2020

Ans. Use backtracking to build permutations one character at a time until the current string has the same length as the input. Keep a used boolean array to mark chosen characters, or swap characters in place. The key detail is duplicates: sort first and skip repeated unused choices. Time complexity is O(n! × n).

Q. Perform spiral order traversal of a binary tree.

asked 3xmediumTreesTechnical2017-2020

Ans. Use level order traversal with a queue, but alternate the direction of output at each level. Process one level at a time, collect its nodes in a temporary list, reverse or insert based on the current direction, then toggle the direction. This takes O(n) time and O(w) space, where w is tree width.

Q. Detect a loop in a linked list.

asked 3xeasyLinked listsTechnical2020-2021

Ans. Use Floyd’s cycle detection with two pointers, slow and fast, starting at the head. Move slow one node at a time and fast two nodes at a time. If they ever meet, there is a loop. If fast reaches null, there is no loop. This runs in O(n) time and O(1) space.

Q. Explain the difference between '==' operator and '.equals()' method in Java.

asked 3xeasyOOPTechnical2024

Ans. In Java, == compares primitive values, but for objects it compares references, meaning whether both variables point to the same object. .equals() compares object contents if the class overrides it, such as String comparing characters. If not overridden, .equals() behaves like ==. Calling .equals() on null causes NullPointerException.

Q. Explain garbage collection in Java.

asked 2xmediumOOPTechnical2020

Ans. Garbage collection in Java is automatic memory management that finds objects no longer reachable by the program and reclaims their heap memory. The key point is reachability from roots such as stack variables, static fields and active threads. It reduces manual memory errors, but collection timing is not deterministic and may briefly pause execution.

Q. Write an SQL query for a given table.

asked 2xmediumSQLTechnical2020

Ans. Use a SELECT query that names the required columns, reads from the given table, filters rows with WHERE, groups with GROUP BY if aggregates are needed, filters groups with HAVING, and sorts with ORDER BY. The key detail is to match the query to the required output, especially joins, aggregation, and duplicate handling.

Q. Explain the memory layout of a C program.

asked 2xmediumOperating systemsTechnical2020

Ans. C++ program memory is commonly divided into code, static data, heap and stack areas. Code stores instructions, static data stores globals and static variables, including zero-initialised data. The stack holds function calls and local automatic variables. The heap holds dynamically allocated objects. The key detail is lifetime: stack objects end automatically, heap objects must be managed.

Q. Reverse a linked list in groups of size k

asked 2xmediumLinked listsTechnical2017-2021

Ans. Reverse each block of k nodes by rewiring next pointers, then connect the previous block’s tail to the new head of the reversed block. Use three pointers to reverse a block in place, and first check that k nodes remain if partial groups should stay unchanged. Time complexity is O(n), space complexity is O(1).

Q. Explain the internal working of HashMap in Java

asked 2xmediumData structuresTechnical2024

Ans. A HashMap stores key value pairs in an internal array of buckets, using the key’s hashCode to choose a bucket index. If multiple keys land in the same bucket, it compares keys with equals and stores collisions in a linked list or, after enough collisions, a tree. Resizing happens when the load factor threshold is crossed.

Q. Generate all possible permutations of a string.

asked 2xmediumBacktrackingTechnical2020

Ans. Use backtracking to build permutations by choosing each unused character for the current position until the string length is reached. Keep a current path, a boolean used array, and a result list. The key detail is to mark a character as used, recurse, then unmark it. Time complexity is O(n × n!), with O(n) recursion depth.

Q. What happens when you type a URL in your browser?

asked 2xmediumNetworkingTechnical2020

Ans. The browser resolves the URL to an IP address, opens a connection to the server, sends an HTTP request, receives a response, and renders the page. The key detail is DNS resolution happens first, followed by TCP and usually TLS setup, then HTML parsing, resource fetching, CSS layout, JavaScript execution, and painting to the screen.

Q. Count the number of inversions in an array in less than O(n^2) time complexity.

asked 2xmediumArraysOnline test2017

Ans. Use a modified merge sort to count inversions in O(n log n) time. While merging two sorted halves, if an element from the right half is smaller than the current element from the left half, it forms inversions with all remaining elements in the left half. Add that count during merge.

Q. Check whether two strings are equivalent when one is an abbreviation of the other (case-insensitive), e.g., Internationalization and I18n.

asked 2xmediumStringsTechnical2020

Ans. Use two pointers, comparing characters case-insensitively and treating digits in the abbreviation as a number of characters to skip in the full string. Parse consecutive digits into one integer, advance the full-string pointer by that amount, and continue matching. No extra data structure is needed. Time complexity is O(n).

Q. Write an SQL query to transpose a matrix.

asked 2xhardSQLTechnical2020

Ans. Use conditional aggregation to pivot rows into columns, grouping by the original column index and selecting each original row index with a CASE expression. If the matrix is stored as triples row, column, value, transposition is just swapping row and column in the result. It scans the matrix once, so time complexity is O(nm).

Q. Find the maximum sum submatrix in a given matrix.

asked 2xhardArraysTechnical2020

Ans. Use 2D Kadane’s algorithm: fix two column boundaries, compress the rows between them into a temporary 1D array of row sums, then run Kadane’s algorithm to find the best contiguous set of rows. Track the best sum and coordinates. This takes O(C²R) time, or O(min(R,C)² max(R,C)) if oriented optimally, and O(R) space.

Q. Reverse a linked list

asked 2xeasyLinked listsTechnical2015-2019

Ans. Reverse a linked list by iterating through it and changing each node’s next pointer to point to the previous node. Keep three pointers: previous, current, and next, so you do not lose the rest of the list. At the end, previous is the new head. Time complexity is O(n), space complexity is O(1).

Q. Explain cross join in DBMS.

asked 2xeasyDBMSTechnical2020

Ans. A cross join returns the Cartesian product of two tables, pairing every row from the first table with every row from the second. If table A has m rows and table B has n rows, the result has m × n rows. It is useful but can grow very large quickly.

Q. Reverse a singly linked list.

asked 2xeasyLinked listsTechnical2019-2024

Ans. Reverse it by walking through the list once and redirecting each node’s next pointer to the previous node. Keep three pointers: previous, current, and next, so you do not lose the remaining list. At the end, previous becomes the new head. Time is O(n), space is O(1).

Q. Reverse the words in a given string.

asked 2xeasyStringsTechnical2017-2024

Ans. Split the string into words, then output the words in reverse order joined by a single space. The key detail is to ignore leading, trailing, and repeated spaces while collecting words. Use an array or list to store words. This takes O(n) time and O(n) extra space.

Q. What is the relational model in DBMS?

asked 2xeasyDBMSTechnical2020

Ans. The relational model in DBMS is a way of organising data as relations, usually represented as tables with rows and columns. Each row is a tuple, each column is an attribute, and relationships are handled using keys. Its key strength is data independence with a strong mathematical basis for querying and integrity.

Q. Explain the difference between JDK and JRE.

asked 2xeasyJavaTechnical2024

Ans. JDK is the Java Development Kit for building Java applications, while JRE is the Java Runtime Environment for running them. The JDK includes the JRE plus development tools such as the compiler, debugger, and packaging tools. If you only need to run a Java program, the JRE is enough.

Q. Check whether a linked list is a palindrome.

asked 2xeasyLinked listsTechnical2020

Ans. Use two pointers to find the middle, reverse the second half of the linked list, then compare it node by node with the first half. The key detail is restoring the reversed half afterwards if the list must remain unchanged. This uses constant extra space and takes O(n) time.

Q. What are the differences between C and Java?

asked 2xeasyOOPTechnical2014-2021

Ans. C is a procedural, compiled, low-level language with manual memory management, while Java is object-oriented, runs on a virtual machine, and uses garbage collection. C gives more control over memory and hardware, so it is common in systems programming. Java favours portability, safety, and large application development through its standard runtime.

Q. Check whether two given strings are anagrams.

asked 2xeasyStringsTechnical2024

Ans. Check they have the same length, then count character frequencies in the first string and subtract using the second string. Use a hash map or fixed-size array if the character set is known. If any count becomes negative or non-zero at the end, they are not anagrams. Time complexity is O(n), space is O(k).

Q. Search for a given key in a Binary Search Tree.

asked 2xeasyTreesTechnical2020

Ans. Search a Binary Search Tree by comparing the key with the current node and moving left if it is smaller, right if it is larger, and stopping when it matches or reaches null. This uses the BST ordering property. Time complexity is O(h), where h is tree height, O(log n) if balanced and O(n) if skewed.

Q. What are checked and unchecked exceptions in Java?

asked 2xeasyOOPTechnical2020

Ans. Checked exceptions are exceptions the compiler forces you to handle with try-catch or declare with throws, such as IOException. Unchecked exceptions are not enforced at compile time and usually represent programming errors, such as NullPointerException or IllegalArgumentException. Checked exceptions extend Exception, while unchecked exceptions typically extend RuntimeException.

Q. Print Pascal’s Triangle for a given number of rows.

asked 2xeasyArraysTechnical2021-2024

Ans. Generate each row from the previous row and print it until the required number of rows is reached. Use a list or array for the current row, where the first and last values are 1 and each middle value is the sum of two values above it. Time complexity is O(n²), space is O(n).

Q. What is the difference between a process and a thread?

asked 2xeasyOperating systemsTechnical2020

Ans. A process is an independent running program with its own memory space, while a thread is a smaller unit of execution within a process that shares that process’s memory. Processes are more isolated and cost more to create or switch between. Threads are lighter, but shared memory makes synchronisation and race conditions important.

Q. Define Object-Oriented Programming System (OOPS) concepts.

asked 2xeasyOOPTechnical2020

Ans. Object-Oriented Programming System concepts are principles for designing software around objects that combine data and behaviour. The main concepts are class, object, encapsulation, abstraction, inheritance and polymorphism. The key idea is to model real entities, hide internal details, reuse code through hierarchy and allow the same interface to have different implementations.

Q. Find the maximum repeating (maximum occurring) number in an array

asked 2xeasyArraysTechnical2021

Ans. Count each value’s frequency and return the value with the highest count. Use a hash map from number to count, update it while scanning the array, and track the current best number and frequency. This takes O(n) time and O(n) extra space in the worst case.

Q. Explain the difference between Call by Value and Call by Reference

asked 2xeasyOOPTechnical2020-2024

Ans. Call by value passes a copy of the argument, while call by reference passes access to the original variable. With call by value, changes inside the function do not affect the caller’s variable. With call by reference, changes inside the function can affect the original value, because both refer to the same storage.

Q. How do you insert and delete an element from a doubly linked list?

asked 2xeasyLinked listsTechnical2024

Ans. Insert by creating or choosing a node, setting its prev and next links to the neighbouring nodes, then updating those neighbours to point back to it. Delete by linking the node’s prev directly to its next, then clearing or discarding the node. Handle head and tail cases carefully. Given the node, both operations are O(1).

Q. Write a program to find all prime numbers between two given numbers.

asked 2xeasyMathTechnical2020

Ans. Use the Sieve of Eratosthenes up to the larger number, then print the values marked prime within the given range. Store primality in a boolean array, initially true except 0 and 1, and mark multiples of each prime as false. Time complexity is O(n log log n), with O(n) space.

Q. Detect a loop in a linked list and return the starting node of the loop

asked 2xeasyLinked listsTechnical2015-2020

Ans. Use Floyd’s slow and fast pointer method to detect the loop, then find its starting node. Move slow by one and fast by two; if they meet, reset one pointer to the head and move both one step at a time. Their next meeting point is the loop start. Time is O(n), space is O(1).

Q. Find the length of the subarray with the longest consecutive 1s in a binary array

asked 2xeasyArraysTechnical2024

Ans. Scan the array once, counting the current run of consecutive 1s and keeping the maximum run seen so far. When you see a 1, increment the current count; when you see a 0, reset it to zero. No extra data structure is needed. Time complexity is O(n), space complexity is O(1).

Q. Find the second largest element in an array in a single iteration without using extra space

asked 2xeasyArraysTechnical2024

Ans. Keep two variables, largest and secondLargest, and scan the array once. For each value, update largest if it is bigger, moving the old largest to secondLargest; otherwise update secondLargest if the value is between them. This uses constant extra space and runs in O(n) time. Handle arrays with fewer than two distinct values separately.

Q. Write code and explain inorder, preorder, and postorder traversals of a Binary Search Tree.

asked 2xeasyTreesTechnical2020

Ans. Inorder visits left, root, right; preorder visits root, left, right; postorder visits left, right, root. Implement each with recursion, or iteratively using a stack. For a Binary Search Tree, inorder returns keys in sorted order. All traversals visit every node once, so time is O(n) and space is O(h).

Q. In C++, if a Derived class inherits from a Base class, and an object of Derived is destroyed, which destructor is called first?

asked 2xeasyOOPTechnical2020

Ans. The Derived destructor is called first, then the Base destructor is called. Destruction happens in the reverse order of construction, so the most derived part is cleaned up before its base parts. If a Derived object may be deleted through a Base pointer, the Base destructor should be virtual.

Q. Flatten a linked list

asked 1xmediumLinked listsTechnical2021

Ans. Flatten it by repeatedly merging each child or bottom list into one main list, preserving the required order. For the common sorted bottom-pointer version, use the merge step from merge sort on two lists at a time, recursively or iteratively. This uses constant extra space apart from recursion and runs in O(N) total node processing per merge chain.

Q. Clone an undirected graph.

asked 1xmediumGraphsTechnical2019

Ans. Clone it with a graph traversal, creating one new node for each original node and copying all neighbour links. Use a hash map from original node to cloned node to avoid duplicate copies and handle cycles. BFS with a queue or DFS with recursion works. Time is O(V + E), space is O(V).

Q. Design an elevator system.

asked 1xmediumObject oriented designTechnical2020

Ans. Design it as controllers managing elevators, requests and scheduling, with each elevator tracking current floor, direction, state, capacity and assigned stops. The key detail is the dispatch algorithm: group requests by direction and allocate the nearest suitable elevator, while each elevator serves stops in order before reversing, minimising wait and travel time.

Q. Build a tree data structure

asked 1xmediumTreesTechnical2020

Ans. Use a Node object containing a value and references to its children, with a Tree object holding the root. For a binary tree, each node has left and right references. Insert by traversing from the root to the correct position. Search, insert and delete take O(h), where h is tree height.

Q. Design a URL Shortener service

asked 1xmediumScalable systemsSystem design2023

Ans. Build a service that maps a short code to a long URL, with APIs to create, redirect, and optionally expire links. Store mappings in a durable key value store, generate unique codes using base62 over an ID or random token, cache hot redirects, and use 301 or 302 depending on analytics needs.

Q. Solve problems on Binary Trees

asked 1xmediumTreesTechnical2023

Ans. Most binary tree problems are solved with recursion or traversal using a stack or queue. Use DFS for height, diameter, path sum, lowest common ancestor and tree construction; use BFS for level order and shortest level-based questions. Track the needed state carefully. Time is usually O(n), with O(h) or O(n) space.

Q. Swap K nodes in a linked list.

asked 1xmediumLinked listsTechnical2021

Ans. Find the kth node from the start and the kth node from the end, then swap their links without changing node values. Use one pass to locate length and kth-from-start, or two pointers to find kth-from-end. Carefully handle head changes, same node, and adjacent nodes. Time is O(n), space is O(1).

Q. Design a URL shortening system.

asked 1xmediumScalable systemsSystem design2019

Ans. Build a service that maps a short, unique code to a long URL, with APIs to create a short link and redirect users. Store code, long URL, owner, expiry and metadata in a highly available key value store. Generate codes using base62 over unique IDs, cache hot redirects, and track analytics asynchronously.

Q. Explain file operations in C++.

asked 1xmediumOOPManagerial2021

Ans. File operations in C++ are done mainly through the fstream library, using ifstream for reading, ofstream for writing, and fstream for both. A file is opened with a path and mode, data is read or written using stream operators or functions, and errors should be checked before closing the file.

Q. How is memory allocated in C++?

asked 1xmediumOperating systemsTechnical2020

Ans. C++ allocates memory in automatic storage, static storage, thread storage, or dynamic storage. Local variables usually live on the stack, globals and statics live for the program or thread lifetime, and objects created with new are allocated on the heap. The key detail is ownership: prefer RAII and smart pointers to manage dynamic memory safely.

Q. How is data stored inside a DBMS?

asked 1xmediumDBMSTechnical2020

Ans. A DBMS stores data as files on persistent storage, organised into fixed-size pages or blocks that contain records for tables and indexes. The key detail is that it reads and writes whole pages, not individual rows. A buffer manager caches pages in memory, while indexes such as B+ trees help find records efficiently.

Q. Spiral traversal of a binary tree

asked 1xmediumTreesTechnical2019

Ans. Spiral traversal of a binary tree prints nodes level by level, alternating direction at each level, such as left to right then right to left. Use a queue for level order traversal and reverse the collected values on alternate levels, or use two stacks. Each node is processed once, so time is O(n) and space is O(w).

Q. Why are there no pointers in Java?

asked 1xmediumOOPTechnical2024

Ans. Java has no explicit pointers because it is designed to be safer, portable, and easier to manage than languages like C or C++. Objects are accessed through references, but programmers cannot see memory addresses or do pointer arithmetic. This prevents many memory errors and lets the garbage collector manage object lifetime.

Q. Three bulbs and three switches puzzle.

asked 1xmediumLogical reasoningTechnical2021

Ans. Turn switch 1 on for several minutes, then turn it off. Turn switch 2 on and enter the room. The bulb that is lit is controlled by switch 2. Of the two unlit bulbs, the warm one is controlled by switch 1, because it was on earlier. The cold one is controlled by switch 3.

Q. Solve the puzzle: ABCD × 4 = DCBA, where ABCD is a 4-digit number.

asked 1xmediumLogical reasoningTechnical2020

Ans. 2178 is the number. Work from right to left with carries. 4D ends in A, and the leftmost digit gives D = 4A plus a carry, forcing A = 2 and D = 8. Then 4C + 3 ends in B, while 4B plus the next carry gives C. This yields B = 1 and C = 7.

Q. Describe one of the toughest decisions you have taken in your life.

asked 1xmediumDecision makingHR2020

Ans. Choose a real decision with clear stakes, not a dramatic personal story chosen only for emotion. Explain the context briefly, the options you weighed, who was affected, and the trade-off you accepted. Emphasise sound judgement, ownership, values, and learning. Interviewers listen for maturity, self-awareness, and evidence you can decide under pressure.

Q. Measure exactly 6 liters of water using 4-liter and 9-liter buckets.

asked 1xmediumLogical reasoningTechnical2024

Ans. Fill the 9-litre bucket and pour into the 4-litre bucket twice, emptying the 4-litre bucket each time. This leaves 1 litre in the 9-litre bucket. Pour that 1 litre into the 4-litre bucket. Fill the 9-litre bucket again, then pour 3 litres into the 4-litre bucket, leaving exactly 6 litres.

Q. How would you resolve conflicts when teammates do not agree on something?

asked 1xmediumConflict resolutionHR2021

Ans. Pick a real work disagreement where the outcome mattered but emotions stayed manageable. Emphasise listening first, clarifying facts, separating opinions from evidence, and aligning on the shared goal. Show that you involve the right people, avoid blame, and drive towards a decision. Interviewers listen for maturity, fairness, and collaboration under pressure.

Q. How would you react if you were converted from intern to full-time but a close friend working with you was rejected?

asked 1xmediumConflict resolutionHR2020

Ans. Choose a real example involving mixed outcomes, not office gossip. Emphasise gratitude and professionalism, while showing empathy for your friend without criticising the company. Say you would support them privately, respect confidentiality, and stay focused in the role. Interviewers listen for maturity, discretion, loyalty to team standards, and emotional intelligence.

Q. Solve aptitude questions based on percentage, profit and loss, and probability.

asked 1xeasyProbabilityTechnical2019

Ans. Convert all quantities to clear bases first: use 100 as the base for percentages, cost price for profit or loss, and total possible outcomes for probability. Apply the standard formula, then simplify carefully. For combined changes, multiply factors such as 1.20 and 0.90 rather than adding percentages directly.

Q. Given a range of integers, find all prime numbers in that range and determine which digit occurs the maximum number of times across all those prime numbers.

asked 1xeasyLogical reasoningOnline test2015

Ans. Use the Sieve of Eratosthenes to generate all primes in the given range efficiently. Then convert each prime to digits and maintain a frequency count for digits 0 to 9. After processing all primes, scan the counts and choose the digit with the highest frequency, applying any stated tie rule.

Showing 60 of 676 questions. Ranked by how often the same question came back across interviews.

Practise a Walmart-style interview

A spoken interview built from these questions, scored when you finish; the feedback is yours.

Start practising

When you are ready, record The One: a single interview hiring teams watch, so you stop repeating first rounds.

Common questions

What questions does Walmart ask?

Candidate interviews most often cover CS fundamentals (46%) and DSA (43%).

How many rounds does Walmart interview have?

Candidate interviews show an average of 3.8 rounds per experience, with a typical sequence of Online test → Technical → Technical → Managerial → HR. Individual interview paths can vary.

Is the Walmart interview hard?

Among questions with a recorded difficulty, the mix is easy 37%, medium 55%, hard 8%.