MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / right

Method right

src/class006/Code03_FindRight.java:37–44  ·  view source on GitHub ↗
(int[] arr, int num)

Source from the content-addressed store, hash-verified

35 // 为了验证
36 // 保证arr有序,才能用这个方法
37 public static int right(int[] arr, int num) {
38 for (int i = arr.length - 1; i >= 0; i--) {
39 if (arr[i] <= num) {
40 return i;
41 }
42 }
43 return -1;
44 }
45
46 // 保证arr有序,才能用这个方法
47 // 有序数组中找<=num的最右位置

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected