摘要:
这道题,最重要的是要能观察出,连续的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
阳光明媚的菲越
阅读(29)
评论(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
阳光明媚的菲越
阅读(44)
评论(0)
推荐(0)
浙公网安备 33010602011771号