摘要: 这道题,最重要的是要能观察出,连续的0和连续的1之间的关系——每一组连续的0和连续的1可以贡献出:Math.min(连续0,连续1) 下面的两个算法都可以beat 100%,时间复杂度O(n). public int countBinarySubstrings(String s) { int res 阅读全文
posted @ 2022-01-20 04:57 阳光明媚的菲越 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 这道题的最简单的算法如下,时间复杂度O(m*n) public int countNegatives(int[][] grid) { int res = 0; for(int i=0;i<grid.length;i++){ for ( int j=0;j<grid[0].length;j++){ i 阅读全文
posted @ 2022-01-20 04:23 阳光明媚的菲越 阅读(38) 评论(0) 推荐(0) 编辑