it aint even a question..had we had to return the tree then it would be a medium..the question's prerequisite is lvl order traversal..cuz arrays n sorting is done probably undrr lecture 15
It would be cool to see a video of you solving a problem that you don't already know the solution to. I want to see what you're thought process is like. I understand that a vid like this would probably be very long but i think it would still be a cool concept
because whatever you change index to, it goes back to correct position..also any standard sort i think shouls not work because here our stuff works below linear time..its a custom sort =)
Mostly you upload the solution the moment it appears in daily challenge. I know there is time_zone difference , but curious to know how do you manage sleep and other stuff with this.
as we don't need to update the mapping of idx_map[nums[ i ]] = i we also don't need to swap nums[ i ] = nums[ j ] and our final solution be like j = index_map[sorted_nums[ i ]] nums[ j ] = nums[ i ] index_map[nums[ j ]] = j
This is an array question not a tree one !
it aint even a question..had we had to return the tree then it would be a medium..the question's prerequisite is lvl order traversal..cuz arrays n sorting is done probably undrr lecture 15
It would be cool to see a video of you solving a problem that you don't already know the solution to. I want to see what you're thought process is like. I understand that a vid like this would probably be very long but i think it would still be a cool concept
As always GOAT
Doing the complete swap was very helpful. Thank you!
i actually used a min_heap, instead of sorting.. and i mapped everything but still failed it.. dunno why
Hashmap Jutsu, i am using this one 😆😆
Does count inversions work here??
No. Ex [3, 2, 1] there are 3 inversions but only 1 swap is needed
@raymartin77 okay
Thank you!!
it works when only adjacent swapping is allowed
comparing to sorted array felt like cheating
Cant we do this with two lists? compare the sorted list with the current list, check where the indexes dont match, and return the answeR?
can you solve the same question with multiple approaches...........
With the swaps, how are we guaranteed that its the minimum number of swaps? Does cyclic sort guarantee minimum number of swaps?
because whatever you change index to, it goes back to correct position..also any standard sort i think shouls not work because here our stuff works below linear time..its a custom sort =)
Mostly you upload the solution the moment it appears in daily challenge.
I know there is time_zone difference , but curious to know how do you manage sleep and other stuff with this.
Probably he prepared this video a few days before the problem actually appeared.
@@bubblesort8760 how does one know which problem is coming, or do you think he just hopes a video he's already done will come
hashmap jitsu for the win 😀
as we don't need to update the mapping of
idx_map[nums[ i ]] = i
we also don't need to swap
nums[ i ] = nums[ j ]
and our final solution be like
j = index_map[sorted_nums[ i ]]
nums[ j ] = nums[ i ]
index_map[nums[ j ]] = j
:D