Walmart interview experience Real time questions & tips from candidates to crack your interview

SDE - 2

Walmart
upvote
share-icon
3 rounds | 8 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 3 months
Topics: Data Structures, Algorithms, System Design, Aptitude, OOPS
Tip
Tip

Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 3 : Do at-least 2 good projects and you must know every bit of them.

Application process
Where: Referral
Eligibility: Above 2 years of experience
Resume Tip
Resume tip

Tip 1 : Have at-least 2 good projects/experiences explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.

Interview rounds

01
Round
Medium
Video Call
Duration60 Minutes
Interview date4 Mar 2021
Coding problem2

Standard Data Structures and Algorithms round . One has to be fairly comfortable in solving algorithmic problems to pass this round with ease.

1. Minimum Cost To Connect Sticks

Moderate
15m average time
85% success
0/80
Asked in companies
GoogleLinkedInPayPal

You are given an array/list ‘ARR’ of ‘N’ positive integers where each element describes the length of the stick. You have to connect all sticks into one. At a time, you can join any two sticks by paying a cost of ‘X’ and ‘Y’ where ‘X’ is the length of the first stick and ‘Y’ is the length of the second stick and the new stick we get will have a length equal to (X+Y). You have to find the minimum cost to connect all the sticks into one.

Problem approach

It is a greedy approach where we will form a min-heap of all the lengths of sticks that are given to us. In this approach, we will always find two sticks with minimum length and connect them and add their cost to our answer. Also, we will add the newly formed stick back into our min-heap. And then we will continue to do the same procedure for all the remaining sticks. Since we need to minimize the cost to connect all the sticks into one, therefore we have to greedily pick the two smallest lengths of sticks from given lengths and add them to the answer and continue it until we are left with one stick in our heap. We are picking the two smallest sticks every time because the new stick formed will also be added to our cost later. Therefore picking smaller sticks will reduce the total cost than using longer sticks which will increase the cost.

Try solving now

2. Minimum Jumps

Moderate
25m average time
75% success
0/80
Asked in companies
AdobeSliceMathworks

Bob lives with his wife in a city named Berland. Bob is a good husband, so he goes out with his wife every Friday to ‘Arcade’ mall.

‘Arcade’ is a very famous mall in Berland. It has a very unique transportation method between shops. Since the shops in the mall are laying in a straight line, you can jump on a very advanced trampoline from the shop i, and land in any shop between (i) to (i + Arr[i]), where Arr[i] is a constant given for each shop.

There are N shops in the mall, numbered from 0 to N-1. Bob's wife starts her shopping journey from shop 0 and ends it in shop N-1. As the mall is very crowded on Fridays, unfortunately, Bob gets lost from his wife. So he wants to know, what is the minimum number of trampoline jumps from shop 0 he has to make in order to reach shop N-1 and see his wife again. If it is impossible to reach the last shop, return -1.

Problem approach

Approach 1 : Naive Recursive Approach

A naive approach is to start from the first element and recursively call for all the elements reachable from first
element. The minimum number of jumps to reach end from first can be calculated using minimum number of jumps
needed to reach end from the elements reachable from first.
minJumps(start, end) = Min ( minJumps(k, end) ) for all k reachable from start

TC : O(n^n)
SC:O(n)


Approach 2: Dynamic Programming - Tabulation

We can solve this iteratively as well. For this, we start from the last index. We need 0 jumps from nums[n-1] to reach
the end. We store this as dp[n - 1] = 0 and then iteratively solve this for each previous index till the 0th index. Here
dp[i] denotes minimum jumps required from current index to reach till the end.

1) For each index, we explore all the possible jump sizes available with us.
2) The minimum jumps required to reach the end from the current index would be - min(dp[jumpLen]), where 1 <=
jumpLen <= nums[currentPostion]

TC : O(n^2)
SC : O(n)


Approach 3 : Most optimal - Greedy-BFS

We can iterate over all indices maintaining the furthest reachable position from current index - maxReachable and
currently furthest reached position - lastJumpedPos. Everytime we will try to update lastJumpedPos to furthest
possible reachable index - maxReachable.

