IBM Interview Questions
- 0of 0 votes
AnswerYou and your friend go to a game arcade where you choose to play the lucky pick game. In the game,
- Pooja August 09, 2017 in India
there is a square grid and on each block some money is placed on it. When a player chooses a block, the
machine randomly chooses a block from the available neighboring and the chosen block (consider 8
neighborhood). The player is awarded the money that is placed on the block that the machine selects.
Your friend needs help choosing the block.
Your job is to return the block position(s) that will maximize the minimum amount your friend will win
for sure. If there are more than one such block positions, then output must return all these positions.
Input Format
You will be given a single input representing the Grid Description (in the form of string array)
(N rows each containing N numbers separated by '#', each number representing the amount of money
put on that block)
Output Format
You need to return the array of string containing the position(s) of a block choosing which will give the
maximum amount of money which your friend will definitely win.
Sample Test Case 1
Sample Input
3 12#45#33 94#54#23 98#59#27
Sample Output
3#1
Explanation: In the above example, if he selects the block (3,1), then under the best case, he could win is
98 and under the worst case the maximum he could win is 54. In such scenario, the worst case of block
(3,1) gives your friend more money than the worst case of other blocks.
Sample Test Case 2
Sample Input 4
12#45#33#27
94#54#23#53
98#59#27#62
11#51#67#13
Sample Output
1#3
1#4
2#3
2#4
Explanation
Note: If the output array contains multiple strings(block's positions), all the positions must be in the
row-wise traversal order. In Example 2, the output is {1 #3,1#4,2#3,2#4}. If your function is returning an
array that has same elements (block's position) but in the different order, then the output array will be
incorrect.
Function to implement:
public static String[] amount_value(String[] input1){
//implement your logic
}| Report Duplicate | Flag | PURGE
IBM Java Developer - 1of 1 vote
AnswersProgramming Challenge Description:
- abhinav.thegame October 17, 2016 in United States
Develop a service to help a client quickly find a manager who can resolve the conflict between two employees. When there is a conflict between two employees, the closest common manager should help resolve the conflict. The developers plan to test the service by providing an example reporting hierarchy to enable the identification of the closest common manager for two employees. Your goal is to develop an algorithm for IBM to efficiently perform this task. To keep things simple, they just use a single relationship "isManagerOf" between any two employees. For example, consider a reporting structure represented as a set of triples:
Tom isManagerOf Mary
Mary isManagerOf Bob
Mary isManagerOf Sam
Bob isManagerOf John
Sam isManagerOf Pete
Sam isManagerOf Katie
The manager who should resolve the conflict between Bob and Mary is Tom(Mary's manager). The manager who should resolve the conflict between Pete and Katie is Sam(both employees' manager). The manager who should resolve the conflict between Bob and Pete is Mary(Bob's manager and Pete's manager's manager).
Assumptions:
There will be at least one isManagerOf relationship.
There can be a maximum of 15 team member to a single manager
No cross management would exist i.e., a person can have only one manager
There can be a maximum of 100 levels of manager relationships in the corporation
Input:
R1,R2,R3,R4...Rn,Person1,Person2 R1...Rn - A comma separated list of "isManagerOf" relationships. Each relationship being represented by an arrow "Manager->Person". Person1,Person2 - The name of the two employee that have conflict
Output:
The name of the manager who can resolve the conflict Note: Please be prepared to provide a video follow-up response to describe your approach to this exercise.
Test 1:
Test Input
Frank->Mary,Mary->Sam,Mary->Bob,Sam->Katie,Sam->Pete,Bob->John,Bob,Katie
Expected Output
Mary
Test 2:
Test Input
Sam->Pete,Pete->Nancy,Sam->Katie,Mary->Bob,Frank->Mary,Mary->Sam,Bob->John,Sam,John
Expected Output
Mary| Report Duplicate | Flag | PURGE
IBM Software Engineer / Developer Coding Java Python String Manipulation - 0of 0 votes
AnswersThis questing was something related to parse trees. I really don't remember the semantics but needed to extract the complete sentences from the provided parse tress.
- abhinav.thegame October 13, 2016 in United States
Input: A full sentence: (S (NP (NNP James)) (VP (VBZ is) (NP (NP (DT a) (NN boy)) (VP (VBG eating) (NP (NNS sausages))))))
Output: James is a boy eating sausages
Input: (NNS Sausages)
Output: Sausages
Input: (NP(DT a) (NN boy))
Output: a boy| Report Duplicate | Flag | PURGE
IBM Software Engineer / Developer Java - -1of 1 vote
AnswersFor a given string sentence, reverse it.
- abhinav.thegame October 13, 2016 in United States
Input : Hello World
Output : Dlorw Olleh
Input: How Are You Doing Today
Output: Yadot Ginod Uoy Era Woh| Report Duplicate | Flag | PURGE
IBM Software Engineer / Developer Java - 0of 0 votes
AnswersYou will be given a sequence of passages, and must filter out any passage whose text (sequence of whitespace-delimited words) is wholly contained as a sub-passage of one or more of the other passages.
- abhinav.thegame October 13, 2016 in United States
When comparing for containment, certain rules must be followed:
The case of alphabetic characters should be ignored
Leading and trailing whitespace should be ignored
Any other block of contiguous whitespace should be treated as a single space
non-alphanumeric character should be ignored, white space should be retained
Duplicates must also be filtered - if two passages are considered equal with respect to the comparison rules listed above, only the shortest should be retained. If they are also the same length, the earlier one in the input sequence should be kept. The retained passages should be output in their original form (identical to the input passage), and in the same order.
Input: For each test case a single line comprising the passages (strings) to be processed, delimited by | characters. The | characters are not considered part of any passage.
Output: A single line of filtered passages in the same |-delimited format.
Input1: IBM cognitive computing|IBM "cognitive" computing is a revolution| ibm cognitive computing|'IBM Cognitive Computing' is a revolution?
Output1: IBM "cognitive" computing is a revolution
Input2: IBM cognitive computing|IBM "cognitive" computing is a revolution|the cognitive computing is a revolution
Output2: IBM "cognitive" computing is a revolution|the cognitive computing is a revolution| Report Duplicate | Flag | PURGE
IBM Software Engineer / Developer Java - 6of 6 votes
AnswersGiven a non-directed, strongly connected graph where the node values are letters of the alphabet, write an algorithm that prints out all possible permutations of strings. What is this called?
- william.brandon.lee83 January 18, 2016 in United States
For example:
V = A,B,C
Printout
ABC
ACB
BAC
BCA
CAB
CBA
BAC etc.| Report Duplicate | Flag | PURGE
IBM Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven a sorted integer array, write a method that builds a balanced binary search tree. What is the runtime complexity?
- william.brandon.lee83 January 18, 2016 in United States
Hint: Recursion.
Follow-up: Non-recursive solution| Report Duplicate | Flag | PURGE
IBM Software Engineer / Developer Algorithm - 0of 0 votes
AnswersWhat design pattern you will use in this scenario :
- linardni June 09, 2015 in India
One class will print odd numbers and other class will print even numbers.| Report Duplicate | Flag | PURGE
IBM Tech Lead C++ - -1of 1 vote
AnswersPrint a singly linked list in ascending and descending order in O(n) time. Both order printing should take O(n) time only.
- linardni June 09, 2015 in India| Report Duplicate | Flag | PURGE
IBM Tech Lead Data Structures - 0of 0 votes
AnswersFollowing code is used by ONE producer and ONE consumer
- Karrie November 26, 2013 in India
public void Produce(queue<int> queue, ManualResetEvent mre){
while(true){
lock(queue){
queue.enque(3);
}
mre.set();
}
}
public void Consume(queue<int> queue, ManualResetEvent mre){
while (true){
mre.Reset();
if (queue.Count == 0)
mre.WaitOne();
lock(Queue){
var x = queue.Dequeue();
}
}
}
the last code line causes error, queue is empty-
"var x = queue.Dequeue();"
they asked me to suggest a fix for that.| Report Duplicate | Flag | PURGE
IBM Software Engineer / Developer Threads - 0of 0 votes
AnswersUsing two threads you should print "Hello World Hello World Hello World Hello World Hello World Hello World ".
- PCB March 05, 2013 in India for ISL
In two threads one should print "Hello: and another thread "World".| Report Duplicate | Flag | PURGE
IBM Developer Program Engineer Java - 0of 0 votes
AnswersFind whether there is a loop in a given liked list or no?
- PCB March 05, 2013 in India for ISL
Solved it using two pointer. He wanted me to prov using mathematics, which I don't know :(.| Report Duplicate | Flag | PURGE
IBM Developer Program Engineer Algorithm - 0of 0 votes
Answerswhat is use of command line argument in software development.
- rohit March 01, 2013 in India
give any real example where we must use command line argrment (for ex- any system software,application software etc)| Report Duplicate | Flag | PURGE
IBM Software Development Manager Java - 0of 2 votes
AnswersWe Have 5 balls And We have to find it out in 2 ways that which 1 is havier or lesser..
- jain.saurabh241990 February 27, 2013 in India for FRESHER| Report Duplicate | Flag | PURGE
IBM Developer Program Engineer Brain Teasers - 2of 2 votes
AnswersYou are given an array of size N containing negative and positive real numbers. Zero may or may not be present in the array. The requirement is to rearrange the array using O(N) time and O(1) space so that all negative numbers come before all positive elements. Develop a program to read a real number array of size N from user, and then arrange it as explained above.
- rohit February 22, 2013 in India
Constraints :
(i) The value of N has to be read from user, and the memory for array has to be allocated dynamically. The real numbers will be also read from user. The menu-driven program should also have an option to populate the array with random data, if the user wants to do so.
(ii) A maximum of 3 passes allowed over the entire array. O(N) time expected.
(iii) O(1) extra space permitted – creating copy of array etc not allowed.
(iv) Program must work properly even if zero is NOT present in array.| Report Duplicate | Flag | PURGE
IBM Software Engineer in Test - 2of 2 votes
AnswersGiven a monotonically sorted 2D array, explain an algorithm to search for a given input element.
- maytas92@yahoo.com February 11, 2013 in United States
A monotonically sorted array is one in which each row and column has elements in ascending order.
E.g. [ 1 2 10; 4 6 11; 5 7 12;] and [1 2 5; 4 6 7; 10 12 13] are both monotonically sorted.| Report Duplicate | Flag | PURGE
IBM Software Engineer / Developer Algorithm - 0of 0 votes
AnswersPrint in spiral form as shown below
- umang.1rn09cs116 November 23, 2012 in India for Development
For n=2
3 2
0 1
For n=3
4 3 2
5 0 1
6 7 8
For n=4
15 14 13 12
4 3 2 11
5 0 1 10
6 7 8 9| Report Duplicate | Flag | PURGE
IBM Intern Coding - 0of 0 votes
AnswersDesign Solar System
- R@M3$H.N October 01, 2012 in India for ISL| Report Duplicate | Flag | PURGE
IBM Software Engineer / Developer C++ Application / UI Design - 0of 0 votes
AnswersWhen singleton wont work as singleton??
- sarthakiter July 17, 2012 in India| Report Duplicate | Flag | PURGE
IBM Developer Program Engineer Java - 0of 0 votes
AnswerWhat is a weakHashMap??weak References??
- sarthakiter July 17, 2012 in India
xplain with example| Report Duplicate | Flag | PURGE
IBM Developer Program Engineer Java - 0of 0 votes
AnswerWhat is a Executer in threads??
- sarthakiter July 17, 2012 in India| Report Duplicate | Flag | PURGE
IBM Developer Program Engineer Threads - 2of 2 votes
AnswersWrite a program to find out if the binary tree is balance or not. The tree is balance if the difference between the
- india.tp.1976 January 21, 2012 in United States
left node and right node is equal or less than 1. The above considition is applicable for subtree too..
If tree do not have any child, its height will be zero.
What is the order of above program| Report Duplicate | Flag | PURGE
IBM Accountant Algorithm - 0of 0 votes
AnswersWrite a program to find out the height of the tree. Tree can have two node (one is left and right node).
- india.tp.1976 January 21, 2012 in United States
If tree do not have any child, its height will be zero.
What is the order of above program| Report Duplicate | Flag | PURGE
IBM Accountant Algorithm - -1of 1 vote
Answers1) Write a iterative program to calculate factorial of N.
- india.tp.1976 January 20, 2012 in United States
2) what is the order of above program
3) Write a recursive program to calculate factorial of N.
4) what is the order of above program| Report Duplicate | Flag | PURGE
IBM Accountant Algorithm - 0of 0 votes
Answerscome up with a solution, where u r given a single pointer in a single link list and u shoudl be able to return (+/-)nth node from it.
My solution:list * returnN (list *node, int n) { if (n>0) { traverse and reverse list from node to nth node } else { traverse and negatereverse from node till nth node }
he asked for algo only, so this worked fine.
- Varun November 09, 2011 in India
eg list=1->2->3->4->5
returnN(1, 3)
output 4
list=1<-2<-3<-4->5
returnN(4, -2)
output 2
list: 1<-2->3->4->5
Any other suggestions??| Report Duplicate | Flag | PURGE
IBM Software Engineer / Developer Algorithm - -1of 1 vote
AnswersHow can make Mutex global to All CPUs in your Board? Because spinlock is global to all CPUs in SMP system. Just make Mutex work like spinlock?
- MLakshmana Rao August 03, 2011| Report Duplicate | Flag | PURGE
IBM Software Engineer / Developer Linux Kernel - -1of 1 vote
Answerssort three numbers without inserting them onto array(dont use stl container) ? What about 4 numbers?
- Anonymous July 15, 2011| Report Duplicate | Flag | PURGE
IBM - 0of 0 votes
Answerswhat is virtual overloading?
- khushboo taneja July 15, 2011| Report Duplicate | Flag | PURGE
IBM Developer Program Engineer C++ - 0of 0 votes
Answeruse of arrays?
- khushboo taneja July 15, 2011| Report Duplicate | Flag | PURGE
IBM Developer Program Engineer C