解题思路:通过找规律,发现其实这也是斐波那契数列 # -*- coding:utf-8 -*- class Solution: def jumpFloor(self, number): #n=1 f(n)=1 #n=2,11,2, f(n)=2 #n=3,111,12,21 f(n)=3 #n=4, ...
分类:
其他好文 时间:
2021-04-02 13:00:23
阅读次数:
0
class Solution(object): def intersect(self, nums1, nums2): if len(nums1) > len(nums2): return self.intersect(nums2, nums1) m = collections.Counter() f ...
分类:
编程语言 时间:
2021-04-01 13:42:22
阅读次数:
0
一.二叉树的前序遍历 https://leetcode-cn.com/problems/binary-tree-preorder-traversal/ class Solution { public List<Integer> preorderTraversal(TreeNode root) { L ...
分类:
其他好文 时间:
2021-04-01 13:41:51
阅读次数:
0
1 class Solution { 2 private: 3 int maxSum = INT_MIN; 4 5 public: 6 int maxGain(TreeNode* node) { 7 if (node == nullptr) { 8 return 0; 9 } 10 11 // 递归 ...
分类:
其他好文 时间:
2021-04-01 13:30:06
阅读次数:
0
看到返回List就好奇试了一下 List<List<Integer>> res = new List<>(); 结果果然还是不行的。 这道题的思路很好 理解,先序遍历将当前节点值添加进路径。 如果符合一条路径的标准就在res存做一个答案。 遍历到null就返回到上一层,然后会有一个removeLas ...
分类:
其他好文 时间:
2021-04-01 13:22:02
阅读次数:
0
动态规划题,根据动态规划,选择最短的路径 class Solution { public: int minimumTotal(vector<vector<int>>& triangle) { int n = triangle.size(); vector<int> f(n); f[0] = tria ...
分类:
其他好文 时间:
2021-03-31 12:26:06
阅读次数:
0
class Solution { public static void main(String[] args) { int[] arr = new int[]{0, 1, 2, 2, 2, 3, 4, 5}; //int index = binarySearch(arr, 2); //int ind ...
分类:
其他好文 时间:
2021-03-31 11:46:55
阅读次数:
0
48. 旋转图像 LeetCode_48 题目描述 方法一:使用辅助数组 class Solution { public void rotate(int[][] matrix) { //第i,j的元素翻转后出现在倒数第i列的第j个元素 int m = matrix.length; int n = m ...
分类:
编程语言 时间:
2021-03-30 13:19:14
阅读次数:
0
\(\text{Problem}:\)Three strings \(\text{Solution}:\) 仿照 \(\text{SA}\) 连接多个串的方式,我们可以把这三个串连成:\(A+\)#\(+B+\)?\(+C\) 的形式。那么 \(A,B,C\) 中相同的子串在 \(\text{SAM ...
分类:
其他好文 时间:
2021-03-30 13:18:03
阅读次数:
0
/* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } };*/class Solution { public: ListNode* FindFirstCommonNo ...
分类:
其他好文 时间:
2021-03-29 12:50:50
阅读次数:
0