Question one was
"Given a linked list head, reading the data from the first and last node, find the max of the pairs until the linked list is empty, the solution needs to be constant space"
1->2->->1->1->8->4
1+4 = 5
2+8 = 10
1+1 = 2
max pairs are 2 and 8
Solved this one by having a fast and slow pointer once fast reaches end slow is half way in list you can reverse the second half of the list, then start adding the pairs from the two lists and keep track of the max
Second question
"Developers are working on a new sorting algorithm for points on the x-asis of the coordinate system. There are n points. The ith point initally has a weight of weight[i] and is located at position i on the xasis in a single operation the ith point can be moved ot the right by a distance of dist[i] given the weight and dist, find the minimum number of operations required to sort the points by their weights for example if weight = [3,6,5,2] and dist = [4,3,2,1] the answer is 5 because the number of operations is 1+2+2 = 5 and if weights = [2,4,3,1] and dist = [2,6,3,5] the ans is 4"
the way I solved this was creating a vector<vector> of weight, and distance, sorted them in acending order, then looped over and kept track of a current distance and number of moves, and for each add the distance a number of times till the current distance became greater than the previous one and incrememented the number of moves every time i added a distance, then at end set current distance to the new distance.
Note: I was able to answer both questions and pass ALL testcases for both and still did not make it to the onsite. So make sure you prep for the Amazon work simulation portion, these are questions like:
You need to design a new message system what is the most important thing to start with, A. build prototype, B. create uml diagram, C. talk to requirments team.
You are starting work on the message system what do you start with first, A. front end B. back end, C. api, D. message queue
Good luck hope this helps someone!