Problem database last updated: June 20, 2025

WWalmart Labs logo

Walmart Labs Coding Interview Questions

95 problems · 18 Easy, 62 Medium, 15 Hard · Ranked #18 of 458

Difficulty breakdown

18 Easy

19% · avg 23%

62 Medium

65% · avg 59%

15 Hard

16% · avg 18%

Top topics

array
50.5%
string
26.3%
hash-table
21.1%
dynamic-programming
21.1%
two-pointers
18.9%
sorting
14.7%

Interview profile

Based on 95 reported problems, Walmart Labs interviews are in line with industry averages - 16% Hard vs 18% overall. The majority (65%) of questions are Medium difficulty, which is typical for companies that want to see solid fundamentals without excessive trick questions.

Compared to the industry average, Walmart Labs puts unusual emphasis on merge-sort (2.1% of problems, 2.9x the industry average), queue (3.2% of problems, 2.2x the industry average), quickselect (2.1% of problems, 2x the industry average). If you're short on time, these are the categories to double down on.

The most common topics are array (50.5%), string (26.3%), hash-table (21.1%), dynamic-programming (21.1%). Problems below are sorted by frequency, the ones at the top are asked most often.

All 95 problems

Longest Substring Without Repeating Characters

Solve

Given a string s, find the length of the longest substring without duplicate characters.

MediumVery Likely
hash-tablestringsliding-window

LRU Cache

Solve

Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.

MediumVery Likely
hash-tablelinked-listdesign

Valid Parentheses

Solve

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

EasyVery Likely
stringstack

Trapping Rain Water

Solve

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.

HardVery Likely
arraytwo-pointersdynamic-programming

Merge Intervals

Solve

Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cove...

MediumVery Likely
arraysorting

Best Time to Buy and Sell Stock

Solve

You are given an array prices where prices[i] is the price of a given stock on the ith day.

EasyVery Likely
arraydynamic-programming

Longest Palindromic Substring

Solve

Given a string s, return the longest palindromic substring in s.

MediumVery Likely
two-pointersstringdynamic-programming

Two Sum

Solve

Given an array of integers nums and an integer target, return the indices of the two numbers that add up to target.

EasyVery Likely
arrayhash-map

Divide Intervals Into Minimum Number of Groups

Solve

You are given a 2D integer array intervals where intervals[i] = [lefti, righti] represents the inclusive interval [lefti, righti].

MediumVery Likely
arraytwo-pointersgreedy

Word Break

Solve

Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words.

MediumVery Likely
arrayhash-tablestring

Generate Parentheses

Solve

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

MediumVery Likely
stringdynamic-programmingbacktracking

Number of Ways to Separate Numbers

Solve

You wrote down many positive integers in a string called num. However, you realized that you forgot to add commas to seperate the different numbers. You remembe...

HardVery Likely
stringdynamic-programmingsuffix-array

Minimum Operations to Make Array Equal II

Solve

You are given two integer arrays nums1 and nums2 of equal length n and an integer k. You can perform the following operation on nums1:

MediumVery Likely
arraymathgreedy

Count Good Triplets in an Array

Solve

You are given two 0-indexed arrays nums1 and nums2 of length n, both of which are permutations of [0, 1, ..., n - 1].

HardVery Likely
arraybinary-searchdivide-and-conquer

Minimum Number of Operations to Make Arrays Similar

Solve

You are given two positive integer arrays nums and target, of the same length.

HardVery Likely
arraygreedysorting

Maximum Number of Tasks You Can Assign

Solve

You have n tasks and m workers. Each task has a strength requirement stored in a 0-indexed integer array tasks, with the ith task requiring tasks[i] strength to...

HardVery Likely
arraytwo-pointersbinary-search

Middle of the Linked List

Solve

Given the head of a singly linked list, return the middle node of the linked list.

EasyVery Likely
linked-listtwo-pointers

Spiral Matrix

Solve

Given an m x n matrix, return all elements of the matrix in spiral order.

MediumLikely
arraymatrixsimulation

Search in Rotated Sorted Array

Solve

There is an integer array nums sorted in ascending order (with distinct values).

