Created
January 2, 2021 23:39
-
-
Save or9/a5b4f4cf7cd3d55060b99d97f1375ec0 to your computer and use it in GitHub Desktop.
Extract the kth element from a list of lists without a heap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function kth (m, k) { | |
return m.reduce((curr, next) => curr.concat(next)) | |
.sort((x, y) => x >= y? 1: -1) | |
[k]; | |
} | |
// e.g., [[1, 5, 9], [10, 11, 13], [12, 13, 15]], 7 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://instagram.com/osama_fstq_2021?igshid=6z23gvkmuotm