Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
OYO interview experience Real time questions & tips from candidates to crack your interview

SDE - Intern

OYO
upvote
share-icon
3 rounds | 6 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 6 months
Topics: Data Structures, Algorithms, Dynamic Programming, Machine Learning, OOPS
Tip
Tip

Tip 1 : Primary skill to be developed is problem solving, i.e proficient in data structures and algorithms.
Tip 2 : After this, practice competitive programming, start giving contests, this will make you faster.
Tip 3 : Then take any technology, e.g., machine learning, web development etc., make few but good projects using these technologies.

Application process
Where: Campus
Eligibility: Above 6.45 CGPA
Resume Tip
Resume tip

Tip 1 : Make it short, 1-2 pages max. Only mention those projects that you know the best.
Tip 2 : While mentioning projects, do mention numbers in them, like what was the accuracy(in case of ML projects).

Interview rounds

01
Round
Medium
Online Coding Interview
Duration90 minutes
Interview date11 Nov 2020
Coding problem2

The test was scheduled at 2:30 PM, IST. The test was conducted online, due to the ongoing pandemic situation. Webcam was required to be switched on during the complete duration of the test. I had solved 2/2 coding questions with all test cases successfully passing. Out of the 10 MCQ questions, I had done 6. Around 90 students sat for the online coding round, 19 were shortlisted for the interview. Those who had solved both coding questions were called for interview.

1. Candies

Moderate
10m average time
90% success
0/80
Asked in companies
Goldman SachsOYOFlipkart

Prateek is a kindergarten teacher. He wants to give some candies to the children in his class. All the children stand in a line and each of them has a grade according to his or her performance in the class. Prateek wants to give at least one candy to each child. If two children are standing adjacent to each other, then the one with the higher rating must get more candies than the other. Prateek wants to minimize the total number of candies he must buy.

Given an array 'STUDENTS' of size 'N' that contains the grades for each student, your task is to find what is the minimum number of candies Prateek must buy so that he can distribute them among his students according to the criteria given above.

Example :

Given students' ratings : [5, 8, 1, 5, 9, 4]. 
He gives the students candy in the following minimal amounts : [1, 2, 1, 2, 3, 1]. He must buy a minimum of 10 candies.

Note :

1. If two students having the same grade are standing next to each other, they may receive the same number of candies.
2. Every student must get at least a candy.
Problem approach

Step 1: Since we had to see adjacent students' marks, and then decide the candy to be given, dynamic programming struck my mind.
Step 2: We need to look in both sides, left as well as right. So I constructed an array, say left, in the first traversal.

 

Try solving now

2. Min cost to reach N

Easy
10m average time
90% success
0/40
Asked in companies
OYOSquadstackFlipkart

Ninja Yuki is in the mood of shopping ninja blades today, and why should he not be, its finally the time for the Spring Fair in his Village. Initially, he has 0 number of blades and aims to buy ‘N’ of them from the fair. But the blade shopkeeper being a cunning man himself, presents a weird way of pricing the number of ninja blades Yuki can buy.

Suppose at any instance Yuki has ‘K’ number of blades, then:

1) Yuki can buy 1 more blade with cost 'A.’ He now has ‘K+1’ Ninja blades.
2) Yuki could buy a ‘K’ number of blades with cost 'B.’ He now has ‘2*K’ blades.
where 'A' and 'B' are predefined and constant.

Yuki does not want to get robbed in the fair. Being his nerd friend can you tell him the minimum price he needs to pay to buy exactly ‘N’ ninja blades, considering he has 0 blades initially?

Note:

There can be two or more ways with the exact cost. You can consider any one of them, but the overall cost to reach from 0 to 'N' must be minimized.

For example:

Consider Yuki need to buy 5 blades, the cost of adding 1 blade is 2, and the cost of doubling the blades is 1 then you have to perform the following operations:
1) Doubling 0 will result in 0 only, so add 1 blade to 0 blades with cost 2. Total cost becomes 2.

2) Next, you can either double 1 to reach 2 or add 1 blade. But since the cost of doubling is less than that of adding, so double 1 with cost 1. Total cost becomes 3.

3) Doubling 2 will result in 4 with a cost of 1. Total becomes 4.

4) Adding 1 in 4 will result in 5 (which is the desired number) with a cost of 2. The total cost to reach 5 becomes 6.
Problem approach

This was a simple DP based problem. Construct a DP array of size n+1. And fill the array as follows:
For i between 2 to n:
1). If i is even: then we can reach that i by two ways, one is by adding 1 to i-1, another by doubling i/2, and add their respective costs.
Therefore, dp[i] = min(dp[i-] + A, dp[i/2] + B);
2). If i is odd. This is a bit tricky, one option is adding one to i-1. Since this is not an even no. so we cant divide it by 2.
The approach is to add one to i, now it will be an even no, and now we can find dp[(i+1)/2], since now its even.
Therefore, dp[i] = min(dp[i-1] + A, dp[(i+1)/2] + A + B);

Try solving now
02
Round
Medium
Video Call
Duration60 minutes
Interview date18 Nov 2020
Coding problem2

This was a pure DSA based round. Two questions were asked in this round. The interviewer was quite good, and helped in between.

1. First Unique Character in a String

Moderate
15m average time
80% success
0/80
Asked in companies
OYOAmdocs

You are given a string A consisting of lower case English letters. You have to find the first non-repeating character from each stream of characters.

