Page 2Page 2
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 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
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 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
Even though there is something easy like .equals, I'd like to point out TWO mistakes you made in your code. The first: when you go through the arrays, you say b is true or false. Then you start again to check, because of the for-loop. But each time you are giving b a value. So, no matter what happens, the value b gets set to is always the value of the LAST for-loop. Next time, set boolean b = true, if equal = true, do nothing, if equal = false, b=false. Secondly, you are now checking each value in array1 with each value in array2. If I understand correctly, you only need to check the values at the same location in the array, meaning you should have deleted the second for-loop and check like this: if (array2[i] == array1[i]). Then your code should function as well. Your code would work like this: public static void compareArrays(int[] array1, int[] array2) { boolean b = true; for (int i = 0; i < array2.length; i++) { if (array2[i] == array1[i]) { System.out.println("true"); } else { b = false; System.out.println("False"); } } return b;} But as said by other, easier would be: Arrays.equals(ary1,ary2);
Round 1 (Online Test): 10 MCQS (based on Aptitude, OS, OOP, Output based ques) + 2 Coding question
Could solve all test cases for 2 coding ques and 8+ MCQs in 10 were right. 15 students got shortlisted for Interviews. Round 2 (Technical Interview 1 Approx 80mins): Took place on HackerRank Code Pair.
Round 3 (Technical Interview 2 Approx 65mins): This took place on MS Teams.
After technical rounds, around 6/15 students made it to next round Round 4 (Managerial Interview Approx 70mins): Focused mainly on my resume and my ambitions, took place on MS Teams.
Round 5 (HR Interview Approx 30mins): It revolved around the conclusion of my previous round and how I am as a person, my interpersonal skills. Took place on MS Teams again.
Finally, they recruited 3 students for Full Time Employment Offer. I was selected as one of them. Article Tags :
Given two arrays arr1[] and arr2[] and an integer K, our task is to find the number elements in the first array, for an element x, in arr1[], there exists at least one element y, in arr2[] such that absolute difference of x and y is greater than the integer K. Examples:
Naive Approach: Iterate for each element in arr1[] and check whether or not there exists an element in arr2 such that their absolute difference is greater than the value K. Time complexity: O(N * M) where N and M are the sizes of the arrays 1 and 2 respectively. Efficient Approach: To optimize the above method we have to observe that for each element in arr1[], we need only the smallest and largest element of arr2[] to check if it is distant or not. For each element x, in arr1, if the absolute difference of smallest or the largest value and x is greater than K then that element is distant. Below is the implementation of the above approach:
Time Complexity: O(N + M), where N and M are the sizes of the given arrays. Article Tags : |