[LeetCode]Set Matrix Zeroes
发布日期:2021-11-22 02:48:57
浏览次数:2
分类:技术文章
本文共 562 字,大约阅读时间需要 1 分钟。
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.
Follow up:
Did you use extra space?
A straight forward solution using O(mn) space is probably a bad idea.
A simple improvement uses O(m + n) space, but still not the best solution.
Could you devise a constant space solution?
题解:使用两个boolean数组保存为0的位置。
public class Solution73 { public void setZeroes(int[][] matrix) { boolean rows[] = new boolean[matrix.length]; boolean cols[] = new boolean[matrix[0].length]; for(int i=0; i这不是最好的空间复杂度O(n*m),不知道怎么用O(1)的解法。
转载地址:https://blog.csdn.net/zxdfc/article/details/48731845 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
做的很好,不错不错
[***.243.131.199]2024年04月24日 03时06分37秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
维基百科上的算法和数据结构链接很强大
2021-06-30
选择排序
2021-06-30
PHP session回收机制
2021-06-30
最新的全球编程语言,操作系统,web服务器等使用率分析报告
2021-06-30
用C语言写PHP扩展
2021-06-30
PHP Extension programming
2021-06-30
海量数据处理
2019-04-27
PHP防止注入攻击
2019-04-27
多路IO复用模型 select epoll 等
2019-04-27
Linux Epoll介绍和程序实例
2019-04-27
output_buffering详细介绍
2019-04-27
php缓冲 output_buffering和ob_start
2019-04-27
php error_reporting 详解
2019-04-27
剖析PHP中的输出缓冲
2019-04-27
HTTP响应头不缓存
2019-04-27
apache的keepalive和keepalivetimeout(apache优化)
2019-04-27
内容协商 (Content Negotiation)
2019-04-27
关于URL编码
2019-04-27
HTTP中的缓存
2019-04-27
Varnish 和 Squid比较到底强多少
2019-04-27