For Example: If the given string is 'bbaca', then the operations are done as:

The first stream is “b” and the first non-repeating character is ‘b’ itself, so print ‘b’. 
The next stream is “bb” and there are no non-repeating characters, so print nothing.
The next stream is “bba” and the first non-repeating character is ‘a’, so print ‘a’. 
The next stream is “bbac” and the first non-repeating character is ‘a’, so print ‘a’. 
The next stream is “bbaca” and the first non-repeating character is ‘c’, so print ‘c’. 
Problem approach

I had solved this question earlier, thanks to Coding Ninja's Codezen. I was able to give the optimised solution. I used the concept of deque. The question was based on the concept of sliding window.

Try solving now

2. Boolean Matrix

Moderate
35m average time
60% success
0/80
Asked in companies
OYOUberAmazon

Given a 2-dimensional boolean matrix mat of size N x M, modify the matrix such that if an element is 1, set its entire row and column to 1 i.e. if mat[i][j] = 1, then make all the elements of the ith row and the jth column as 1.

Note :
You need to make the modifications in the input matrix.

You do not need to print anything, it has already been taken care of. 
Problem approach

I started with the naive approach. I suggested storing the location of all 1s in an array. Then traverse over this array and make required changes in the matrix.
The interviewer asked me to optimise it further. I suggested, when we encounter a one, start making changes in the matrix as: if m[i][j] is 0 then change it to 1, else change the value to -1, so that we know a 1 was present here and change its respective column to 1 when we arrive there.
He further asked me to optimise it, I wasn't able to think of a solution, though he seemed satisfied with the discussion we had.

Try solving now
03
Round
Medium
Video Call
Duration75 minutes
Interview date18 Nov 2020
Coding problem2

This round was also again focused on DSA. Two interviewers were present. This round was very extensive and everything was asked in depth as well as they asked to write the codes as well for all the questions. I was also asked to explain my projects, they were based on ML. Many aspects of OOPs, POP, memory allocation was asked as well.

1. Maximum sum of (i*Arr[i]) among all possible rotations of an array.

Moderate
15m average time
85% success
0/80
Asked in companies
OYOAppleMakeMyTrip

You are given an array 'ARR' consisting of 'N' elements, and you need to find the maximum value of sum(i * ARR[i]) among all possible rotations of the given array. The rotations allowed are left rotation, and right rotation, and these rotations can be performed any number of times on the array.

Sum(i * ARR[i]) denotes the summation of all values (i * ARR[i]) for every 'i', where 0 <= 'i' <= 'N' - 1.

Note :

1. The array follows 0-based indexing.
2. In one rotation operation, all elements of the array will shift either towards the left or right by one index.
3. The element at the extreme left index (i.e. 0th index) will shift to the 'N-1'th index after applying one left rotation on the array and the rest all the elements will shift to the 'i-1'th index.
4. The element at the extreme right index (i.e. 'N-1'th index) will shift to the 0th index after applying one right rotation on the array and the rest of the elements will shift to the 'i' + 1'th index.
Problem approach

first found the value of f(0). Now what we need to do is assign last element the index 0, then in next iteration, the 2nd last element as index 0 and last as index 1.
So i ran a loop from 1 to n, and i in each iteration, the last i elements were assigned indices starting from 0. After that, continuing from the last index that was assigned to the last element, we start picking elements from the start.
Sum these values and calculate the maximum over all of them.

Try solving now

2. Averages of Levels in Binary Tree

Easy
15m average time
85% success
0/40
Asked in companies
OYOInfosysJFrog

You are given an arbitrary binary tree consisting of 'N' nodes numbered from 1 to 'N', and each node is associated with some positive integer value. Your task is to find the average of all the levels in the given tree, i.e you have to find the average of all the node values present on the level, for each level.

Two nodes of a tree are said to be at the same level ‘K’ if both of them are at equal distance( 'K' ) from the 'ROOT' node. The 'ROOT' node is said to be at level 0.

Note :

1. Two nodes may have the same value associated with it.
2. Average of any level is computed as the sum of the values of all the nodes at that level divided by the number of nodes at that level.
3. You will be given the 'ROOT' node of the binary tree.
4. You need to print the floor value for each average. For example,  if the average of node values at some level is 3.5 then you have to print 3.
Problem approach

This was a simple BFS traversal problem. I was also asked to write the code for the same. I was able to code it successfully.

Try solving now

Here's your problem of the day

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

What does ROLLBACK do in DBMS?

Start a Discussion
Similar interview experiences
company logo
SDE - Intern
3 rounds | 10 problems
Interviewed by OYO
881 views
0 comments
0 upvotes
company logo
SDE - Intern
3 rounds | 3 problems
Interviewed by OYO
1435 views
0 comments
0 upvotes
company logo
SDE - Intern
1 rounds | 2 problems
Interviewed by OYO
861 views
0 comments
0 upvotes
company logo
SDE - Intern
3 rounds | 4 problems
Interviewed by OYO
816 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - Intern
3 rounds | 6 problems
Interviewed by Amazon
13227 views
4 comments
0 upvotes
company logo
SDE - Intern
4 rounds | 7 problems
Interviewed by Microsoft
12230 views
1 comments
0 upvotes
company logo
SDE - Intern
2 rounds | 4 problems
Interviewed by Amazon
8837 views
2 comments
0 upvotes