Created
December 17, 2022 13:25
-
-
Save thebigdatajedi/ba80b96aef83660d02dc9e0733e9ed70 to your computer and use it in GitHub Desktop.
Java, nested loop search.
This file contains 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
class Solution { | |
public boolean searchMatrix(int[][] matrix, int target) { | |
boolean found = false; | |
outer:for(int[] array : matrix) | |
{ | |
for(int item : array){ | |
if(item == target){ | |
found = true; | |
break outer; | |
}else{ | |
found = false; | |
continue; | |
} | |
} | |
} | |
return found; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment