🛒 Walmart DSA Interview Questions (with Links + Sources)
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)
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.
Design and implement a data structure for a Least Frequently Used (LFU) cache. Implement the LFUCache class:
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.
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 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.
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.
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.
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).