Last active
December 11, 2015 11:18
-
-
Save duraz0rz/4592313 to your computer and use it in GitHub Desktop.
Reformatted code for http://www.reddit.com/r/learnprogramming/comments/171f5y/java_question_regarding_if_else_statements/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean has12(int[] nums) { | |
boolean has1 = false; | |
boolean has2 = false; | |
for (int i = 0 ; i < nums.length ; ++i) { | |
if (nums[i] == 1) | |
{ | |
has1 = true ; | |
} | |
else if (has1 && nums[i] == 2) | |
{ | |
has2 = true ; | |
} | |
} | |
return has2 ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment