🛒 Walmart DSA Interview Questions (with Links + Sources)

walmart logo
walmart
August 30, 202561 reads

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.

Full Experience

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.

Interview Questions (17)

Q1
Move Zeroes
Data Structures & AlgorithmsEasy

Given an integer array nums, move all 0'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.

Q2
Maximum Subarray
Data Structures & AlgorithmsMedium

Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.

Q3
House Robber II
Data Structures & AlgorithmsMedium

You 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 nums representing the amount of money of each house, return the maximum amount of money you can rob tonight without alerting the police.

Q4
Subarray Sum Equals K
Data Structures & AlgorithmsMedium

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

Q5
LFU Cache
Data Structures & AlgorithmsHard

Design and implement a data structure for a Least Frequently Used (LFU) cache. Implement the LFUCache class:

  • LFUCache(int capacity) Initializes the object with the capacity of the data structure.
  • int get(int key) Gets the value of the key if the key exists in the cache, otherwise returns -1.
  • void put(int key, int value) Update the value of the key if present, or inserts the key if not already present. When the cache reaches its capacity, 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.
Q6
LRU Cache
Data Structures & AlgorithmsMedium

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

Implement the LRUCache class:

  • LRUCache(int capacity) Initializes the LRU cache with the given positive capacity.
  • int get(int key) Returns the value of the key if the key exists, otherwise returns -1.
  • void put(int key, int value) Update the value of the key if the key exists, Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used key.
Q7
Degree of an Array
Data Structures & AlgorithmsEasy

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. Your task is to find the smallest possible length of a (contiguous) subarray of nums that has the same degree as nums.

Q8
Reformat Date
Data Structures & AlgorithmsEasy

Given a date string in the form "Day Month Year", where:

  • Day is an integer in the range [1, 31] with an ordinal suffix.
  • Month is a three-letter abbreviation of a month.
  • Year is an integer in the range [1900, 2100].

Return the date in the format "YYYY-MM-DD".

Q9
Two Sum IV - Input is a BST
Data Structures & AlgorithmsEasy

Given the root of a Binary Search Tree and an integer k, return true if there exist two distinct nodes in the tree whose values sum up to k, or false otherwise.

Q10
Gas Station
Data Structures & AlgorithmsMedium

There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i]. You have a car with an unlimited tank and it costs cost[i] of gas to travel from the ith station to the (i + 1)th station. You begin the journey with an empty tank at one of the gas stations.

Given two integer arrays gas and cost, 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.

Q11
Jump Game
Data Structures & AlgorithmsMedium

You are given an integer array nums. You are initially positioned at the array's first index, and each element in nums represents your maximum jump length at that position.

Return true if you can reach the last index, or false otherwise.

Q12
Subsets II
Data Structures & AlgorithmsMedium

Given an integer array nums that may contain duplicates, return all possible subsets (the power set).

The solution set must not contain duplicate subsets. Return the solution in any order.

Q13
Longest Palindromic Substring
Data Structures & AlgorithmsMedium

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

Q14
Reverse Linked List
Data Structures & AlgorithmsEasy

Given the head of a singly linked list, reverse the list, and return the reversed list.

Q15
Minimum Number of Days to Make m Bouquets
Data Structures & AlgorithmsMedium

You are given an integer array bloomDay, an integer m and an integer k.

You want to make m bouquets. To make a bouquet, you need k adjacent flowers from the garden. The garden has n flowers, the ith flower will bloom in the bloomDay[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 m bouquets. If it is impossible to make m bouquets, return -1.

Q16
Best Time to Buy and Sell Stock with Cooldown
Data Structures & AlgorithmsMedium

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

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).
Q17
Trapping Rain Water
Data Structures & AlgorithmsHard

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.

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!