diff options
author | Santo Cariotti <santo@dcariotti.me> | 2024-05-28 10:29:13 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2024-05-28 10:29:13 +0200 |
commit | f05d888a0b621ca4e99e2b0fb6e23c097006fe41 (patch) | |
tree | eebbb2489144112d3288393e354d19375a0aa088 /progs/a960.py |
Init
Diffstat (limited to 'progs/a960.py')
-rw-r--r-- | progs/a960.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/progs/a960.py b/progs/a960.py new file mode 100644 index 0000000..1e4960e --- /dev/null +++ b/progs/a960.py @@ -0,0 +1,22 @@ +def find_kth(arr1, arr2, m, n, k):
+ sorted1 = [0] * (m + n)
+ i = 0
+ j = 0
+ d = 0
+ while (i < m and j < n):
+ if (arr1[i] < arr2[j]):
+ sorted1[d] = arr1[i]
+ i += 1
+ else:
+ sorted1[d] = arr2[j]
+ j += 1
+ d += 1
+ while (i < m):
+ sorted1[d] = arr1[i]
+ d += 1
+ i += 1
+ while (j < n):
+ sorted1[d] = arr2[j]
+ d += 1
+ j += 1
+ return sorted1[k - 1]
\ No newline at end of file |