码迷,mamicode.com
首页 >  
搜索关键字:solution upgrade    ( 13024个结果
跳台阶
解题思路:通过找规律,发现其实这也是斐波那契数列 # -*- 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
letcode 两个数组求交集,哈希解法
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
leetcode 124. 二叉树中的最大路径和
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
面试题34. 二叉树中和为某一值的路径
看到返回List就好奇试了一下 List<List<Integer>> res = new List<>(); 结果果然还是不行的。 这道题的思路很好 理解,先序遍历将当前节点值添加进路径。 如果符合一条路径的标准就在res存做一个答案。 遍历到null就返回到上一层,然后会有一个removeLas ...
分类:其他好文   时间:2021-04-01 13:22:02    阅读次数:0
3.30刷题记录 Triangle
动态规划题,根据动态规划,选择最短的路径 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. 旋转图像 + 数组遍历 + 思维
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
[CF452E] Three strings
\(\text{Problem}:\)Three strings \(\text{Solution}:\) 仿照 \(\text{SA}\) 连接多个串的方式,我们可以把这三个串连成:\(A+\)#\(+B+\)?\(+C\) 的形式。那么 \(A,B,C\) 中相同的子串在 \(\text{SAM ...
分类:其他好文   时间:2021-03-30 13:18:03    阅读次数:0
52. 两个链表的第一个公共结点
/* 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
13024条   上一页 1 ... 17 18 19 20 21 ... 1303 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!