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

SDE - 1

Milkbasket
upvote
share-icon
2 rounds | 4 Coding problems

Interview preparation journey

expand-icon
Journey
I participated actively in our college in various coding competitions and practised a lot of Questions on various competitive programming sites. Although I got placed very early during college time so was not allowed in other companies so kept working hard for various off-campus opportunities available.
Application story
Milkbasket visited our campus for hiring. I applied for it passed the preliminary test and moved to the interview rounds.
Why selected/rejected for the role?
Rejected, they had a fixed number to take so maybe they found some better resource that met their company requirements.
Preparation
Duration: 8 months
Topics: Data Structures, Pointers, OOPS, System Design, Algorithms, Computer Networking, Object Oriented Programming, ML
Tip
Tip

Tip 1: Never leave any topic from any chapter/subject.

Tip 2: Learn to explain your thoughts well.

Tip 3: Learn from previous experiences/interviews/problems asked.

Tip 4: Include at least four projects on your resume.

Application process
Where: Campus
Eligibility: CGPA 6.00 and above with no active backlog(s) and pursuing a regular semester.
Resume Tip
Resume tip

Tip 1: Include at least four projects on your resume. 

Tip 2: Do not write false information. You will always get caught. Be genuine.

Interview rounds

01
Round
Easy
Video Call
Duration60 minutes
Interview date9 May 2022
Coding problem2

Simple DSA round taken by a very supportive interviewer. He asked about two DSA problems.

1. Maximum Product Subarray

Moderate
25m average time
75% success
0/80
Asked in companies
InnovaccerAmazonMicrosoft

You are given an array “arr'' of integers. Your task is to find the contiguous subarray within the array which has the largest product of its elements. You have to report this maximum product.

An array c is a subarray of array d if c can be obtained from d by deletion of several elements from the beginning and several elements from the end.

For e.g.- The non-empty subarrays of an array [1,2,3] will be- [1],[2],[3],[1,2],[2,3],[1,2,3]. 
For Example:
If arr = {-3,4,5}.
All the possible non-empty contiguous subarrays of “arr” are {-3}, {4}, {5}, {-3,4}, {4,5} and {-3,4,5}.
The product of these subarrays are -3, 4, 5, -12, 20 and -60 respectively.
The maximum product is 20. Hence, the answer is 20.
Follow Up:
Can you solve this in linear time and constant space complexity?
Problem approach

The code defines a function named maxSubarrayProduct that takes an integer array A and its size n as arguments.
It initializes a variable r with the first element of the array A. This variable will store the maximum subarray product found so far.
The function then enters a loop that starts from the second element of the array A and goes up to the last element.
Inside the loop, the function initializes two variables imax and imin with the value of r. These variables will store the maximum and minimum product of subarrays that end with the current number A[i].
If the current number A[i] is negative, the function swaps imax and imin. This is because multiplying a negative number with a maximum product will give a minimum product and vice versa.
The function then calculates the maximum and minimum product of subarrays that end with the current number A[i]. It does this by taking the maximum and minimum of either the current number A[i] or the maximum and minimum product of subarrays that end with the previous number times the current number.
The function then updates the value of r to the maximum of r and imax. This is because the newly computed maximum value is a candidate for the global maximum subarray product.
After the loop ends, the function returns the value of r.
The code defines a main function that initializes an array arr with some values, calls the maxSubarrayProduct function passes the array and its size as arguments, and then prints the result to the console.
The program then exits with a status of 0.

Try solving now

2. Reverse Linked List

Moderate
15m average time
85% success
0/80
Asked in companies
GE (General Electric)Tata 1mgFreshworks

Given a singly linked list of integers. Your task is to return the head of the reversed linked list.

For example:
The given linked list is 1 -> 2 -> 3 -> 4-> NULL. Then the reverse linked list is 4 -> 3 -> 2 -> 1 -> NULL and the head of the reversed linked list will be 4.
Follow Up :
Can you solve this problem in O(N) time and O(1) space complexity?
Problem approach

Initialize three pointers prev as NULL, curr as head, and next as NULL.
Iterate through the linked list. In a loop, do the following:
Before changing the next of curr, store the next node 
next = curr -> next
Now update the next pointer of curr to the prev 
curr -> next = prev 
Update prev as curr and curr as next 
prev = curr 
curr = next

Try solving now
02
Round
Medium
Video Call
Duration80 minutes
Interview date10 May 2022
Coding problem2

