outside09
BAN USER- 1of 1 vote
AnswersGiven a linked list of integers, write a function to determine whether the given list has a loop or cycle anywhere in the list. The integer values may not be relied upon to be distinct.
- outside09 in United States
You may use the JDK or the standard template library. The solution will be evaluated on correctness, runtime complexity (big-O), and adherence to coding best practices. A complete answer will include the following:
Document your assumptions
Explain your approach and how you intend to solve the problem
Provide code comments where applicable
Explain the big-O run time complexity of your solution. Justify your answer.
Identify any additional data structures you used and justify why you used them.
Only provide your best answer to each part of the question.
Use one of the following skeletons for your solutions.
Java:
public class ListLoopQuestion {
public static class ListNode {
public int value;
public ListNode next;
}
public static boolean hasLoops( ListNode myList ) {
}
}
C++:
struct ListNode {
int value;
ListNode * next;
}
bool hasLoops( ListNode * myList ) {
}| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 2 votes
AnswersGiven a list of test results (each with a test date, Student ID, and the student’s Score), return the Final Score for each student. A student’s Final Score is calculated as the average of his/her 5 highest test scores. You can assume each student has at least 5 test scores.
- outside09 in United States
You may use the JDK or the standard template library. The solution will be evaluated on correctness, runtime complexity (big-O), and adherence to coding best practices. A complete answer will include the following:
Document your assumptions
Explain your approach and how you intend to solve the problem
Provide code comments where applicable
Explain the big-O run time complexity of your solution. Justify your answer.
Identify any additional data structures you used and justify why you used them.
class TestResult{
int studentId;
Date testDate;
int testScore;
}
public Map<Integer, Double> getFinalScores(List<TestResult> resultList){
return null;
}| Report Duplicate | Flag | PURGE
Amazon SDE1 Object Oriented Design - 0of 0 votes
AnswersGiven two sorted singly linked lists, implement a function to merge the two lists into a single sorted list and return its head. You may destroy the original lists if you want.
- outside09 in United States
You may use the JDK or the standard template library. The solution will be evaluated on correctness, runtime complexity (big-O), and adherence to coding best practices. A complete answer will include the following:
Document your assumptions
Explain your approach and how you intend to solve the problem
Provide code comments where applicable
Explain the big-O run time complexity of your solution. Justify your answer.
Identify any additional data structures you used and justify why you used them.
Only provide your best answer to each part of the question.
Example:
Input:
List 1: 1->2->3->4
List 2: 1->3->5->7
Output:
1->1->2->3->3->4->5->7
Use one of the following skeletons for your solutions.
Java:
public class Node {
public int value;
public Node next;
public Node() {
value = 0;
next = null;
}
public Node(int value, Node next) {
this.value = value;
this.next = next;
}
}
public class MergeListProblem {
public static Node mergeLists(Node head1, Node head2) {
// your code goes here
}
}
C++:
class Node {
public:
int value;
Node* next;
Node() {
value = 0;
next = NULL;
}
Node(int v, Node* n) {
value = v;
next = n;
}
};
Node* mergeLists(Node* head1, Node* head2) {
// your code goes here
}| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm