Sunteți pe pagina 1din 1

Q1 Given two lists of integers, write a function that returns a list that contains only the intersection (elements

that occur in both lists) of the two lists. The returned list should only contain unique integers, no duplicates. For example, [4, 2, 73, 11, -5] and [-5, 73, -1, 9, 9, 4, 7] would return the list [-5, 4, 73] in no particular order. 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: 1. Document your assumptions 2. Explain your approach and how you intend to solve the problem 3. Provide code comments where applicable 4. Explain the big-O run time complexity of your solution. Justify your answer. 5. Identify any additional data structures you used and justify why you used them. 6. Only provide your best answer to each part of the question. Q2 Given a binary tree, write a function that returns true if and only if it is a binary search tree. Your solution will be evaluated on correctness, runtime complexity (bigO), and adherence to coding best practices Q3 Find the K closest points to the origin in 2D plane, given an array containing N points. You can assume K is much smaller than N and N is very large. You need only use standard math operators (addition, subtraction, multiplication, and division).

java,c++

S-ar putea să vă placă și