Morgan Stanley Interview Question for Developer Program Engineers


Country: India
Interview Type: Phone Interview




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

For this types of questions, Its a biggest mistake to jump to solution directly. Its very necessary to ask right set of questions before committing any solution. As an example, here lot of things are unknown 1) Data are coming from stock exchange but where they are going, is it some centralized place where all the exchanges are sending the data 2) What is data here, is it just stockname, price, time stamp 3) how frequenlty data is sent and is it in some batches like 100 stock data per second ? 4) what if two stock exchanges same same data, do we need to merge them 5) what kinds of operations we want to do, do we just need to consolidate the dataset 6) can stock exchanges are wired to the place where they are sending data, if not we might need to go for File system storage and the later transfer them. 7) is stock data are realtime stock value or historical data, 8) are all stock exchanges reside in same time zone, what if stock exchange A is NYSE and stock exchange B is bombay stock exchange
once u get clarity for all these open questions, you should jump on for solution.

- billu April 02, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

HashMap<Exchange,Set<Stock>> should be the right option.

- Manoj July 17, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You Must have Asked regarding the Type of Operations/Queries that would be performed on above Data..Then only can decide the DS to be used.

- Algorithmist March 31, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You must b having Exchange (various exchanges) object and Stock object
U can take HashMap<Exchange,Set<Stock>>

- Anonymous April 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Question is incomplete. Data structure will be decided at least with couple of questions.
1. How frequently data is need to be queried?
2. what is the volume of data?
3. does it require real time right and read opearation etc etc.

- Mohd Adnan August 18, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class inAnotinB {

	public static void main(String[] args) {
		
		int[] A = {1, 3, 4, 6,8,10, 17, 34} ;
		int[] B = {2, 8, 17, 33, 44, 66, 89, 100, 123}; 

		int largest = A[A.length-1] > B[B.length-1]?  A[A.length-1] : B[B.length-1];
		int smallest = A[A.length-1] < B[B.length-1]?  A[A.length-1] : B[B.length-1];
		
		int i=0,j=0;
		
		while(smallest != largest) {
			if(A[i] == B[j]) {
				smallest = A[i];
				i++;
				j++;
			} else if(A[i] < B[j]) {
				System.out.print(A[i]+" ");
				smallest = A[i];
				i++;
			} else {
				smallest = B[j];
				System.out.print(B[j]+" ");
				j++;
			}
			
			if(i>=A.length) {
				for (; j < B.length; j++) {
					System.out.print(B[j] + " ");
					smallest = B[j];
				}
			}
			
			if(j>=B.length) {
				for (; i < A.length; i++) {
					System.out.print(A[i] + " ");
					smallest = A[i];
				}
			}
			
		}
	}

}

- Jahir May 16, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Sorry the answer for other problem posted here. Please ignore.

- Jahir May 16, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

The question is not very clear. Assuming you have a specified number of exchanges and the data is stock_ticker and stock_price, then you could create multiple hash maps of <string, double>, one per exchange. i.e. If exch==LIFFE then add the stock data to liffe_exch_map. If you're supposed to be aggregating prices from different exchanges then you only actually need one hash map, as exchange is irrelevant. If you didn't know the number of exchanges in advance then you could create a hashmap where the key is exchange and the returned value is another hashmap of <string, double>. Look up the correct list of stocks and their values based on the exchange, then look up the value for that stock as before.

It's also worth pointing out that you don't have to use a string as the key, you could get a lot more flexibility if you defined a proper Stock object to use as the key, and then defined the Stock hash function as needed, and let your container handle how it stores the Stock objects. For example, if the hash includes the exchange and name, then stocks with the same name but different exchanges would be stored in separate buckets in the hashmap. You then lookup a Stock object in the hashmap using name and exchange, and if your hashing function is working properly it's constant time lookup. If you stop caring about exchange then you simply remove exchange from the hash function.

- merlinme December 04, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Should be hashtable.

- Varun March 30, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I got the same question + moving averages problem

- helly July 20, 2014 | Flag


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