aopencv
BAN USER- 0of 0 votes
AnswersFind the most common "3 page path" on a website given a large data log.
- aopencv in United States| Report Duplicate | Flag | PURGE
Groupon Software Engineer / Developer - -1of 1 vote
AnswersFind pairs of nums that add upto given number.
- aopencv in United States| Report Duplicate | Flag | PURGE
Groupon Software Engineer / Developer - 0of 0 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.
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 the following skeleton for your solutions.
Java:
- aopencv in United Statesclass TestResult { int studentId; String testDate; int testScore; } public class FinalScoreQuestion { Map <Integer, Double> calculateFinalScores (List<TestResult> results) { }
| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm Java Problem Solving Sorting - 2of 2 votes
AnswersCheck if the given binary tree is BST or not.
- aopencv in United States| Report Duplicate | Flag | PURGE
Ebay Software Engineer / Developer Algorithm Data Structures Java - 0of 0 votes
AnswersGiven an integer array, find pairs in an array which sum up to a given number.
- aopencv in United States
For example: Array{4,5,1,3,2} and required sum=6 then output should be [1,5] and [2,4].| Report Duplicate | Flag | PURGE
Ebay Software Engineer / Developer Data Structures Java
public boolean isBST(Node root, int min, int max){
if(root == null)
return true;
if(min < root.data && root.data < max)
return isBST(root.left, min, root.data) && isBST(root.right, root.data,max);
else
return false;
}
Call the method as - isBST(root, Integer.MIN_value, Integer.MAX_value);
public boolean isBST(Node root, int min, int max){
if(root == null)
return true;
if(min < root.data && root.data < max)
return isBST(root.left, min, root.data) && isBST(root.right, root.data,max);
else
return false;
}
Call the method as - isBST(root, Integer.MIN_value, Integer.MAX_value);
A better explanation of question-
Given a web log which consists of fields 'User ' 'Page url'. We have to find out the most frequent 3-page sequence that users takes.
There is a time stamp. and it is not guaranteed that the single user access will be logged sequentially it could be like user1 Page1 user2 Pagex user1 Page2 User10 Pagex user1 Page 3 her User1s page sequence is page1-> page2-> page 3
public static void main(String[] args) {
int[] a = new int[] { 1, 3, 10, 4, 5, 6, 7, 2, 6 };
Set<String> resultSet = new HashSet<String>();
int sum = 12;
if (a == null || a.length < 2) {
return;
}
int left = 0;
int right = a.length - 1;
java.util.Arrays.sort(a);
while (left < right) {
int i = a[left];
int j = a[right];
if (i + j == sum) {
resultSet.add(String.valueOf(i)+"-"+String.valueOf(j));
left++;
right--;
} else if (i + j > sum) {
right--;
} else {
left++;
}
}
System.out.println(resultSet);
}
- aopencv July 19, 2013