LeetCode
uzck
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode 771
Problem771 题目 You’re given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how m...原创 2018-12-09 20:12:52 · 377 阅读 · 0 评论 -
LeetCode905 Sort Array By Parity
Problem905 Sort Array By Parity Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A. You may return any answer ar...原创 2018-12-10 15:43:45 · 228 阅读 · 0 评论 -
LeetCode876 Middle of the Linked List
题目原意是找一个链表的中间结点,如果中间结点有两个,取靠后的那个 沙雕解法 public class ListNode { public int val; public ListNode next; public ListNode(int val) { this.val = val; } } 给定的是结点数据结构是这样的,因此不能直接用Java里...原创 2019-01-16 11:03:19 · 220 阅读 · 0 评论 -
LeetCode766. Toeplitz Matrix
题意 判断一个矩阵是不是Toeplitz矩阵 Toeplitz矩阵需要满足的条件 [123451239512] \left[ \begin{matrix} 1 & 2 & 3 & 4 \\ 5 & 1 & 2 & 3 \\ 9 & 5 & 1 &am...原创 2019-01-16 16:03:21 · 341 阅读 · 0 评论 -
LeetCode739 Daily Temperatures
题目描述 给出连续若干天的气温数据如[73, 74, 75, 71, 69, 72, 76, 73],输出多少天后气温会高于当天,上面例子的输出结果为[1, 1, 4, 2, 1, 1, 0, 0]。温度的范围从30到100,数据长度1到30000。 蒟蒻的解法 public int[] dailyTemperatures(int[] T) { int[] result = new int[T....原创 2019-03-20 22:07:10 · 277 阅读 · 0 评论 -
LeetCode 260 Single Number III
找出数组中只出现一次的两个数 题目描述:输入一个整型数组,数组中只有两个数字只出现了一次,其他的数都出现了两次。要求找出那两个数字,对于输出结果的顺序没有要求,时间复杂度要求在线性时间且只使用常数空间 1. 用Map的解法 这种方法比较直接,但是不符合线性时间和常数空间的要求。遍历的时候把每个数出现的次数存储到一个map中,再遍历一遍这个map找到出现次数为1的数即可。 /** * 6ms 19....原创 2019-10-07 20:50:36 · 196 阅读 · 0 评论 -
LeetCode 153 Find Minimum in Rotated Sorted Array
找出有序旋转数组里的最小值 假设将一个升序数组按照某个点进行旋转[0,1,2,3,4,5,6,7]可能变成[4,5,6,7,0,1,2],然后找出旋转后的数组中的最小值,数组中不含重复数值。 1. 暴力法 可以知道除了没有旋转的情况下,最小的数位于数组中间,因此从后面往前搜索,如果找到了nums[end-1] > nums[end],那么nums[end]就是最小的值。 public int...原创 2019-10-08 09:07:48 · 180 阅读 · 0 评论
分享