• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
村雨sup
自己选的路,跪着也要走完 XD
博客园    首页    新随笔    联系   管理    订阅  订阅
2018年10月8日
Leetcode 55
摘要: //很巧妙的贪心算法 reach = max(reach,nums[i] + i); class Solution { public: bool canJump(vector& nums) { int n = nums.size(); int reach = 0; for(int i=0;i reach || reach >= n-1) ... 阅读全文
posted @ 2018-10-08 16:46 村雨sup 阅读(91) 评论(0) 推荐(0)
Leetcode 52
摘要: //N皇后的基础上改了一点class Solution { public: int totalNQueens(int n) { int res = 0; vector pos(n,-1); DFS(pos,0,res); return res; } void DFS(vector& pos,int row,i... 阅读全文
posted @ 2018-10-08 16:23 村雨sup 阅读(94) 评论(0) 推荐(0)
Leetcode 51
摘要: //看了一次解析后,一次AC,用一个pos记录行列。class Solution { public: vector> solveNQueens(int n) { vector> res; vector pos(n,-1); DFS(pos,0,res); return res; } void DF... 阅读全文
posted @ 2018-10-08 16:02 村雨sup 阅读(116) 评论(0) 推荐(0)
Leetcode 53
摘要: //经典class Solution { public: int maxSubArray(vector& nums) { int sum = 0; int maxsum = -INT_MAX; for(int i=0;i maxsum) maxsum = sum; if(sum < 0) sum = 0; ... 阅读全文
posted @ 2018-10-08 14:55 村雨sup 阅读(86) 评论(0) 推荐(0)
Leetcode 50
摘要: //1开始我只是按照原来快速幂的思想,当n 0?res:1/res; } }; 阅读全文
posted @ 2018-10-08 14:39 村雨sup 阅读(100) 评论(0) 推荐(0)
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3