function({1, 1, 2, 2, 1}) → true
function({1, 1, 2, 2, 2, 1}) → false
function({1, 1, 1, 2, 2, 2, 1}) → false
1 2 3 4 5 6 7 8 | public boolean noTriples(int[] nums) { for(int x=0;x<nums.length-2;x++){ if(nums[x]==nums[x+1] && nums[x]==nums[x+2]) return false; } return true; } |
No comments:
Post a Comment