🛒 Walmart DSA Interview Questions (with Links + Sources)
- Posted
- 30 Aug 2025
Summary
I've compiled a comprehensive list of Data Structures & Algorithms (DSA) interview questions that have been asked at Walmart, sourcing them from various interview experiences. This collection includes direct LeetCode links and aims to provide valuable insight into the technical problem-solving skills expected by the company.
How it went
I've meticulously collected and organized these interview questions to offer a detailed overview of what to expect in Walmart's technical rounds. This compilation aggregates problems reported by candidates across a spectrum of roles and experience levels, including SDE III, Senior SWE, and fresher positions. Some of the sources even specify locations like Bengaluru and recent interview dates up to December 2024. Each question is accompanied by its direct LeetCode link, facilitating easy access to the problem statement for focused practice. While the specific outcomes for all individual aggregated experiences are not universally detailed, one notable source explicitly mentions an offer, highlighting the relevance of these problems in successful interview journeys.
Questions asked (17)
- 01
Move Zeroes
Data Structures & Algorithms · Easy
Open the problemGiven an integer array
nums, move all0's to the end of it while maintaining the relative order of the non-zero elements. Note that you must do this in-place without making a copy of the array. - 02
Maximum Subarray
Data Structures & Algorithms · Medium
Open the problemGiven an integer array
nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. - 03
House Robber II
Data Structures & Algorithms · Medium
Open the problemYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have a security system connected, and it will automatically contact the police if two adjacent houses were broken into on the same night.
Given an integer array
numsrepresenting the amount of money of each house, return the maximum amount of money you can rob tonight without alerting the police. - 04
Subarray Sum Equals K
Data Structures & Algorithms · Medium
Open the problemGiven an array of integers
numsand an integerk, return the total number of continuous subarrays whose sum equals tok. - 05
LFU Cache
Data Structures & Algorithms · Hard
Open the problemDesign and implement a data structure for a Least Frequently Used (LFU) cache. Implement the
LFUCacheclass:LFUCache(int capacity)Initializes the object with thecapacityof the data structure.int get(int key)Gets the value of thekeyif thekeyexists in the cache, otherwise returns-1.void put(int key, int value)Update the value of thekeyif present, or inserts thekeyif not already present. When the cache reaches itscapacity, it should invalidate the least frequently used item before inserting a new item. For this problem, when there is a tie (a key has the same frequency as another key), the least recently used key would be invalidated.
- 06
LRU Cache
Data Structures & Algorithms · Medium
Open the problemDesign a data structure that follows the constraints of a Least Recently Used (LRU) cache.
Implement the
LRUCacheclass:LRUCache(int capacity)Initializes the LRU cache with the given positivecapacity.int get(int key)Returns the value of thekeyif thekeyexists, otherwise returns-1.void put(int key, int value)Update the value of thekeyif thekeyexists, Otherwise, add thekey-valuepair to the cache. If the number of keys exceeds thecapacityfrom this operation, evict the least recently used key.
- 07
Degree of an Array
Data Structures & Algorithms · Easy
Open the problemGiven a non-empty array of non-negative integers
nums, the degree of this array is defined as the maximum frequency of any one of its elements. Your task is to find the smallest possible length of a (contiguous) subarray ofnumsthat has the same degree asnums. - 08
Reformat Date
Data Structures & Algorithms · Easy
Open the problemGiven a date string in the form
"Day Month Year", where:Dayis an integer in the range[1, 31]with an ordinal suffix.Monthis a three-letter abbreviation of a month.Yearis an integer in the range[1900, 2100].
Return the date in the format
"YYYY-MM-DD". - 09
Two Sum IV - Input is a BST
Data Structures & Algorithms · Easy
Open the problemGiven the
rootof a Binary Search Tree and an integerk, returntrueif there exist two distinct nodes in the tree whose values sum up tok, orfalseotherwise. - 10
Gas Station
Data Structures & Algorithms · Medium
Open the problemThere are
ngas stations along a circular route, where the amount of gas at theithstation isgas[i]. You have a car with an unlimited tank and it costscost[i]of gas to travel from theithstation to the(i + 1)thstation. You begin the journey with an empty tank at one of the gas stations.Given two integer arrays
gasandcost, return the starting gas station's index if you can travel around the circuit once in the clockwise direction, otherwise return-1. If there exists a solution, it is guaranteed to be unique. - 11
Jump Game
Data Structures & Algorithms · Medium
Open the problemYou are given an integer array
nums. You are initially positioned at the array's first index, and each element innumsrepresents your maximum jump length at that position.Return
trueif you can reach the last index, orfalseotherwise. - 12
Subsets II
Data Structures & Algorithms · Medium
Open the problemGiven an integer array
numsthat may contain duplicates, return all possible subsets (the power set).The solution set must not contain duplicate subsets. Return the solution in any order.
- 13
Longest Palindromic Substring
Data Structures & Algorithms · Medium
Open the problemGiven a string
s, return the longest palindromic substring ins. - 14
Reverse Linked List
Data Structures & Algorithms · Easy
Open the problemGiven the
headof a singly linked list, reverse the list, and return the reversed list. - 15
Minimum Number of Days to Make m Bouquets
Data Structures & Algorithms · Medium
Open the problemYou are given an integer array
bloomDay, an integermand an integerk.You want to make
mbouquets. To make a bouquet, you needkadjacent flowers from the garden. The garden hasnflowers, theithflower will bloom in thebloomDay[i]and then can be used in exactly one bouquet.Return the minimum number of days you need to wait to be able to make
mbouquets. If it is impossible to makembouquets, return-1. - 16
Best Time to Buy and Sell Stock with Cooldown
Data Structures & Algorithms · Medium
Open the problemYou are given an array
priceswhereprices[i]is the price of a given stock on theithday.Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times) with the following restrictions:
- You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).
- After you sell your stock, you cannot buy stock on the next day (i.e., cooldown period is one day).
- 17
Trapping Rain Water
Data Structures & Algorithms · Hard
Open the problemGiven
nnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.