数据结构算法
Stwilsoon
深入浅出 清晰透彻
展开
-
爬楼梯算法的五种解决办法-简单演示
下面贴出五种解法: 首先简单递推可知 一级 1 种 二级 2 种 三级 3 种 四级 5 种 五级 8 种 N级 (N-1)的走法数+(N-2)的走法和/** * 递归算法 一行 时间复制度O(2^(N/2))~O(2^N) 空间复杂度O(N) */public int fib02(int n){ return n==1||n==2?n:fi原创 2019-11-29 11:02:57 · 888 阅读 · 0 评论 -
LeetCode Search in Rotated Sorted Array 解法
https://leetcode.com/problems/search-in-rotated-sorted-array/description/原题链接 Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4原创 2018-01-23 20:10:27 · 222 阅读 · 0 评论 -
LeetCode Subsets 解法
https://leetcode.com/problems/subsets/description/原题链接给定一个含不同整数的集合,返回其所有的子集 注意 子集中的元素排列必须是非降序的,解集必须不包含重复的子集如果 S = [1,2,3],有如下的解:[ [3], [1], [2], [1,2,3], [1,3], [2,3], [1,2],原创 2018-01-22 21:48:34 · 285 阅读 · 0 评论 -
LeetCode Maximum Depth of Binary Tree 解法
https://leetcode.com/problems/maximum-depth-of-binary-tree/description/原题链接原文: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path原创 2018-01-24 21:47:23 · 223 阅读 · 0 评论