This was a round to test your JAVA knowledge as I applied for this role. He asked me a lot of questions on JAVA and my past projects followed by 2 DSA questions.

1. Chocolate Problem

Moderate
15m average time
85% success
0/80
Asked in companies
AdobePaytm (One97 Communications Limited)JP Morgan

Given an array/list of integer numbers 'CHOCOLATES' of size 'N', where each value of the array/list represents the number of chocolates in the packet. There are ‘M’ number of students and the task is to distribute the chocolate to their students. Distribute chocolate in such a way that:

1. Each student gets at least one packet of chocolate.

2. The difference between the maximum number of chocolate in a packet and the minimum number of chocolate in a packet given to the students is minimum.

Example :

Given 'N' : 5 (number of packets) and 'M' : 3 (number of students)

subsequence

And chocolates in each packet is : {8, 11, 7, 15, 2}

All possible way to distribute 5 packets of chocolates among 3 students are -

( 8,15, 7 ) difference of maximum-minimum is ‘15 - 7’ = ‘8’
( 8, 15, 2 ) difference of maximum-minimum is ‘15 - 2’ = ‘13’ 
( 8, 15, 11 ) difference of maximum-minimum is ‘15 - 8’ = ‘7’
( 8, 7, 2 ) difference of maximum-minimum is ‘8 - 2’ = ‘6’
( 8, 7, 11 ) difference of maximum-minimum is ‘11 - 7’ = ‘4’
( 8, 2, 11 ) difference of maximum-minimum is ‘11 - 2’ = ‘9’
( 15, 7, 2 ) difference of maximum-minimum is ‘15 - 2’ = 13’
( 15, 7, 11 ) difference of maximum-minimum is ‘15 - 7’ = ‘8’
( 15, 2, 11 ) difference of maximum-minimum is ‘15 - 2’ = ‘13’
( 7, 2, 11 ) difference of maximum-minimum is ‘11 - 2’ = ‘9’

Hence there are 10 possible ways to distribute ‘5’ packets of chocolate among the ‘3’ students and difference of combination (8, 7, 11) is ‘maximum - minimum’ = ‘11 - 7’ = ‘4’ is minimum in all of the above.
Problem approach

Initially sort the given array. Declare a variable to store the minimum difference, and initialize it to INT_MAX. Let the variable be min_diff.
Find the subarray of size m such that the difference between the last (maximum in case of sorted) and first (minimum in case of sorted) elements of the subarray is minimum.
We will run a loop from 0 to (n-m), where n is the size of the given array and m is the size of the subarray.
We will calculate the maximum difference with the subarray and store it in diff = arr[highest index] – arr[lowest index]
Whenever we get a diff less than the min_diff, we will update the min_diff with diff.

Try solving now

2. Next Greater Element

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

You are given an array 'a' of size 'n'.



The Next Greater Element for an element 'x' is the first element on the right side of 'x' in the array, which is greater than 'x'.


If no greater elements exist to the right of 'x', consider the next greater element as -1.


For example:
Input: 'a' = [7, 12, 1, 20]

Output: NGE = [12, 20, 20, -1]

Explanation: For the given array,

- The next greater element for 7 is 12.

- The next greater element for 12 is 20. 

- The next greater element for 1 is 20. 

- There is no greater element for 20 on the right side. So we consider NGE as -1.
Problem approach

Push the first element to stack.
Pick the rest of the elements one by one and follow the following steps in the loop. 
Mark the current element as next.
If the stack is not empty, compare top most element of the stack with the next.
If next is greater than the top element, Pop the element from the stack. next is the next greater element for the popped element.
Keep popping from the stack while the popped element is smaller than the next. next becomes the next greater element for all such popped elements.
Finally, push the next in the stack.
After the loop in step 2 is over, pop all the elements from the stack and print -1 as the next element for them.

Try solving now

Here's your problem of the day

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

Skill covered: Programming

Which collection class forbids duplicates?

Choose another skill to practice
Similar interview experiences
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by OYO
1446 views
0 comments
0 upvotes
SDE - 1
2 rounds | 5 problems
Interviewed by Meesho
3629 views
0 comments
0 upvotes
company logo
SDE - 1
3 rounds | 9 problems
Interviewed by Salesforce
942 views
0 comments
0 upvotes
company logo
System Engineer
2 rounds | 2 problems
Interviewed by Tata Consultancy Services (TCS)
737 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Amazon
107325 views
24 comments
0 upvotes
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
51681 views
5 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
32028 views
6 comments
0 upvotes