• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
frankM
天下武功,唯快不破。
博客园 | 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理

12 2014 档案

 
LeetCode Maximum Product Subarray
摘要:链接: https://oj.leetcode.com/problems/maximum-product-subarray/求最大连续序列的乘积因为偶数个负数相乘为正数,且任何数乘0等于0.所以在计算的过程中需要维护两个数组,一个记录到当前位的最大乘积,一个记录到当前位的最小乘积..并初始化为A[i... 阅读全文
posted @ 2014-12-27 14:03 frankM 阅读(163) 评论(0) 推荐(0)
LeetCode Merge Two Sorted Lists
摘要:链接: https://oj.leetcode.com/problems/merge-two-sorted-lists/题目要去把两个有序的链表合并,并且合并后的链表依然有序./** * Definition for singly-linked list. * struct ListNode { *... 阅读全文
posted @ 2014-12-24 22:31 frankM 阅读(93) 评论(0) 推荐(0)
LeetCode Single Number II
摘要:链接: https://oj.leetcode.com/problems/single-number-ii/虽然知道这个题肯定跟位运算,异或有关...但实在没想出来怎么解决class Solution {public: int singleNumber(int A[], int n) { ... 阅读全文
posted @ 2014-12-14 16:41 frankM 阅读(126) 评论(0) 推荐(0)
LeetCode Find Peak Element
摘要:链接: https://oj.leetcode.com/problems/find-peak-element/题目要求复杂度在对数级以内对数组下标进行二分搜索,public class Solution{ public int findPeakElement(int [] num) { int l... 阅读全文
posted @ 2014-12-13 20:02 frankM 阅读(135) 评论(0) 推荐(0)
LeetCode Minimum Path Sum
摘要:链接: https://oj.leetcode.com/problems/minimum-path-sum/简单的动态规划.[i][j]表示到达位置(i,j)时的最小sumpublic class Solution{ public int minPathSum(int[][] grid) { in... 阅读全文
posted @ 2014-12-13 12:32 frankM 阅读(175) 评论(0) 推荐(0)
LeetCode 3sum
摘要:链接: https://oj.leetcode.com/problems/3sum/2sum:尺取法 通过a+b与target比较,.根据大于或小于不断缩小范围3sum:即对0~n个数分别做2sum...去重: if(i!=0&&num[i]==num[i-1]) continue;只有当i=... 阅读全文
posted @ 2014-12-12 17:13 frankM 阅读(130) 评论(0) 推荐(0)
LeetCode Best Time to Buy and Sell Stock II
摘要:链接: https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/class Solution{ public: int maxProfit(vector &prices) { if(prices.size()==... 阅读全文
posted @ 2014-12-10 14:07 frankM 阅读(92) 评论(0) 推荐(0)
LeetCode Permutations
摘要:链接: https://oj.leetcode.com/problems/permutations/每次从num中选择一个数添加到结果中,并用used标记用过的数.public class Solution { private boolean used[]; private List > ans;... 阅读全文
posted @ 2014-12-08 22:08 frankM 阅读(118) 评论(0) 推荐(0)
LeetCode Rotate List
摘要:链接: https://oj.leetcode.com/problems/rotate-list//** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next... 阅读全文
posted @ 2014-12-05 21:39 frankM 阅读(113) 评论(0) 推荐(0)
LeetCode Reorder List
摘要:链接: https://oj.leetcode.com/problems/reorder-list/空间复杂度为O(n),时间复杂度为 O(n)的代码:/** * Definition for singly-linked list. * struct ListNode { * int val... 阅读全文
posted @ 2014-12-04 13:55 frankM 阅读(138) 评论(0) 推荐(0)
LeetCode Sum Root to Leaf Numbers
摘要:链接: https://oj.leetcode.com/problems/sum-root-to-leaf-numbers/dfs..sum保存中间结果.每计算完一条路径,就更新ans/** * Definition for binary tree * struct TreeNode { * ... 阅读全文
posted @ 2014-12-02 19:37 frankM 阅读(165) 评论(0) 推荐(0)
 

公告


博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3