![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法-leetcode
ida20111117
请求
展开
-
209. Minimum Size Subarray Sumœ
描述: 给出一个数组a,找到在数组a中的一个最短连续序列,使得序列之和大于等于s代码:class Solution { public int minSubArrayLen(int s, int[] a) { if (a == null || a.length == 0) return 0; int i = 0,原创 2018-01-11 20:15:44 · 137 阅读 · 0 评论 -
343. Integer Break
Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given n = 2, retur原创 2018-01-15 20:42:15 · 109 阅读 · 0 评论 -
105. Construct Binary Tree from Preorder and Inorder Traversal
描述基于给出的前序遍历和中序遍历,构造出二叉树。参考文献Construct Binary Tree From Inorder and Preorder/Postorder Traversal 前序遍历和中序遍历的分析重复值在前序遍历和中序遍历中不会存在重复的item,因为如果存在重复的值,那么其表达的二叉树一定会产生歧义。 例如:preorder =原创 2018-01-09 21:10:08 · 90 阅读 · 0 评论 -
63. Unique Paths II
描述: 唯一路径:意思就是从[0,0]到[n,m](最右下角的方格)的路径 在矩阵中,0表示可通行,1表示有阻碍。求有多少条唯一路径。具体分析: 运用动态规划,result[i][j]=result[i-1][j]+result[i][j-1]; - 其中result[i][j]表示的是到达[i,j]的方格时,有多少条唯一路径; - 所以result[i][j]=result[i原创 2018-01-10 12:22:36 · 138 阅读 · 0 评论 -
leetcode 算法题的技巧总结
BST Binary Search Tree原创 2018-09-04 19:59:54 · 204 阅读 · 0 评论 -
编程之美--第二章 读书笔记
2.1 求二进制数中的1的个数最优解法:复杂度为O(k) k为二进制中1的个数public int count(int n){ int num=0; while(n){ //从后往前数‘1’的个数 //n&(n-1)这种方式可以消去一个‘1’ //e.g. 10000&01111=00000 n...原创 2018-09-05 20:20:27 · 99 阅读 · 0 评论