题目链接 167. 两数之和 II - 输入有序数组 题目分析 非常简单的一个题目,因为给定的是一个有序数组,我们可以直接使用双指针思想去寻找两个目标元素。如果num[left] + num[right]==target 就保存循环结果然后退出循环,否则就看大小移动left或者right指针。 其实 ...
分类:
编程语言 时间:
2020-07-20 10:20:44
阅读次数:
62
package LeetCode_122 /** * 122. Best Time to Buy and Sell Stock II * https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/description/ * * ...
分类:
其他好文 时间:
2020-07-19 18:07:26
阅读次数:
79
问题描述 给定一个可包含重复数字的序列,返回所有不重复的全排列。 示例: 输入: [1,1,2]输出:[ [1,1,2], [1,2,1], [2,1,1]] 来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/permutations-ii 解答 ...
分类:
其他好文 时间:
2020-07-19 17:55:22
阅读次数:
60
给定一个整数 n,生成所有由 1 ... n 为节点所组成的 二叉搜索树 。 示例: 输入:3 输出: [ [1,null,3,2], [3,2,null,1], [3,1,null,null,2], [2,1,3], [1,null,2,null,3] ] 解释: 以上的输出对应以下 5 种不同结 ...
分类:
其他好文 时间:
2020-07-19 17:50:40
阅读次数:
72
class Solution { public List<Integer> getRow(int rowIndex) { Integer[] res = new Integer[rowIndex+1]; Arrays.fill(res,1); for(int i = 1; i <= rowIndex ...
分类:
编程语言 时间:
2020-07-19 17:46:05
阅读次数:
79
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=105; const int mod=1e9+7; int n; struct matrix { ll a[maxn][maxn]; m ...
分类:
其他好文 时间:
2020-07-18 22:14:26
阅读次数:
75
i = 2;i = i++ + ++i;结果输出6,从左到右算,i++之后i为3,后边++i之后,i为4但i++取的是旧值2,所以2+4= 6 i = ++i + i++;结果为7,这就很容易困惑,其实只要记得++i的时候,i取得是最新的值,所以++i之后,i为3,后边i++之后i为4,但取旧值3, ...
分类:
其他好文 时间:
2020-07-18 16:08:35
阅读次数:
99
给定四个包含整数的数组列表 A , B , C , D ,计算有多少个元组 (i, j, k, l) ,使得 A[i] + B[j] + C[k] + D[l] = 0。 为了使问题简单化,所有的 A, B, C, D 具有相同的长度 N,且 0 ≤ N ≤ 500 。所有整数的范围在 -228 到 ...
分类:
其他好文 时间:
2020-07-18 15:37:40
阅读次数:
64
链接:https://leetcode-cn.com/problems/unique-binary-search-trees-ii/ 代码 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNo ...
分类:
其他好文 时间:
2020-07-18 13:39:30
阅读次数:
56
题解:hashset(没有达到进阶的要求) /** * Definition for singly-linked list. * class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = ...
分类:
其他好文 时间:
2020-07-18 11:31:09
阅读次数:
54