Morgan Stanley Interview Question for Software Engineer Interns


Country: India
Interview Type: Written Test




Comment hidden because of low score. Click to expand.
1
of 1 vote

1. Search a tree recursively, returning the minimum and maximum nodes. This should be pretty straight-forward.

2. Turn your problem into a tree. I would basically have the root (for your example) be 1+2*3+4*5, and then brackets get added as you move down the tree; a child of the root, for instance, could be (1+2)*3+4*5.

If you solve both of those problems, you'll have a recursive solution to your original question.

- ArvindAaswani01 November 22, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Why we need greedy or DP approach for this.
We can sort the numbers in decreasing order and place "+" between large numbers. when all given "+" are used then fill "-" between the numbers.
ex. 10+9+8+7+6-5-3-2-1
This will give us the maximum expression value.

- Mohit March 27, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

No. You are intrepting the question incorrectly. It is given an expression with numbers ,+,- you need maximum output of that expression. For example: 10+9-3+1-2 can be treated as : 19-4-2 or 19-3-1 or 10+6-1 and objective is to get max sum of the given expression 10+9-3+1-2

- rahul123jadhaav March 28, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Does this essentially mean parenthesizing the expression in such a way that maximizes its result?

- Hie September 05, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This can be solved if we use back tracking to find permutations of the given expression arranging the numbers and the operators in different ways

- Sidharth November 17, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Search a tree recursively, returning the minimum and maximum nodes. This should be pretty straight-forward.

2. Turn your problem into a tree. I would basically have the root (for your example) be 1+2*3+4*5, and then brackets get added as you move down the tree; a child of the root, for instance, could be (1+2)*3+4*5.

If you solve both of those problems, you'll have a recursive solution to your original question.

- arvindaswani01 November 22, 2016 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More