You are viewing a single comment's thread. Return to all comments →
Hello friends,
Today, I have solved Picking Number hackerrank problem in O(N) time.
In this video tutorial, I have explained the technique to come up with easy algorithm which will pass all the test cases in O(n) time.
click here for the video explanation of generic algorithm with complexity analysis.
or you can click on the image too to follow youtube tutorial.
Here is the 100% working solution:-
source code :
public static int pickingNumbers(List<Integer> a) { int frequency[] = new int[101]; int result = Integer.MIN_VALUE; for (int i = 0; i < a.size(); i++) { int index=a.get(i); frequency[index]++; //frequency[index]=frequency[index]+1 } for (int i = 1; i <= 100; i++) { result = Math.max(result, frequency[i] + frequency[i - 1]); } return result; }
Would really appreciate your feedback like, dislike , comment etc. on my video.
Seems like cookies are disabled on this browser, please enable them to open this website
Picking Numbers
You are viewing a single comment's thread. Return to all comments →
Hello friends,
Today, I have solved Picking Number hackerrank problem in O(N) time.
In this video tutorial, I have explained the technique to come up with easy algorithm which will pass all the test cases in O(n) time.
click here for the video explanation of generic algorithm with complexity analysis.
or you can click on the image too to follow youtube tutorial.
Here is the 100% working solution:-
source code :
Would really appreciate your feedback like, dislike , comment etc. on my video.
Do not forget to upvote, if you find it useful.