MediumLikely
arraybinary-search

Group Anagrams

Solve

Given an array of strings strs, group the anagrams together. You can return the answer in any order.

MediumLikely
arrayhash-tablestring

Number of Islands

Solve

Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands.

MediumLikely
arraydepth-first-searchbreadth-first-search

Kth Largest Element in an Array

Solve

Given an integer array nums and an integer k, return the kth largest element in the array.

MediumLikely
arraydivide-and-conquersorting

Longest Consecutive Sequence

Solve

Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.

MediumLikely
arrayhash-tableunion-find

Sort Colors

Solve

Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order...

MediumLikely
arraytwo-pointerssorting

Combination Sum

Solve

Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum...

MediumLikely
arraybacktracking

Coin Change

Solve

You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.

MediumLikely
arraydynamic-programmingbreadth-first-search

Valid Sudoku

Solve

Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:

MediumLikely
arrayhash-tablematrix

Binary Tree Zigzag Level Order Traversal

Solve

Given the root of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from left to right, then right to left for the next level...

MediumLikely
treebreadth-first-searchbinary-tree

Move Zeroes

Solve

Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.

EasyLikely
arraytwo-pointers

Degree of an Array

Solve

Given 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.

EasyLikely
arrayhash-table

3Sum

Solve

Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.

MediumLikely
arraytwo-pointerssorting

Rotate Array

Solve

Given an integer array nums, rotate the array to the right by k steps, where k is non-negative.

MediumLikely
arraymathtwo-pointers

Pow(x, n)

Solve

Implement pow(x, n), which calculates x raised to the power n (i.e., xn).

MediumLikely
mathrecursion

Median of Two Sorted Arrays

Solve

Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.

HardLikely
arraybinary-searchdivide-and-conquer

Top K Frequent Elements

Solve

Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.

MediumLikely
arrayhash-tabledivide-and-conquer

All Nodes Distance K in Binary Tree

Solve

Given the root of a binary tree, the value of a target node target, and an integer k, return an array of the values of all nodes that have a distance k from the...

MediumLikely
hash-tabletreedepth-first-search

House Robber

Solve

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from rob...

MediumLikely
arraydynamic-programming

Daily Temperatures

Solve

Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait aft...

MediumLikely
arraystackmonotonic-stack

LFU Cache

Solve

Design and implement a data structure for a Least Frequently Used (LFU) cache.

HardLikely
hash-tablelinked-listdesign

Flatten Nested List Iterator

Solve

You are given a nested list of integers nestedList. Each element is either an integer or a list whose elements may also be integers or other lists. Implement an...

MediumLikely
stacktreedepth-first-search

Longest Common Prefix

Solve

Write a function to find the longest common prefix string amongst an array of strings.

EasyLikely
arraystringtrie

Merge k Sorted Lists

Solve

You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.

HardLikely
linked-listdivide-and-conquerheap-priority-queue

Copy List with Random Pointer

Solve

A linked list of length n is given such that each node contains an additional random pointer, which could point to any node in the list, or null.

MediumLikely
hash-tablelinked-list

Reverse Nodes in k-Group

Solve

Given the head of a linked list, reverse the nodes of the list k at a time, and return the modified list.

HardLikely
linked-listrecursion

Search a 2D Matrix

Solve

You are given an m x n integer matrix matrix with the following two properties:

MediumLikely
arraybinary-searchmatrix

Add Binary

Solve

Given two binary strings a and b, return their sum as a binary string.

EasyLikely
mathstringbit-manipulation

First Missing Positive

Solve

Given an unsorted integer array nums. Return the smallest positive integer that is not present in nums.

HardLikely
arrayhash-table

Word Search

Solve

Given an m x n grid of characters board and a string word, return true if word exists in the grid.

MediumLikely
arraystringbacktracking

Squares of a Sorted Array

Solve

Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.

EasyLikely
arraytwo-pointerssorting

Minimum Window Substring

Solve

Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicates) is inc...

HardLikely
hash-tablestringsliding-window

Maximum Subarray

Solve

Given an integer array nums, find the subarray with the largest sum, and return its sum.

