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

SDE - 1

Walmart
upvote
share-icon
3 rounds | 6 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 3 months
Topics: Data Structures, Algorithms, System Design, Puzzles, 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: Campus
Eligibility: Above 7 CGPA
Resume Tip
Resume tip

Tip 1 : Have at-least 2 good projects 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
Face to Face
Duration90 Minutes
Interview date21 Dec 2015
Coding problem2

This Round was DS and Algo round and it started with formal introduction, followed by 2 problems. We first dicussed the approach the time complexity and proper code covering all cases.

1. Minimum Cost To Buy Oranges

Moderate
20m average time
70% success
0/80
Asked in companies
WalmartIntuitAmazon

You are given a bag of size 'W' kg and provided with the costs of packets with different weights of oranges as a list/array with the name 'cost'. Every i-th position in the cost denotes the price of 'i+1' kg packet of oranges.

If at any point in time the i-th cost is -1, it means that 'i+1' kg packet of orange is unavailable.

You are required to find the minimum total cost to buy exactly 'W' kg oranges and if it's not possible to buy precisely W kg oranges then print -1. There is an infinite supply of all available packet types.

Note :
Array index 'i' denotes the cost of (i+1)kg packet. 
Example: cost[0] is the cost of a 1kg packet of oranges.
Problem approach

This problem was actually a variation Unbounded Kanpsack Problem . I first gave the interviewer a naive recursive approach and then later optimised it using memoisation .

Naive Recursive Approach :
1) Create a recursive function ( int minCost(cost, idx , w) ) which returns the optimal answer for an array which starts with index idx and for a given weight w.
2) Now for every index idx , if cost[idx]!=-1 then I have three options : 

option1 -> Take that particular element and then recursively call for the whole array again (we won't increment idx here as we can take an element infinitley many times) with the same idx and a reduced weight w-idx-1(assuming 0-based indexing) . i.e.,
option1=cost[idx]+minCost(cost,idx,w-idx-1);

option2 -> Take that particular element and then recursively call for the rest of the array with index as idx+1 and a reduced weight w-idx-1(assuming 0-based indexing) . i.e., 
option2=cost[idx]+minCost(cost,idx+1,w-idx-1); 

option3-> Do not take that element at all and then recursively call for the rest of the array with index as idx+1 but with the same weight w.
option3=minCost(cost,idx+1,w);

Now , return the min({op1,op2,op3})

3)If cost[idx]==-1 , we have only one option - To not take that element at all and then recursively call for the rest of the array with index as idx+1 but with the same weight w.
i.e. return minCost(cost,idx+1,w)

4)Base Cases : 
a) If weight , w==0 then we can simply return 0 (do not take any element)
b) If index >= cost.size() or weight<0 , then simply return the max value of integer (INT_MAX in C++)

TC : O(3^n)
SC:O(n*w)


Dynamic Programmming (Using Memoisation ) : 
As we can observe , this problem has both optimal substructure as well as optimal subproblem properties and hence can be easily memoised using a map (key->pair of index and weight , value->answer for this state) i.e. 

dp[{idx,w}= min({op1,op2,op3})

Check if we have previously visited this state or not . If yes simply return the dp value

TC : O(n*w)
SC : O(n*w)

Try solving now

2. K - Sum Path In A Binary Tree

Moderate
35m average time
65% success
0/80
Asked in companies
Thought WorksWalmartFacebook

You are given a binary tree in which each node contains an integer value and a number ‘K’. Your task is to print every path of the binary tree with the sum of nodes in the path as ‘K’.

Note:

1. The path does not need to start or end at the root or a leaf, but it must go downwards (traveling only from parent nodes to child nodes).

2. Output the paths in the order in which they exist in the tree from left to right. Example: In the below example, path {1,3} is followed by {3,1} and so on.

Example:

For K = 4 and tree given below:

alt text

The possible paths are:
1 3
3 1
-1 4 1
4 
-1 5

The sum of values of nodes of each of the above-mentioned paths gives a sum of 4.
Problem approach

The idea is simple: along the path, record all prefix sums in a hash table. For current prefix sum x, check if (x - target) appears in the hash table.

Steps : 
1) We will be using a unordered map which will be filled with various path sum.
2) For every node we will check if current sum and root’s value equal to k or not. If the sum equals to k then increment the required answer by one.
3) Then we will add all those path sum in map which differs from current sum+root->data value by a constant integer k.
4) Then we will be inserting the current sum + root->data value in the map.
5) We will recursively check for left and right subtrees of current root
6) After the right subtree is also traversed we will remove the current sum + root->data value from the map so that it is not taken into consideration in further traversals of other nodes other than the current root’s.

TC : O(n) where n is the total number of nodes in the tree
SC : O(n)

Try solving now
02
Round
Medium
Face to Face
Duration40 Minutes
Interview date21 Dec 2015
Coding problem2

This round majorly focused on puzzles and some questions revolving around Computer Networks and the projects in my resume .

1. Puzzle

Two wire burning puzzle .

Problem approach

If we light a stick, it takes 60 minutes to burn completely. What if we light the stick from both sides? It will take exactly half the original time, i.e. 30 minutes to burn completely.

1) 0 minutes – Light stick 1 on both sides and stick 2 on one side.
2) 30 minutes – Stick 1 will be burnt out. Light the other end of stick 2.
3) 45 minutes – Stick 2 will be burnt out. Thus 45 minutes is completely measured.

2. Puzzle

3 Ants and Triangle

Problem approach

Collision doesn’t happen only in following two cases
1) All ants move in counterclockwise direction.
2) All ants move in clockwise direction.

Since every ant has two choices (pick either of two edges going through the corner on which ant is initially sitting), there are total 23 possibilities.

Out of 23 possibilities, only 2 don’t cause collision. So, the probability of collision is 6/8 or 3/4 and the probability of non-collision is 2/8 or 1/4.

03
Round
Easy
HR Round
Duration30 Minutes
Interview date21 Dec 2015
Coding problem2

This is a cultural fitment testing round .HR was very frank and asked standard questions. Then we discussed about my role.

1. Basic HR Question

Do you know anything about the company ?

Problem approach

General Tip : Before an interview for any company , have a breif insight about the company , what it does , when was it founded and so on . All these info can be easily acquired from the Company Website itself .

2. Basic HR Question

Why should we hire you ?

Problem approach

Tip 1 : The cross questioning can go intense some time, think before you speak.
Tip 2 : Be open minded and answer whatever you are thinking, in these rounds I feel it is important to have opinion.
Tip 3 : Context of questions can be switched, pay attention to the details. It is okay to ask questions in these round, like what are the projects currently the company is investing, which team you are mentoring. How all is the work environment etc.
Tip 4 : Since everybody in the interview panel is from tech background, here too you can expect some technical questions. No coding in most of the cases but some discussions over the design can surely happen.

Here's your problem of the day

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

Skill covered: Programming

How do you remove whitespace from the start of a string?

Choose another skill to practice
Similar interview experiences
company logo
SDE - 1
5 rounds | 6 problems
Interviewed by Walmart
4668 views
0 comments
0 upvotes
company logo
SDE - 1
4 rounds | 10 problems
Interviewed by Walmart
4972 views
0 comments
0 upvotes
company logo
SDE - 1
5 rounds | 8 problems
Interviewed by Walmart
915 views
0 comments
0 upvotes
company logo
SDE - 1
5 rounds | 8 problems
Interviewed by Walmart
1362 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Amazon
115097 views
24 comments
0 upvotes
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
58238 views
5 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
35147 views
7 comments
0 upvotes