Updating the lastJumpedPos separately from maxReachable allows us to maintain track of minimum jumps required.
Each time lastJumpedPos is updated, jumps will also be updated and store the minimum jumps required to reach
lastJumpedPos (On the contrary, updating jumps with maxReachable won't give the optimal (minimum possible)
value of jumps required).

We will just return it as soon as lastJumpedPos reaches(or exceeds) last index.

TC : O(n)
SC: O(1)

Try solving now
02
Round
Hard
Video Call
Duration70 Minutes
Interview date4 Mar 2021
Coding problem4

This round was preety intense and went for over 1 hour . I was asked 2 preety good coding questions (one was from Graphs and the other one was from DP) . After that I was grilled on my Computer Networks concepts but luckily I was able to answer all the questions and the interviewer was also quite impressed .

1. Bipartite Graph

Moderate
50m average time
50% success
0/80
Asked in companies
UberWalmarteBay

Given a graph, check whether the graph is bipartite or not. Your function should return true if the given graph's vertices can be divided into two independent sets, ‘U’ and ‘V’ such that every edge (‘u’, ‘v’) either connects a vertex from ‘U’ to ‘V’ or a vertex from ‘V’ to ‘U’.

You are given a 2D array ‘edges’ which contains 0 and 1, where ‘edges[i][j]’ = 1 denotes a bi-directional edge from ‘i’ to ‘j’.

Note:
If edges[i][j] = 1, that implies there is a bi-directional edge between ‘i’ and ‘j’, that means there exists both edges from ‘i’ to ‘j’ and to ‘j’ to ‘i’.

For example

Given:
‘N’ = 3
‘edges’ = [[0, 1, 1], [0, 0, 1], [0,0,0]]. 

Problem approach

Algorithm : 
1) Create a graph such that there is a edge between each pair of enemies.
2) We need to find that the above graph is bipartite or not. Check whether the graph is 2-colorable or not
3) We can do that by running dfs and using an auxilary array col to store the assigned col of the node.
4) If we can color the graph with two color such that no two enemies have same color then only we can create two teams.

TC : O(V+E) where V=number of vertices and E=number of edges
SC : O(V) 

Note: Since the graph can be disconnected so run dfs on each component.

Try solving now

2. Maximum length pair chain

Moderate
15m average time
85% success
0/80
Asked in companies
UberMicrosoftAmazon

You are given ‘N’ pairs of integers in which the first number is always smaller than the second number i.e in pair (a,b) -> a < b always. Now we define a pair chain as the continuous arrangement of pairs in which a pair (c,d) can follow another pair (a,b) only when b < c.

Find the length of the longest pair chain that can be formed using the given pairs.

Example:
Given Pairs =  [3,4], [1,2], [2,3].

The length of the maximum chain will be 2. The longest chain is [1,2] -> [3,4].
Note:
1. You can select a pair only once.

2. You needn’t use up all the given pairs.

3. You can select pairs in any order. 
Problem approach

Approach 1 (Using DP ) :

Observe that , If a chain of length k ends at some pairs[i], and pairs[i][1] < pairs[j][0], we can extend this chain to a chain of length k+1

Steps :
1) Sort the pairs by first coordinate, and let dp[i] be the length of the longest chain ending at pairs[i]. 
2) When i < j and pairs[i][1] < pairs[j][0], we can extend the chain, and so we have the candidate answer 
dp[j] = max(dp[j], dp[i] + 1).

TC : O(N^2)
SC : O(N)

Approach 2 (Greedy based):

We can greedily add to our chain. 
Steps:
1) Choosing the next addition to be the one with the lowest second coordinate is at least better than a choice with a larger second coordinate.
2) Consider the pairs in increasing order of their second coordinate.
3) We'll try to add them to our chain. If we can, by the above argument we know that it is correct to do so.

TC : O(N*log(N))
SC: O(N)

Try solving now

3. Computer Networks Question

Explain TCP/IP Protocol

Problem approach

1) TCP or TCP/IP is the Transmission Control Protocol/Internet Protocol. 
2) It is a set of rules that decides how a computer connects to the Internet and how to transmit the data over the network. 
3) It creates a virtual network when more than one computer is connected to the network and uses the three ways handshake model to establish the connection which makes it more reliable.

