Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean haveThree(int[] nums) {
- int numThrees = 0;
- for (int i = 0; i < nums.length; i ++ ) {
- if (nums[i] == 3) {
- if (i + 1 < nums.length) {
- if (nums[i+1] == 3) {
- return false;
- } else {
- numThrees += 1;
- }
- } else {
- numThrees += 1;
- }
- }
- }
- if (numThrees == 3) {
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement