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

SDE - 2

Morgan Stanley
upvote
share-icon
4 rounds | 10 Coding problems

Interview preparation journey

expand-icon
Journey
Hello everyone! My name is Prerak Gupta, and I'm here to share my personal journey from starting with the basics to landing a job interview at Morgan Stanley as an SDE-2. I hope my story inspires and motivates you to pursue your dreams and learn from my experiences. I have always had a deep passion for technology and a strong desire to excel in the field of software development. My journey began when I enrolled in a computer science program at a reputable university. There, I focused on building a solid foundation in programming languages, algorithms, data structures, and software engineering principles. While my academic curriculum provided a strong base, I quickly realized that to stand out in the competitive job market, I needed to go beyond the classroom. I embarked on a journey of self-learning and practical application. I started by working on side projects and internships, seeking opportunities to gain hands-on experience and expand my skill set. Armed with a solid foundation, a diverse range of projects, and a well-rounded skill set, I began applying for job opportunities. I tailored my resume to highlight my relevant experiences and skills, showcasing my passion for technology and my ability to deliver results. I researched companies extensively, including Morgan Stanley, and prepared for technical interviews by practicing coding problems and refining my problem-solving strategies. After numerous rounds of interviews, I finally received an invitation for an interview at Morgan Stanley for the SDE-2 position. I dedicated myself to thorough preparation, studying the company's values, culture, and technical requirements. During the interview, I confidently demonstrated my technical expertise, problem-solving abilities, and my passion for technology. I focused on effective communication and showcased my potential as a valuable asset to the team.
Application story
I tailored my resume to highlight my relevant experiences and skills, showcasing my passion for technology and my ability to deliver results. I researched companies extensively, including Morgan Stanley, and prepared for technical interviews by practicing coding problems and refining my problem-solving strategies. After numerous rounds of interviews, I finally received an invitation for an interview at Morgan Stanley for the SDE-2 position.
Why selected/rejected for the role?
I want to emphasize that my journey is a testament to the power of passion, continuous learning, and a strong work ethic. By constantly seeking knowledge, gaining practical experience, and developing both technical and soft skills, I was able to secure a job interview and ultimately land a position at Morgan Stanley. I want to encourage each one of you to pursue your dreams with determination and dedication. With the right mindset and a commitment to learning, you too can achieve your goals.
Preparation
Duration: 3 months
Topics: Data Structures, Pointers, OOPS, System Design, Algorithms, Dynamic Programming
Tip
Tip

Tip 1 : Practice Atleast 250 Questions
Tip 2 : Do atleast 2 projects

Application process
Where: Campus
Eligibility: NO
Resume Tip
Resume tip

Tip 1 : Have some projects on resume.
Tip 2 : Keep resume short

Interview rounds

01
Round
Easy
Online Coding Test
Duration30 min
Interview date25 Apr 2023
Coding problem3

1. Largest Element in the Array

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

Given an array ‘arr’ of size ‘n’ find the largest element in the array.


Example:

Input: 'n' = 5, 'arr' = [1, 2, 3, 4, 5]

Output: 5

Explanation: From the array {1, 2, 3, 4, 5}, the largest element is 5.
Problem approach

Step 1: Initialize variables maxValue and minValue with the first element of the array.
Step 2: Iterate through the array starting from the second element. Update maxValue and minValue if a larger maximum or smaller minimum value is found.
Step 3: After the loop, the maxValue and minValue variables will contain the maximum and minimum elements of the array, respectively.

Try solving now

2. Check If The String Is A Palindrome

Easy
10m average time
90% success
0/40
Asked in companies
Tech MahindraHCL TechnologiesMorgan Stanley

You are given a string 'S'. Your task is to check whether the string is palindrome or not. For checking palindrome, consider alphabets and numbers only and ignore the symbols and whitespaces.

Note :

String 'S' is NOT case sensitive.

Example :

Let S = “c1 O$d@eeD o1c”.
If we ignore the special characters, whitespaces and convert all uppercase letters to lowercase, we get S = “c1odeedo1c”, which is a palindrome. Hence, the given string is also a palindrome.
Problem approach

Step 1: Remove all non-alphanumeric characters from the string and convert it to lowercase.
Step 2: Check if the modified string is equal to its reverse.

Try solving now

3. Pair Sum

Easy
15m average time
90% success
0/40
Asked in companies
OpenTextPhone PeGoogle

You are given an integer array 'ARR' of size 'N' and an integer 'S'. Your task is to return the list of all pairs of elements such that each sum of elements of each pair equals 'S'.

Note:

Each pair should be sorted i.e the first value should be less than or equals to the second value. 

Return the list of pairs sorted in non-decreasing order of their first value. In case if two pairs have the same first value, the pair with a smaller second value should come first.
Problem approach

Step 1: Create a dictionary to store the complement of each element (target minus the current element) as keys and their indices as values.
Step 2: Iterate through the array and check if the complement of the current element is in the dictionary. If found, return the indices of the two numbers.
Step 3: If no two numbers are found, return an empty list or a suitable message indicating that no solution exists

Try solving now
02
Round
Easy
Online Coding Test
Duration30 min
Interview date26 Apr 2023
Coding problem2

This interview held on 26 april 2023 and time was around 3 pm.

1. Count Triplets

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

You have been given an integer ‘X’ and a non-decreasing sorted doubly linked list with distinct nodes.

Your task is to return the number of triplets in the list that sum up to the value ‘X’.

Problem approach

Step 1: Sort the array in ascending order to easily handle duplicates and track unique triplets.
Step 2: Iterate through the array and for each element, use two-pointer technique to find the remaining two elements that sum up to the target.
Step 3: Return the list of unique triplets that add up to the target sum.