4. Computer Networks Question

Explain DHCP Protocol

Problem approach

1) DHCP is the Dynamic Host Configuration Protocol.
2) It is an application layer protocol used to auto-configure devices on IP networks enabling them to use the TCP and UDP-based protocols.
3) The DHCP servers auto-assign the IPs and other network configurations to the devices individually which enables them to communicate over the IP network. 
4) It helps to get the subnet mask, IP address and helps to resolve the DNS. It uses port 67 by default.

03
Round
Medium
Video Call
Duration50 Minutes
Interview date4 Mar 2021
Coding problem2

This round majorly focused on past projects and experiences from my Resume and some standard System Design +
LLD questions + some basic OS questions which a SDE-2 is expected to know .

1. System Design Question

Design Pastebin

Problem approach

Approach : 

Pastebin allows users to store text-based data over the internet for a set period of time and generate a unique URL corresponding uploaded data to share that with anyone. Users who create that data, can also modify it by logging in to the same account. 

Database Schema :

i) users(userID, name, createdAT, metaData)
ii) paste(pasteID, content, URL, createdAt, expiryAt)

Algorithm :

1) create_paste(api_key, content, expiryAt)- this will return URL generated and success message that paste is stored successfully and in case of error it will return error.
2) read_paste(URL)- returns corresponding original content and a error code in case of any failure.

Architecture and Components :

For creating the backend of pastebin we can either use serverless architecture which will use AWS lambda functions for both APIs create paste and read paste or we can use microservice architecture which will require different services for creating paste and reading paste.

Storing Content :

It will not be a good choice to keep all data in our database(SQL or noSQL). Because storing 1000TBs of data in DB is not a good choice, so we can use hybrid approach we can use Object storage service like AWS S3 in which we can store the content in blob(binary large object) form and for the data less than 100KB we can store it in our Database only.

Cache :

For eliminating Cache, we can use LRU here, URLs which aren’t used frequently we can replace them with frequently used URLs. We need to synchronize cache data with original data in the background, so that consistency is always there in content.

Key Generating Service :

This service helps in generating random 10 letter keys beforehand and will store them in Redis DB, Now whenever we are storing a paste and we need a URL for, we will look up in our Redis DB and see which key is not used, and after using the key we need to mark it used.

Expiry time URL :

We have a cleanup Sync service which will lookup in our database if current time is greater than expiry time set while creating a paste, it will delete the entry from DB and also delete the file present in AWS S3(Object Store).


General Tip : Finally , for acing System Design Rounds I would suggest watching Gaurav Sen's System Design Videos on YouTube and for hands on practice there is a Guided Path solely for System Design on CodeStudio which is very useful while preparing for these type of rounds.

2. OOPS Question

What is Data Abstraction and how to achive it ?

Problem approach

Answer : 
1) Data abstraction is a very important feature of OOPs that allows displaying only the important information and hiding the implementation details. 
2) For example, while riding a bike, you know that if you raise the accelerator, the speed will increase, but you don’t know how it actually happens. 
3) This is data abstraction as the implementation details are hidden from the rider.

Data abstraction can be achieved through:
i) Abstract class
ii) Abstract method

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

What is 3 + 2 * 4 based on operator precedence?

Choose another skill to practice
Similar interview experiences
company logo
SDE - 2
3 rounds | 6 problems
Interviewed by Walmart
2446 views
1 comments
0 upvotes
company logo
SDE - 2
4 rounds | 4 problems
Interviewed by Walmart
1564 views
1 comments
0 upvotes
company logo
SDE - 2
4 rounds | 13 problems
Interviewed by Walmart
1782 views
0 comments
0 upvotes
company logo
SDE - 2
2 rounds | 7 problems
Interviewed by Walmart
1015 views
1 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 2
3 rounds | 5 problems
Interviewed by Amazon
5771 views
0 comments
0 upvotes
company logo
SDE - 2
6 rounds | 8 problems
Interviewed by Amazon
4197 views
0 comments
0 upvotes
company logo
SDE - 2
4 rounds | 7 problems
Interviewed by Dunzo
2702 views
0 comments
0 upvotes