Unverified Commit 3a665f62 authored by Guolin Ke's avatar Guolin Ke Committed by GitHub
Browse files

fix a bug in `ArgMaxAtK` (#1196)

* fix a bug in `ArgMaxAtK`
parent 9e223c3a
......@@ -133,7 +133,8 @@ public:
int l = start;
int r = end - 1;
Partition(arr, start, end, &l, &r);
if ((k > l && k < r) || l == 0 || r == end - 1) {
// if find or all elements are the same.
if ((k > l && k < r) || (l == start - 1 && r == end - 1)) {
return k;
} else if (k <= l) {
return ArgMaxAtK(arr, start, l + 1, k);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment