Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding
Ninjas X Naukri.com

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

IBM

2 rounds | 4 Coding
problems

Journey

When I joined college, I was unaware of this Data Structure and Algorithm, which made my journey to getting an internship way more complicated. From that point, I started doing questions on leetcode and code studio.

Application story

This company visited to my campus for the selection they first took a test then allow us to come for the interview.

Why selected/rejected for the role?

I was rejected because I have a good history of content preparation and i do not have a decent rank in leetcode and code forces. ,

Preparation

Duration: 3 Months

Topics: Data Structures, Pointers, OOPS, System Design, Algorithms, Dynamic Programming

Tip

Tip 1 : Practice from Leetcode, solve Leetcode medium level problems.

Tip 2 : Brush up computer fundamentals from subjects like OS, DBMS and CN.

Tip 3 : Have a good project or good internship experience and have in-depth knowledge regarding what you have done.

Application process

Where: Campus

Eligibility: No criteria

Resume tip

Tip 1 : Have some projects on resume.

Tip 2 : Do not put false things on resume

01

Round

Easy

Video Call

Duration60 Minutes

Interview date5 Jan 2023

Coding problem2

```
Can you solve each query in O(logN) ?
```

Problem approach

"Search in Rotated Sorted Array" is a problem that involves finding the index of a target value in a rotated sorted array. The input array is sorted in ascending order and then rotated by some unknown number of positions to the right or left. The task is to find the index of the target value in the array, or return -1 if the target value is not found.

Problem approach

Tree symmetry, also known as tree isomorphism or tree symmetry, refers to the property of two trees having the same structure or shape, even if their node values may be different. In other words, two trees are considered symmetric if they can be obtained from each other by swapping their left and right subtrees, or by reflecting them along their root node.

02

Round

Hard

Video Call

Duration60 Minutes

Interview date5 Jan 2023

Coding problem2

Problem approach

The "Colourful Knapsack Problem" is a variation of the classical "Knapsack Problem", which is a combinatorial optimization problem. In the Colourful Knapsack Problem, the items that can be selected for inclusion in the knapsack have colors associated with them, and the objective is to maximize the total value of the items in the knapsack subject to the constraint of the knapsack's capacity, while also ensuring that no two items of the same color are selected.

Given a building with k floors and m identical eggs, what is the minimum number of trials required to determine the highest floor from which an egg can be dropped without breaking?

Assumptions:

The eggs are identical and have the same properties.

If an egg breaks when dropped from a certain floor, it will also break when dropped from any higher floor.

If an egg does not break when dropped from a certain floor, it will not break when dropped from any lower floor.

The goal is to minimize the number of trials required to determine the highest floor with the given number of eggs.

Problem approach

The Egg Dropping Puzzle can be solved using dynamic programming. The key idea is to consider all possible dropping strategies and choose the one that minimizes the number of trials required.

Let's define a 2D array dp[i][j], where dp[i][j] represents the minimum number of trials required to determine the highest floor with i floors and j eggs.

We can start with a base case:

If there is only one floor, then we need to drop the egg from that floor, and it will either break or not break. So dp[1][j] = 1 for all j (since we need at least one trial to determine the result).

Then we can use the following recurrence relation to fill in the rest of the array dp[i][j]:

For each floor i from 2 to k, and each number of eggs j from 1 to m, we can consider dropping the egg from each floor k one by one and choose the strategy that minimizes the number of trials.

For each floor k, we have two possibilities:

If the egg breaks when dropped from floor k, we need to continue with j-1 eggs and search in the lower floors (1 to k-1). So we need dp[k-1][j-1] trials.

If the egg does not break when dropped from floor k, we need to continue with j eggs and search in the upper floors (k+1 to i). So we need dp[i-k][j] trials.

We need to consider the worst case (maximum number of trials) among these two possibilities, and add 1 to account for the current trial from floor k.

Therefore, the recurrence relation can be defined as: dp[i][j] = min(max(dp[k-1][j-1], dp[i-k][j]) + 1) for k in range(1, i).

Finally, the minimum number of trials required to determine the highest floor with m eggs can be found at dp[k][m], where k is the smallest value such that dp[k][m] >= i.

This dynamic programming approach has a time complexity of O(k^2 * m), as we need to fill in a 2D array of size k x m. There are also optimized solutions using binary search and other techniques to reduce the time complexity further.

Here's your problem of the day

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

Suppose list1 is [2, 133, 12, 12], what is max(list1) in Python?

Choose another skill to practice

Start a Discussion

Similar interview experiences

Associate Software Engineer

3 rounds | 11 problems

Interviewed by IBM

2069 views

0 comments

0 upvotes

Associate Software Engineer

4 rounds | 4 problems

Interviewed by IBM

1540 views

0 comments

0 upvotes

Staff Engineer

3 rounds | 4 problems

Interviewed by IBM

3848 views

0 comments

0 upvotes

MEAN Stack Developer

4 rounds | 6 problems

Interviewed by IBM

214 views

0 comments

0 upvotes

Companies with similar interview experiences

Associate Software Engineer

3 rounds | 10 problems

Interviewed by Amdocs

1888 views

0 comments

0 upvotes

Associate Software Engineer

3 rounds | 4 problems

Interviewed by Amdocs

1390 views

0 comments

0 upvotes

Associate Software Engineer

3 rounds | 5 problems

Interviewed by Optum

1329 views

0 comments

0 upvotes