Walmart Labs Interview Questions
- 0of 0 votes
Answersgiven two strings s1 and s2 we have to convert s1 into palindrome such that s1 contain s2 as a substring. in a minimum number of operation. wherein a single operation we can replace any word of s1 with any character.
- GB11 October 17, 2018 in India
constraint : |s1| <= 1000
|s2| <= |s1|
ex: s1 = "abaa" , s2 = "bb"
output : 1| Report Duplicate | Flag | PURGE
Walmart Labs Software Developer - 0of 0 votes
AnswerGiven 3 unsorted arrays A, B and C you need to find all possible combinations such that A[i] + B[j] = B[k] + C[l].
- venkataratnamkumar7777 September 22, 2018 in United States| Report Duplicate | Flag | PURGE
Walmart Labs SDE1 Algorithm Arrays - 0of 0 votes
AnswersHow to design a system which allows millions of requests
- kay March 16, 2018 in United States| Report Duplicate | Flag | PURGE
Walmart Labs Staff Engineer - 0of 0 votes
AnswersDesign an app which allows different types of jobs to be triggered at user specified delay
- kay March 16, 2018 in United States| Report Duplicate | Flag | PURGE
Walmart Labs Staff Engineer - 0of 0 votes
AnswersGiven a dictionary containing some words, and a start word and end word, you need to find the minimum number of conversion needed to convert start word to end word with the following restrictions :-
- Nascent August 23, 2017 in India
1. Each intermediate word must be in the dictionary
2. You can change only one character in the word to convert to another word.
Example If You are given start word as ‘SAT’ and end word as ‘PAN
and the dictionary contains words = [‘RAT’,’PAT’,’DAM’]
then SAT -> PAT ->PAN is the answer.| Report Duplicate | Flag | PURGE
Walmart Labs - 0of 0 votes
AnswersHow to find total number of greater number after all number in an array ?
- rahulkumar5july September 18, 2016 in India
Eg. Given array is,
5 3 9 8 2 6
o/p
3 3 0 0 1 0| Report Duplicate | Flag | PURGE
Walmart Labs Software Developer - 1of 1 vote
AnswersTwo friends Kohli and Dhoni want to test their friendship to check how compatible they are. Given a list of n movies numbered 1,2,3....n and asked both of them to rank the movies.
- abhibhagia August 07, 2016 in India
Design an algorithm to find compatibility difference between them.
Compatibility difference is the number of mis-matches in the relative rankings of the same movie given by them i.e. if Kohli ranks Movie 3 before Movie 2 and Dhoni ranks Movie 2 before Movie 3 then its a relative ranking mis-match Compatibility difference is the maximum number of mis-matches
Sample Input
5
31245
32415
Sample Output
2
Explanation
Movies are 1,2,3,4,5. Kohli ranks them 3,1,2,4,5, Dhoni ranks them 3,2,4,1,5. Compatibility difference is 2 because Kohli ranks movie 1 before 2,4 but Dhoni ranks it after.| Report Duplicate | Flag | PURGE
Walmart Labs Senior Software Development Engineer Arrays - 0of 0 votes
AnswersMario wants to reach to his princess who is waiting for him in a castle. But the way to the castle is full of dragons. Each dragon is an enemy of the dragon who is located just before him on that path. The dragons in this world are quite peculiar. They have some number of diamonds each. Although they are dragons, they won't burn, instead they will give Mario their diamonds, but if and only if, Mario didn't take any diamonds from the dragon standing directly before the current one. If Mario does, then that dragon will burn him. Mario is in your control. You have to make Mario collect maximum number of diamonds for his princess and reach castle safely.
- shraddha9jain July 28, 2016 in India
Input- Each test case starts with a number N, the number of dragons, 0 <= N <= 10^4. The next line will have N numbers, number of diamonds each dragon has, 0 <= The number of diamonds with each dragon <= 10^9. Dragons described in the order they are encountered on the way to the castle.
Output- Print the maximum number of diamonds you can collect (and reach to castle safely).
Sample Input
5 1 2 3 4 5
Sample Output
9
Explanation
Input - 5 ==> Represents number of Dragons 1 2 3 4 5 ==> Represents the diamonds each of the Dragon has consecutively. The first dragon has 1 , the second has 2 and so on....
Output- 9
Explanation- If Mario collects diamonds from 1st, 3rd and 5th dragon (1+3+5). He will get 9 diamonds which is the maximum number of diamonds he can collect. Two of the other possible ways in which he can collect diamonds is, from 2nd and 4th dragon, (2+4),i.e.(6) or from 2nd and 5th dragon (2+5) i.e.,7 . He can’t obtain more than 9 diamonds in any case.
Therefore the output would be 9, the maximum he can collect.| Report Duplicate | Flag | PURGE
Walmart Labs Java Developer - 0of 0 votes
AnswersFind the number of column-swaps required to find the largest rectangle of all ones in a matrix.
- novicedhunnu July 19, 2016 in India for N/A
The question is similar to the one in this link-
http://www.geeksforgeeks.org/find-the-largest-rectangle-of-1s-with-swapping-of-columns-allowed/
But we need to find the number of minimum swaps required| Report Duplicate | Flag | PURGE
Walmart Labs SDE1 - 0of 0 votes
AnswersFind the value of (x, y) in Pascal's triangle. I wrote code to construct the Pascal's triangle upto the required (x, y). Then interviewer asked me to change code so that I dont have to calculate the whole triangle but only the necessary parts.
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
For example, in order to calculate f(4, 1) which is 4, we only need to calculate f(3, 0) and f(3, 1). And for f(3, 1) we need to calculate f(2, 0) and f(2, 1) and so on. After getting the hint, I wrote the recursive code and then he asked my for complexity of the code.
- killdos October 11, 2015 in United Statesint pascals(int x, int y){ if(x == 0 or x == y) return 1; return(pascals(x - 1, y) + pascals (x- 1, y - 1); }
| Report Duplicate | Flag | PURGE
Walmart Labs Java Developer - 0of 0 votes
AnswersImplement pow(x, y) which should return x^y. Both iterative and recursive.
- killdos October 11, 2015 in United States| Report Duplicate | Flag | PURGE
Walmart Labs Java Developer - 0of 0 votes
AnswersPrint all permutations of a string and give the complexity of the algorithm.
- killdos October 11, 2015 in United States| Report Duplicate | Flag | PURGE
Walmart Labs Java Developer - 0of 0 votes
AnswersGiven a tree (incolmplete and/or unbalanced), how would you write it to disk so it can be moved to another machine and recreated?
- killdos October 11, 2015 in United States| Report Duplicate | Flag | PURGE
Walmart Labs Java Developer - 0of 0 votes
AnswersThere is a garden of strawberry plants represented by a 2D, square array.Each plant represents an element in the matrix ie it has a number of strawberries. If a plant doesnt have strawberries it is denoted by 0. If 0 is encountered you cannot travel through that path.
- topCoder September 27, 2015 in United States
You can start from any cell along the left border of this ground (i.e the matrix) and travel until it finally stops at one cell in the right border, and you can only move to up/down/right. You can only visit each cell once. Calculate the maximum number of berries is obtained.
Backtracking using Dynamic programming is one of the methods i have thought of.
Also there some special conditions:
a.Even in the left border and right border, we can go up and down.
b. When we are at the top cell of one column, we can still go up, which demands us to
pay all current strawberries , then we will be teleported to the bottom cell of this column and vice
versa.
Input: user enters dimensions of ground ie size of matrix and the matrix itself
Output: is the maximum number of strawberries collected without encountering 0; in case we do we display 0.
Till now i have managed to find the largest value in the first column of the matrix but i am facing difficulty in testing the neighbours of that cell.
Also i am not able to store the position of the cell which i started from or even mark it.
Input
4 4
-1 4 5 1
2 -1 2 4
3 3 -1 3
4 2 1 2
output
23
Input
4 4
-1 4 5 1
2 -1 2 4
3 3 -1 -1
4 2 1 2
output
22| Report Duplicate | Flag | PURGE
Walmart Labs Algorithm C++ Coding Dynamic Programming - 1of 1 vote
Answers. Given n strings consisting of ‘R’ and ‘B’. Two strings can be only combined if last character of first string and first character of second string are same. Given n strings, you have to output the maximum length possible by combining strings.
- ritwik_pandey September 09, 2015 in United States
I/P
RBR
BBR
RRR
output : 9| Report Duplicate | Flag | PURGE
Walmart Labs Software Engineer Algorithm - 0of 0 votes
AnswersImplemented a bounded queue:
- JSDUDE June 23, 2015 in United States for Customer experience
Read:
If queue is empty, wait till it can return a value with time out
If another thread is reading from the queue then wait till that thread is done
Remove the first element from the queue and return it
Do not block if a thread is writing into the queue
Write:
If queue is full, wait till one value is read with time out
If another thread is writing to the queue, wait till that thread is done
Write the element at the end of the queue
Do not block if a thread is reading from the queue| Report Duplicate | Flag | PURGE
Walmart Labs Software Developer Data Structures Threads - 1of 1 vote
AnswersGiven a start string, end string and a set of strings, find if there exists a path between the start string and end string via the set of strings.
- JSDUDE June 23, 2015 in United States for Customer experience
A path exists if we can get from start string to end string by changing (no addition/removal) only one character at a time. The restriction is that the new string generated after changing one character has to be in the set.
start: "cog"
end: "bad"
set: ["bag", "cag", "cat", "fag", "con", "rat", "sat", "fog"]
one of the paths: "cog" -> "fog" -> "fag" -> "bag" -> "bad"| Report Duplicate | Flag | PURGE
Walmart Labs Software Developer Algorithm String Manipulation - 0of 0 votes
AnswersGiven an array of integers (+ve & -ve) find two equal sized contiguous non-overlapping sub-arrays with maximum dot-product
- JSDUDE June 23, 2015 in United States for Customer experience| Report Duplicate | Flag | PURGE
Walmart Labs Software Developer Algorithm Arrays - 0of 0 votes
AnswersWrite an OO class system for individual-contributors, managers, directors.
- JSDUDE June 23, 2015 in United States for Customer experience| Report Duplicate | Flag | PURGE
Walmart Labs Software Developer Object Oriented Design - 0of 0 votes
AnswersMinimize the cost to chop the log into pieces of desired lengths. The cost to cut any piece is the max of the two lengths generated out of cutting the wood. e.g. If a 14 unit log is cut into 2 pieces of lengths 6 and 8, cost is 8.
- JSDUDE June 23, 2015 in United States for Customer experience
Write a function that takes the total length of the log and an array of piece lengths and returns the cheapest sequence to do this along with the cost| Report Duplicate | Flag | PURGE
Walmart Labs Software Developer Algorithm - 0of 0 votes
AnswersGiven an existing inventory Oracle Database system and UI. The UI should update itself as soon as the db gets updated
- JSDUDE June 23, 2015 in United States for Customer experience
There is a tool that people use to dump inventory data (one row at a time or bulk insert via data in files)
Currently a new system is built with new UI using No Sql database.
Write a bridge that will update the new UI and populate the No SQL database, so that the new UI has real time updates as the tool has updated.| Report Duplicate | Flag | PURGE
Walmart Labs Software Developer System Design - -1of 1 vote
Answers
- JSDUDE June 04, 2015 in United Statespublic class StringUtilities { /** * Count the maximum depth of parenthesis nesting, i.e. "abc(123(xyz))m(((n)))o" -> 3. * * @param input * any string * @return deepest parenthesization level * @throws IllegalArgumentException * if input is null or contains a mismatch "a)b(c" or "a(b" */ public static int nestedParenthesisDepth(String input) throws IllegalArgumentException { //... } }
| Report Duplicate | Flag | PURGE
Walmart Labs Software Engineer Algorithm String Manipulation - -2of 4 votes
Answerspublic class MyClass {
- MrA March 29, 2015 in United States
public static int num=1;
public static boolean flag=false;
public static void main(String[] args) {
Thread t =new Thread(new MyThread());
t.start();
MyClass.flag=true;
MyClass.num=10;
}
}
class MyThread implements Runnable{
public void run() {
while(!MyClass.flag){
Thread.yield();
}
System.out.println(MyClass.num);
}
}
Output of this code and the reason for the output?| Report Duplicate | Flag | PURGE
Walmart Labs Software Engineer Java - 0of 0 votes
AnswersInput any string, count the maximum depth of parenthesis nesting, i.e. "abc(123(xyz))m(((n)))o" -> 3.
- jobPrep February 23, 2015 in United States
if input is null or contains a mismatch "a)b(c" or "a(b"
Also some other samples:
(((()))) -> 4
()()()() -> 1| Report Duplicate | Flag | PURGE
Walmart Labs Coding - 1of 1 vote
AnswersYou have a class that many libraries depend on. You need to modify the class for one application. Which of the following changes require recompiling all libraries before it is safe to build the application?
- manojkumar16 December 04, 2014 in India
a. add a constructor
b. add a data member
c. change destructor into virtual
d. add an argument with default value to an existing member function| Report Duplicate | Flag | PURGE
Walmart Labs Applications Developer Java - -1of 1 vote
AnswersDo thread join without join function?
- manojkumar16 December 04, 2014 in India| Report Duplicate | Flag | PURGE
Walmart Labs Applications Developer Java - 0of 0 votes
AnswersGiven a BST, how would you return the kth smallest element. Cover all the corner cases with time complexity logn
- manojkumar16 December 04, 2014 in India| Report Duplicate | Flag | PURGE
Walmart Labs Applications Developer Algorithm - 0of 0 votes
AnswersWrite a program that reverses alternate elements in a given linked list input: a->b->c->d, output should be b->a->d->c
- manojkumar16 December 04, 2014 in India| Report Duplicate | Flag | PURGE
Walmart Labs Applications Developer Algorithm - 1of 1 vote
AnswersAsked at Walmart Labs
- ayaskant.swain November 04, 2014 in India for R&D
----------------------------------
There is a row of seats. Assume that it contains 15 seats adjacent to each other. There is a group of people who are already seating in that row randomly. i.e. some are sitting together & some are scattered.
Take the row as a String in java.
The seat which is occupied is marked with a character 'X' & which is not occupied is marked with a dot '.'
Now your target is to make the whole group sit together i.e. next to each other and without having any vacant seat between them in such a way that the total number of hops or jumps at the end of the grouping them together should be minimum.
Ok let me try to explain you in details.
Here is the row having 15 seats represented by the String (0, 1, 2, 3, ......... , 14) -
. . . . x . . x x . . . x . .
Now to make them sit together one of approaches is - . . . . . . x x x x . . . . .
Following are the steps to achieve this -
1 - Move the person sitting at 4th index to 6th index - Number of jumps by him = (6 - 4) = 2
2 - Bring the person sitting at 12th index to 9th index - Number of jumps by him = (12 - 9) = 3
------------------------------------------------------------------------------------------------------------------------------------------------------------
So now the total number of jumps made = ( 2 + 3) = 5 which is the minimum possible jumps to make them seat together.
There are also other ways to make them sit together but the number of jumps will exceed 5 & that will not be minimum.
For example bring them all towards the starting of the row i.e. start placing them from index 0. In that case the total number of jumps will be ( 4 + 6 + 6 + 9 ) = 25 which is very costly and not an optimized way to do this movement.
Now write an algorithm which will return the minimum number of jumps required to make them sit together.| Report Duplicate | Flag | PURGE
Walmart Labs Senior Software Development Engineer Algorithm - 0of 0 votes
AnswersThere is a matrix of very large dimension (10^30 * 10*40) of characters. You need to search a string of length 10^10 inside the matrix. Adjacent characters in any direction can be chosen and same cell can be counted multiple times to find the pattern
- Lunatic November 05, 2013 in India| Report Duplicate | Flag | PURGE
Walmart Labs Software Engineer / Developer Algorithm
Open Chat in New Window