题目: 反转一个单链表。 示例: 输入: 1->2->3->4->5->NULL输出: 5->4->3->2->1->NULL进阶:你可以迭代或递归地反转链表。你能否用两种方法解决这道题? 来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/reve ...
分类:
编程语言 时间:
2020-07-03 21:41:43
阅读次数:
160
Given an array A of integers, return true if and only if we can partition the array into three non-empty parts with equal sums. Formally, we can parti ...
分类:
其他好文 时间:
2020-07-03 21:13:36
阅读次数:
57
283th 移动零 位置指示器法 我们将cnt看作位置指示器,易于发现规律:某个不为0的元素前面有几个0(cnt),他就会向前移动cnt个位置。 class Solution { public void moveZeroes(int[] nums) { int cnt = 0; for(int i ...
分类:
移动开发 时间:
2020-07-03 21:11:39
阅读次数:
64
66th 加一 模拟运算法 根据题目要求做一个模拟即可,需要注意的是最后的数组长度不一定为原数组长度,还可能会增加一位,因为类似于999会进位到1000。因此最后需要做一个判断。 class Solution { public int[] plusOne(int[] digits) { int[] ...
分类:
其他好文 时间:
2020-07-03 21:04:30
阅读次数:
58
问题描述 给定一个数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。 candidates 中的每个数字在每个组合中只能使用一次。 说明: 所有数字(包括目标数)都是正整数。解集不能包含重复的组合。 示例 1: 输入: ...
分类:
其他好文 时间:
2020-07-03 17:47:39
阅读次数:
59
作者:LeetCode-Solution链接:https://leetcode-cn.com/problems/shun-shi-zhen-da-yin-ju-zhen-lcof/solution/shun-shi-zhen-da-yin-ju-zhen-by-leetcode-solution/来 ...
分类:
其他好文 时间:
2020-07-03 17:35:27
阅读次数:
56
解题思路: 这道题是要将有序数组转为二叉搜索树,所谓二叉搜索树,是一种始终满足左<根<右(另外一种更直白的解释,二叉搜索树:空树或者二叉树的所有节点比他的左子节点大,比他的右子节点小。)的特性的二叉树,如果将二叉搜索树按中序遍历的话,得到的就是一个有序数组了。那么反过来,我们可以得知,根节点应该是有 ...
分类:
编程语言 时间:
2020-07-03 10:45:13
阅读次数:
60
ε=(´ο`*)))唉,继续加油,先实现功能 1 #include <iostream> 2 #include <vector> 3 4 using namespace std; 5 6 class Solution { 7 public: 8 int removeDuplicates(vector ...
分类:
编程语言 时间:
2020-07-03 10:30:08
阅读次数:
70
数组中的重复数字 题目描述 Java代码 、import java.util.*; public class Solution { // Parameters: // numbers: an array of integers // length: the length of array numbe ...
分类:
编程语言 时间:
2020-07-03 01:09:01
阅读次数:
81
给定一个 n x n 矩阵,其中每行和每列元素均按升序排序,找到矩阵中第 k 小的元素。请注意,它是排序后的第 k 小元素,而不是第 k 个不同的元素。 Example: matrix = [ [ 1, 5, 9], [10, 11, 13], [12, 13, 15] ], k = 8, oupu ...
分类:
其他好文 时间:
2020-07-02 23:20:46
阅读次数:
91