Skip to content

Instantly share code, notes, and snippets.

View 0golovatyi's full-sized avatar
🇺🇦
Anything less than immortality is a complete waste of time.

Oleksandr Golovatyi 0golovatyi

🇺🇦
Anything less than immortality is a complete waste of time.
View GitHub Profile
@0golovatyi
0golovatyi / findKthElementInTwoSortedArrays.cpp
Last active April 26, 2020 04:38
Find k-th element in two sorted arrays
// Problem:
// For two sorted arrays A and B and index k find an element on k-th position for merged
// A+B array (sorting preserved).
// Limitations:
// - Complexiti is lower than O(n)
// - No memory allocation
// - Input data can't be modified.
//
// Proposed solution:
// For index i in A and index j in B such that i + j == k move indexes by half of their