MediumLikely
arraydivide-and-conquerdynamic-programming

Keys and Rooms

Solve

There are n rooms labeled from 0 to n - 1 and all the rooms are locked except for room 0. Your goal is to visit all the rooms. However, you cannot enter a locke...

MediumLikely
depth-first-searchbreadth-first-searchgraph

Course Schedule II

Solve

There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, b...

MediumLikely
depth-first-searchbreadth-first-searchgraph

Min Stack

Solve

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.

MediumLikely
stackdesign

Binary Tree Right Side View

Solve

Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.

MediumLikely
treedepth-first-searchbreadth-first-search

Course Schedule

Solve

There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, b...

MediumSometimes
depth-first-searchbreadth-first-searchgraph

Merge Two Sorted Lists

Solve

You are given the heads of two sorted linked lists list1 and list2.

EasySometimes
linked-listrecursion

Best Time to Buy and Sell Stock II

Solve

You are given an integer array prices where prices[i] is the price of a given stock on the ith day.

MediumSometimes
arraydynamic-programminggreedy

Populating Next Right Pointers in Each Node

Solve

You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:

MediumSometimes
linked-listtreedepth-first-search

Container With Most Water

Solve

You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]).

MediumSometimes
arraytwo-pointersgreedy

Subarray Sum Equals K

Solve

Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k.

MediumSometimes
arrayhash-tableprefix-sum

Jump Game II

Solve

You are given a 0-indexed array of integers nums of length n. You are initially positioned at index 0.

MediumSometimes
arraydynamic-programminggreedy

Partition Equal Subset Sum

Solve

Given an integer array nums, return true if you can partition the array into two subsets such that the sum of the elements in both subsets is equal or false oth...

MediumSometimes
arraydynamic-programming

Path Sum II

Solve

Given the root of a binary tree and an integer targetSum, return all root-to-leaf paths where the sum of the node values in the path equals targetSum. Each path...

MediumSometimes
backtrackingtreedepth-first-search

First Unique Character in a String

Solve

Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.

EasySometimes
hash-tablestringqueue

Max Consecutive Ones III

Solve

Given a binary array nums and an integer k, return the maximum number of consecutive 1's in the array if you can flip at most k 0's.

MediumSometimes
arraybinary-searchsliding-window

Wildcard Matching

Solve

Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '' where:

HardSometimes
stringdynamic-programminggreedy

Koko Eating Bananas

Solve

Koko loves to eat bananas. There are n piles of bananas, the ith pile has piles[i] bananas. The guards have gone and will come back in h hours.

MediumSometimes
arraybinary-search

Interleaving String

Solve

Given strings s1, s2, and s3, find whether s3 is formed by an interleaving of s1 and s2.

MediumSometimes
stringdynamic-programming

Flatten Deeply Nested Array

Solve

Given a multi-dimensional array arr and a depth n, return a flattened version of that array.

MediumSometimes

Decode String

Solve

Given an encoded string, return its decoded string.

MediumSometimes
stringstackrecursion

Second Highest Salary

Solve

Table: Employee

MediumSometimes
database

Largest Rectangle in Histogram

Solve

Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the his...

HardSometimes
arraystackmonotonic-stack

Decode Ways

Solve

You have intercepted a secret message encoded as a string of numbers. The message is decoded via the following mapping:

MediumSometimes
stringdynamic-programming

Count Primes

Solve

Given an integer n, return the number of prime numbers that are strictly less than n.

MediumSometimes
arraymathenumeration

Longest Palindrome

Solve

Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters.

EasySometimes
hash-tablestringgreedy

Maximal Square

Solve

Given an m x n binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.

MediumSometimes
arraydynamic-programmingmatrix

Add Two Numbers

Solve

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a sing...

MediumSometimes
linked-listmathrecursion

Binary Tree Maximum Path Sum

Solve

A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequ...

HardSometimes
dynamic-programmingtreedepth-first-search

Product of Array Except Self

Solve

Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].

MediumSometimes
arrayprefix-sum

Palindrome Number

Solve

Given an integer x, return true if x is a palindrome, and false otherwise.

