Interview Question for Analysts


Country: United States
Interview Type: Phone Interview




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

We can have a hashmap for new data set, with Account number as key and an object of class containing only two members Total Incoming and Total Outgoing.
Now we will traverse the original data set's first column - Account From, for each row we check if this account no. is present in our hashmap in O(1) time-
a. If NO, we create a new entry in hashmap with this account no. and value object will contain Total Incoming = 0 and total Outgoing = amount in third column of original data set.
b. If YES, we just add amount in third column of Original data set, to the existing Total Outgoing amount for the object corresponding to this key.
This process will take O(n) time.
Now we will again traverse the complete original data set, but now this time we will traverse second column (Acct To). For each entry of account no. we will check if an entry is there in our output hashmap in O(1) time -
a. If NO we will create a new entry in hashmap with this account no. and value object will contain Total Incoming = amount in third column of original data set and Total Outgoing = 0.
b. If YES, we just add amount in third column of Original data set, to the existing Total Ingoing amount for the object corresponding to this key.
This process will take O(n) time.

Total time O(n).

- Rajat January 12, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use a hash/ dictionary with account number as key and an array or a structure as key.
It'll be o(n) to populate the hash.

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

to display in the new dataset , sum all the positive values for total money transferred in and sum -ve for out

- praveenkcs28 January 12, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Array or struct as value :)

- Varun January 12, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Perhaps I was not clear. There are no negative values unless you would define a new variable for there to be negative values. The original spreadsheet would look like this:
_____________________________
| Acct From | |Acct To| | Amount |

The new spreadsheet would look like:
______________________________________
| Account | |Total Incoming | | Total Outgoing |

- footballman January 12, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

think the accounts number are the node of a weighted directed graph, and the amount transfer from the account is represented by an outgoing edge, and amount transfer to the account is represented by an incoming edge. so first populate the graph(means adjacency list) and then just sum it up and create new three columns

- sonesh January 21, 2013 | 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