题解 | #二维数组中的查找#

二维数组中的查找

https://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e

import java.util.*;

public class Solution {
    public boolean Find(int target, int [][] array) {
        ArrayList<Integer> numList = new ArrayList<>();
        for (int i = 0; i < array.length; i++) {
            if (array.length == 0) {
                return false;
            }
            for (int j = 0; j < array[i].length; j++) {
                numList.add(array[i][j]);
            }
        }
        if (numList.contains(target)) {
            return  true;
        } else
            return false;
    }
}

全部评论

相关推荐

01-21 12:26
暨南大学 golang
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务