Try solving now

2. Maximum Path Sum Between Two Leaves

Hard
50m average time
35% success
0/120
Asked in companies
FlipkartAmazonMicrosoft

You are given a non-empty binary tree where each node has a non-negative integer value. Return the maximum possible sum of path between any two leaves of the given tree.

The path is also inclusive of the leaf nodes and the maximum path sum may or may not go through the root of the given tree.

If there is only one leaf node in the tree, then return -1.

Problem approach

Step 1: Define a helper function to calculate the maximum path sum for each subtree.
Step 2: Call the helper function on the root of the binary tree to calculate the maximum path sum.
Step 3: Return the maximum path sum stored in the max_sum variable.

Try solving now
03
Round
Easy
Online Coding Test
Duration30 min
Interview date26 Apr 2023
Coding problem3

this round was also held on 26 april 2023, and this round was around 5 pm.

1. Balanced parentheses

Moderate
10m average time
90% success
0/80
Asked in companies
SalesforceOLX GroupBig Basket

Given an integer ‘N’ representing the number of pairs of parentheses, Find all the possible combinations of balanced parentheses with the given number of pairs of parentheses.

Note :

Conditions for valid parentheses:
1. All open brackets must be closed by the closing brackets.

2. Open brackets must be closed in the correct order.

For Example :

()()()() is a valid parentheses.
)()()( is not a valid parentheses.
Problem approach

In this implementation, we iterate over each character in the input string. If the character is an opening parenthesis, we push it onto the stack. If the character is a closing parenthesis, we check if the stack is empty or if the corresponding opening parenthesis matches the last opening parenthesis on the stack. If there is a match, we continue. If there is no match or the stack is empty, we return False. After iterating through the entire string, we check if there are any remaining opening parentheses on the stack. If the stack is empty, we return True; otherwise, we return False.

Try solving now

2. URL Shortener

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

You have given a URL id – 'N' consisting of only digits. Your task is to generate a short URL for the given URL id.

To generate a short URL, you need to convert the given URL id to 62 base number where digits of the number are:[“0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ”] i.e “0” corresponds to 0, “a” corresponds to 10, “Z” corresponds to 61, and “10” corresponds to 62, “11” corresponds to 63, and so on….

Follow Up:
Can you solve this in logarithmic time and space complexity?
Problem approach

Step 1: When a long URL is provided, generate a unique short code for it. This code can be generated using a combination of alphanumeric characters or a hashing algorithm.
Step 2: Store the mapping between the generated short code and the original long URL in a database or key-value store.
Step 3: When a short URL is accessed, retrieve the corresponding long URL from the database using the short code and redirect the user to the original URL.

Try solving now

3. OS Question

Explain the concepts of deadlock and starvation in operating systems in two lines.

Problem approach

Step 1: Deadlock occurs when two or more processes are unable to proceed because each is waiting for a resource held by another process.
Step 2: Starvation occurs when a process is unable to gain necessary resources to execute, often due to resource allocation policies that prioritize other processes.

04
Round
Easy
HR Round
Duration20 min
Interview date27 Apr 2023
Coding problem2

This HR Round happened on next day 28th april and time was 12 pm

1. Basic HR Question

How do you manage your time and prioritize tasks when working on multiple projects simultaneously?

Problem approach

I use a project management tool to create a clear overview of all tasks and deadlines, allowing me to prioritize based on urgency and importance.
I break down larger projects into smaller, manageable tasks and allocate dedicated time slots to work on each project, ensuring progress on all fronts.
I regularly communicate with stakeholders and team members to align priorities, manage expectations, and make adjustments as needed to maintain productivity and meet project milestones.

2. Basic HR Question

Describe a situation where you demonstrated leadership skills or took initiative in a project or team setting.

Problem approach

Step 1: Context and Problem: Describe the project or team setting and the specific challenge or problem you encountered.
"In a cross-functional team working on a complex software development project, we faced a critical deadline and were falling behind due to miscommunication and lack of coordination among team members."

Step 2: Initiative and Action: Explain the leadership skills or initiative you took to address the situation.
"I recognized the need for improved collaboration and decided to take the initiative. I organized a team meeting to discuss the challenges and potential solutions. I encouraged open communication, actively listened to everyone's perspectives, and facilitated a brainstorming session to generate ideas."

Step 3: Outcome and Result: Describe the positive outcome achieved through your leadership or initiative.
"As a result of the meeting and collaborative efforts, we established a more efficient workflow, streamlined communication channels, and implemented a project management tool to track progress and deadlines. This led to improved coordination, increased productivity, and ultimately, we successfully met the critical deadline."

Here's your problem of the day

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

Skill covered: Programming

What is the index number of the last element of an array with 9 elements?

Choose another skill to practice
Start a Discussion
Similar interview experiences
company logo
SDE - 2
3 rounds | 3 problems
Interviewed by Morgan Stanley
1908 views
0 comments
0 upvotes
company logo
SDE - 2
4 rounds | 10 problems
Interviewed by Morgan Stanley
1157 views
0 comments
0 upvotes
company logo
Technology Analyst
2 rounds | 3 problems
Interviewed by Morgan Stanley
791 views
0 comments
0 upvotes
company logo
Technology Analyst Intern
3 rounds | 6 problems
Interviewed by Morgan Stanley
13 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 2
5 rounds | 12 problems
Interviewed by Walmart
23581 views
8 comments
0 upvotes
company logo
SDE - 2
3 rounds | 4 problems
Interviewed by HashedIn
7914 views
0 comments
0 upvotes
company logo
SDE - 2
3 rounds | 5 problems
Interviewed by Amazon
5093 views
0 comments
0 upvotes