EasySometimes
math

Boats to Save People

Solve

You are given an array people where people[i] is the weight of the ith person, and an infinite number of boats where each boat can carry a maximum weight of lim...

MediumSometimes
arraytwo-pointersgreedy

Valid Palindrome II

Solve

Given a string s, return true if the s can be palindrome after deleting at most one character from it.

EasySometimes
two-pointersstringgreedy

Linked List Cycle

Solve

Given head, the head of a linked list, determine if the linked list has a cycle in it.

EasySometimes
hash-tablelinked-listtwo-pointers

Reverse Words in a String III

Solve

Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.

EasySometimes
two-pointersstring

Valid Anagram

Solve

Given two strings s and t, return true if t is an anagram of s, and false otherwise.

EasySometimes
hash-tablestringsorting

Perfect Squares

Solve

Given an integer n, return the least number of perfect square numbers that sum to n.

MediumSometimes
mathdynamic-programmingbreadth-first-search

Populating Next Right Pointers in Each Node II

Solve

Given a binary tree

MediumSometimes
linked-listtreedepth-first-search

Reorganize String

Solve

Given a string s, rearrange the characters of s so that any two adjacent characters are not the same.

MediumSometimes
hash-tablestringgreedy

Fruit Into Baskets

Solve

You are visiting a farm that has a single row of fruit trees arranged from left to right. The trees are represented by an integer array fruits where fruits[i] i...

MediumSometimes
arrayhash-tablesliding-window

Palindrome Partitioning

Solve

Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s.

MediumSometimes
stringdynamic-programmingbacktracking

Maximum Number of Non-overlapping Palindrome Substrings

Solve

You are given a string s and a positive integer k.

HardSometimes
two-pointersstringdynamic-programming

Minimum Add to Make Parentheses Valid

Solve

A parentheses string is valid if and only if:

MediumSometimes
stringstackgreedy

Reverse Words in a String

Solve

Given an input string s, reverse the order of the words.

MediumSometimes
two-pointersstring

Merge Sorted Array

Solve

You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and num...

EasySometimes
arraytwo-pointerssorting

How often are these problems asked?

Frequency scores are based on crowdsourced interview reports. A higher score means the problem has been reported more often in recent Walmart Labs interviews.

Very Likely

75-100%

Likely

50-74%

Sometimes

25-49%

Rare

0-24%

Preparing for your Walmart Labs coding interview

Walmart Labs interviews focus heavily on array, string, hash-table problems. If you're short on time, these are the categories to prioritize. The problems on this page are sorted by frequency, so start from the top and work your way down.

Beyond solving problems, practice explaining your approach. Walmart Labs interviewers care about your thought process - how you break down a problem, consider edge cases, and evaluate tradeoffs between solutions. A clean O(n) solution you can explain clearly beats an O(log n) solution you can't articulate.

Looking for more companies? Browse all 458 companies in our directory, or sharpen your fundamentals with our free data structure visualizers and AI-powered DSA tutor.

Frequently Asked Questions

What coding problems does Walmart Labs ask in interviews?add

Walmart Labs has been reported to ask 95 distinct coding problems. The most common topics are array, string, hash-table. 18 are Easy difficulty, 62 are Medium, and 15 are Hard. Problems are sorted by frequency - the ones at the top are asked most often.

How hard are Walmart Labs coding interviews?add

Based on 95 reported problems, Walmart Labs interviews are in line with industry averages - 16% Hard vs 18% overall. 65% of questions are Medium difficulty. Focus on the high-frequency Medium problems first, then work through the Hard ones.

How should I prepare for a Walmart Labs coding interview?add

Start with the highest-frequency problems listed on this page. Focus on the core topics: array, string, hash-table. Practice solving them under time pressure and explaining your approach out loud. Mock interviews with AI can simulate the real experience.

Other companies to explore

Ready to ace your Walmart Labs interview?

Simulate a real Walmart Labs coding interview with an AI interviewer. Get a scorecard with specific feedback on your problem-solving, code quality, and communication.

Simulate a Walmart Labs interview with AIarrow_forward