| [ Web Proxy ] |
| Viewing: https://raw.githubusercontent.com/Programming-With-Love/leetcode/master/Array/No747.java | [Back] [Original] |
package Algorithm.leetcode.Array;
/**
*
* Created by tujietg on Nov 6, 2019
*/
public class No747 {
public int dominantIndex(int[] nums) {
//
int one = 0;
int two = 0;
int index = 0;
for (int i = 0; i < nums.length; i++) {
if (nums[i] > one) {
two = one;
one = nums[i];
index = i;
} else if (nums[i] > two) {
two = nums[i];
}
}
return (one >= two * 2) ? index : -1;
}
}
| Web Proxy Viewer | New URL | Original Page |