diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/kth_missing_pos_num.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/kth_missing_pos_num.cpp')
-rw-r--r-- | other/kth_missing_pos_num.cpp | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/other/kth_missing_pos_num.cpp b/other/kth_missing_pos_num.cpp deleted file mode 100644 index a7f81f7..0000000 --- a/other/kth_missing_pos_num.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// 1539. Kth Missing Positive Number -#include "leetcode.h" - -/* - * given array 'arr' of positive integers sorted in a strictly increasing order, - * and an integer 'k', return 'kth' positive integer missing from array -- o(log - * n) - */ - -class Solution { -public: - int findKthPositive(vector<int> &arr, int k) { - int l = 0, r = arr.size(), m; - while (l < r) { - m = (l + r) / 2; - if (arr[m] - 1 - m < k) - l = m + 1; - else - r = m; - } - return l + k; - } -}; - -int main() { - Solution obj; - vector<int> a1 = {2, 3, 4, 7, 11}, a2 = {1, 2, 3, 4}; - cout << obj.findKthPositive(a1, 5) << endl; // expect: 9 - cout << obj.findKthPositive(a2, 2) << endl; // expect: 6 -} |