You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
603 B
31 lines
603 B
5 years ago
|
/*
|
||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
|
*
|
||
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
|
*/
|
||
|
class CompareArgs {
|
||
|
static int max(int[] a, int i, int k) {
|
||
|
int m = a[i];
|
||
|
for (int j = i + 1; j < k; ++j) {
|
||
|
m = Math.max(m, a[j]);
|
||
|
}
|
||
|
return m;
|
||
|
}
|
||
|
|
||
|
static void aBad() {
|
||
|
int[] a = new int[10];
|
||
|
int x = max(a, 2, 2);
|
||
|
}
|
||
|
|
||
|
static void bOk() {
|
||
|
int[] a = new int[10];
|
||
|
int x = max(a, 2, 3);
|
||
|
}
|
||
|
|
||
|
static void cBad() {
|
||
|
int[] a = new int[10];
|
||
|
int x = max(a, 2, 1);
|
||
|
}
|
||
|
}
|