Find the index of the first element from the end of the array that verifies the given condition. The function is applied from the pivot to the end of array.
(a, fn)
| 232 | |
| 233 | |
| 234 | def bisect_keep_right(a, fn): |
| 235 | """ |
| 236 | Find the index of the first element from the end of the array that verifies |
| 237 | the given condition. |
| 238 | The function is applied from the pivot to the end of array. |
| 239 | """ |
| 240 | lo = 0 |
| 241 | hi = len(a) |
| 242 | while lo < hi: |
| 243 | mid = (lo + hi) // 2 |
| 244 | if fn(a[mid:]): |
| 245 | lo = mid + 1 |
| 246 | else: |
| 247 | hi = mid |
| 248 | return lo |
no outgoing calls