RyanFehr / HackerRank

HackerRank solutions in Java/JS/Python/C++/C#
MIT License
1.29k stars 693 forks source link

Question: How is sorting defined as (n+m) log(n+m)? Shouldn't it be nlogn +mlogm? #243

Open tseth92 opened 5 years ago

tseth92 commented 5 years ago

nlogn for drives and mlogm for keyboard. So, if you sort both independently, shouldn't it be mlogm+nlogn , instead of (m+n)log(m+n) ?

RyanFehr commented 5 years ago

This is Big O notation signifying the class of problem. This post should help explain how the notation works and the mathematical thought behind it: http://forums.codeguru.com/showthread.php?491516-how-is-O(logm-logn)-O(log(m-n))-O-is-big-oh

On Wed, Jul 17, 2019, 11:37 PM tseth92 notifications@github.com wrote:

nlogn for drives and mlogm for keyboard. So, if you sort both independently, shouldn't it be mlogm+nlogn , instead of (m+n)log(m+n) ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/RyanFehr/HackerRank/issues/243?email_source=notifications&email_token=AEWZT3I774ATLB5CQJ7QHITQAAFR5A5CNFSM4IEXNAYKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G75OIJA, or mute the thread https://github.com/notifications/unsubscribe-auth/AEWZT3PLSX33BOCWOOLCNJ3QAAFR5ANCNFSM4IEXNAYA .