Walmart Labs Interview Questions
- 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 - 0of 0 votes
AnswersGiven an array find any three numbers which sum to zero. Give the best algorithm.
- Naveen March 15, 2013 in United States| Report Duplicate | Flag | PURGE
Walmart Labs Software Engineer / Developer Algorithm - 1of 3 votes
AnswersGiven an array of both positive and negative numbers, find the contiguous range in the array which gives the maximum product. Give an algorithm which runs in O(N).
- Naveen March 15, 2013 in United States| Report Duplicate | Flag | PURGE
Walmart Labs Software Engineer / Developer Algorithm - 0of 0 votes
AnswersHow will you Design Twitter Trends. Suggest Algorithm for this
- Geek January 26, 2013 in India| Report Duplicate | Flag | PURGE
Walmart Labs Algorithm - 0of 0 votes
AnswersYou have a sequence of data which tells about daily prices of a stock (of a company in some market). Given the sequence for N such days tell when should one buy and sell to maximize the profit. (for simplicity Assume you can buy only 1 stock). Prices of stock is same for a single day and you cannot buy and sell on the same day.
- vik January 23, 2013 in United States
Edit: You have to buy once only and sell once only. (I also misunderstood Q during interview that we have to tell sequence of buying and selling but it was not the question)| Report Duplicate | Flag | PURGE
Walmart Labs Intern Algorithm - 0of 0 votes
Answersgiven a binary tree and a leaf node.
- geekykid January 20, 2013 in India
holding that leaf node and whole tree falls down such that it is the new root of the tree.
return the modified tree.| Report Duplicate | Flag | PURGE
Walmart Labs Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersLongest posibble path in a tree, you had to return the end leaf nodes.
- kingKode October 12, 2012 in United States
geeksforgeeks(dot)org/diameter-of-a-binary-tree/| Report Duplicate | Flag | PURGE
Walmart Labs Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersGiven a number, find closest perfect square to the number?
- Gowri Shankar August 02, 2012 in India for Services| Report Duplicate | Flag | PURGE
Walmart Labs Software Engineer / Developer Algorithm - 0of 0 votes
AnswersTransform a binary tree to a left child right sibling tree?
- Gowri Shankar August 02, 2012 in India for Services| Report Duplicate | Flag | PURGE
Walmart Labs Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven a set of numbers. Print all possible subsets?
- Gowri Shankar August 02, 2012 in India for Services| Report Duplicate | Flag | PURGE
Walmart Labs Software Engineer / Developer Algorithm - 0of 0 votes
AnswersA set of integer values are being received (1 per day). Store these values and at any given time, retrieve the min and max value over the last k days. What structures would you use for storing and retrieving ?
- abkk July 14, 2012 in India| Report Duplicate | Flag | PURGE
Walmart Labs Software Engineer / Developer Algorithm - 1of 1 vote
AnswersYou have an array containing n integers. Find a triplet a,b,c st a < b < c and a appears before b and b before c in the array. Suggest a solution with complexity less than O(n2)
- neshg May 16, 2012 in India| Report Duplicate | Flag | PURGE
Walmart Labs Developer Program Engineer Algorithm - 0of 0 votes
AnswersHow would you merge two binary search tree's ?
- neshg May 16, 2012 in India
O(n) solution
Gave them a soln to do inorder traversal for both trees and merge the two sorted lists and create a tree out of the new list| Report Duplicate | Flag | PURGE
Walmart Labs Developer Program Engineer Algorithm - 0of 0 votes
AnswersInsert an element in a ordered (ascending) circular linked list. After inserting return the node with the smallest element.
- sai25590 April 11, 2012 in United States| Report Duplicate | Flag | PURGE
Walmart Labs Intern - 0of 0 votes
Answersthey asked some quesyion from fym :
- tomb February 16, 2012 in India
a horse is in chessboard. given its x,y find the probability through program that it will remain in board after n moves.| Report Duplicate | Flag | PURGE
Walmart Labs - 0of 0 votes
Answerswrite algo for longest palindrome?
- tomb February 16, 2012 in India| Report Duplicate | Flag | PURGE
Walmart Labs Developer Program Engineer Algorithm - 0of 0 votes
Answersfind square root of a number upto given precision value
- gn.srinadh January 08, 2012 in India| Report Duplicate | Flag | PURGE
Walmart Labs Software Engineer / Developer Algorithm