1957

无聊蛋疼的1957写的低端博客
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2014年1月11日

摘要: 和I一样的。。。不过只输出可能数感觉。。。可能有优化吧。。但是用I的代码过了。。。class Solution {public: bool col[100]; bool d1[100]; // i + j bool d2[100]; // i - j + n int ans; void nque( int n , int dep) { if(dep >= n) { ans ++; return ; } for(int i = 0 ; i < n ; i++... 阅读全文

posted @ 2014-01-11 22:25 1957 阅读(190) 评论(0) 推荐(0)

摘要: 八皇后,学递归入门题判重复的技巧,就是对角线x+y , x-y这样判断两个对角线了,把二维坐标压缩到一维,方便点。。class Solution {public: bool col[100]; bool d1[100]; // i + j bool d2[100]; // i - j + n int cnt[100]; void nque(vector >& ans , int n , int dep) { if(dep >= n) { vector xx(n); for(int i = 0 ; i... 阅读全文

posted @ 2014-01-11 22:22 1957 阅读(246) 评论(0) 推荐(0)

摘要: O(m+n)其实很简单的,记录列行,有木有0就好了如果是O(1),那么我们就随便找个0所在的列,行当做我们之前那两个数组嘛。。。class Solution {public: void setZeroes(vector > &matrix) { int m = matrix.size(); if(m < 1) return ; int n = matrix.front().size(); //found first zero int row = -1 , col = -1;; for(i... 阅读全文

posted @ 2014-01-11 22:08 1957 阅读(1508) 评论(0) 推荐(0)