You are viewing a single comment's thread. Return to all comments →
Your approach is correct but it will take O(nlogn) time due to sorting but same thing can be achieved in O(n) time.
Here is the video explaination of my solution in O(n) time - https://youtu.be/3hvzKDJQypI
and you can find most of the hackerrank solutions with video explaination here- https://github.com/Java-aid/Hackerrank-Solutions
and many more needs to be addeed.
Regards,
Kanahaiya Gupta
Git Hub URL | https://github.com/Java-aid/
LIKE US | https://www.facebook.com/javaaid/
SUBSCRIBE US | https://www.youtube.com/channel/UCx1hbK753l3WhwXP5r93eYA
Seems like cookies are disabled on this browser, please enable them to open this website
Angry Professor
You are viewing a single comment's thread. Return to all comments →
Your approach is correct but it will take O(nlogn) time due to sorting but same thing can be achieved in O(n) time.
Here is the video explaination of my solution in O(n) time - https://youtu.be/3hvzKDJQypI
and you can find most of the hackerrank solutions with video explaination here- https://github.com/Java-aid/Hackerrank-Solutions
and many more needs to be addeed.
Regards,
Kanahaiya Gupta
Git Hub URL | https://github.com/Java-aid/
LIKE US | https://www.facebook.com/javaaid/
SUBSCRIBE US | https://www.youtube.com/channel/UCx1hbK753l3WhwXP5r93eYA