Related Articles

# Walmart Interview Experience

• Difficulty Level : Medium
• Last Updated : 22 Jun, 2021

Round 1:
It was an online round hosted by Walmart on dare2dare. It consisted of 2 coding questions. The coding question goes like this :

1: This question is also asked in the onsite 2nd intuit interview of SDE-1.
Exactly one swap

Given a string S containing lowercase English alphabet characters. The task is to calculate the number of distinct strings that can be obtained after performing exactly one swap.

In one swap,Geek can pick two distinct indexes i and j (i.e 1 < i < j < |S| ) of the string, then swap the characters at the position i and j.

```Example 1:
Input:
S = "geek"
Output:
6
Explanation:
After one swap, there are only 6 distinct strings possible.
(i.e "egek","eegk","geek","geke","gkee" and "keeg")```

2: This question is also asked in the Hackwithinfy online round.

Partition the array

Given an array A[] of N integers. The task is to partition the array into four non-empty parts P,Q,R and S.

Let W,X,Y and Z be the sum of the elements in P,Q,R and S respectively. The absolute difference of the maximum and the minimum among W,X,Y and Z should be smallest. Find the smallest absolute difference of the maximum and the minimum among W,X,Y and Z.

Example 1:
Input:
N = 5
A[] = [4,2,2,5,1]
Output:
Explanation: let partition the array
P,Q,R,S = ,[2,2],,
W = 4, X = 4, Y = 5, Z = 1
Difference = max(W,X,Y,Z) – min(W,X,Y,Z)
= 5 – 1 = 4

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course. In case you are prepared, test your skills using TCS, Wipro, Amazon. GoogleE-Litmus and Microsoft Test Serieses.

My Personal Notes arrow_drop_up