Skip to content

Instantly share code, notes, and snippets.

@thebigdatajedi
Created December 17, 2022 13:25
Show Gist options
  • Save thebigdatajedi/ba80b96aef83660d02dc9e0733e9ed70 to your computer and use it in GitHub Desktop.
Save thebigdatajedi/ba80b96aef83660d02dc9e0733e9ed70 to your computer and use it in GitHub Desktop.
Java, nested loop search.
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