- 博客(9)
- 收藏
- 关注
原创 LeetCode 167. Two Sum II - Input array is sorted
Given an array of integers that is alreadysorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers ...
2019-12-19 09:46:52 190
原创 LeetCode 153. Find Minimum in Rotated Sorted Array
153.Find Minimum in Rotated Sorted ArrayMedium1413192FavoriteShareSuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7]might b...
2019-12-18 22:06:51 106
原创 LeetCode 151. Reverse Words in a String
Given an input string, reverse the string word by word.Example 1:Input: "the sky is blue"Output:"blue is sky the"Example 2:Input: " hello world! "Output:"world! hello"Explanation:...
2019-12-18 10:41:21 96
原创 LeetCode 144. Binary Tree Preorder Traversal
Given a binary tree, return thepreordertraversal of its nodes' values.Example:Input:[1,null,2,3] 1 \ 2 / 3Output:[1,2,3]Follow up:Recursive solution is trivial, could...
2019-12-10 18:54:54 91
原创 LeetCode 141. Linked List Cycle
Given a linked list, determine if it has a cycle in it.To represent a cycle in the given linked list, we use an integerposwhich represents the position (0-indexed)in the linked list where tail co...
2019-12-07 08:35:48 170
原创 Java集合之ArrayList
相关类简介List接口的可调整大小的数组实现。size, isEmpty, get, set, iterator, and listIterator这些方法是常数时间,其他的方法都是O(n)。注意它不能保证同步,若要同步,可用: List list = Collections.synchronizedList(new ArrayList(...));同样的,如果在使用迭代器时使用了...
2019-12-04 13:25:31 126
原创 数据结构(八)——栈 in Java8
源码package java.util;/** * 栈是一个先进后出的数据结构,它继承于Vector,那表明它是线程安全的。 * @since JDK1.0 */publicclass Stack<E> extends Vector<E> { /** * 创建空栈的构造方法 */ public Stack() { ...
2019-12-04 10:48:28 198
原创 Java集合之Set
简述set是一种没有重复元素的集合。也就是说用equals方法没有相等的元素,最多只有一个null。相关类public interface Set<E> extends Collection<E> { // 查询操作 /** * 元素个数,如果超过Integer.MAX_VALUE,则为Integer.MAX_VALUE */...
2019-12-03 22:25:09 121
原创 数据结构(七)——队列
定义队列支持FIFO,尾部添加、头部删除队列种类单队列存在“假溢出”:头部有空位,尾部无法添加了循环队列当rear要大于队列长度时,rear = (rear - size) % size判断队列满:1.加个标识flag2.(rear - front) % size = 1当rear > front时,队列中元素个数=rear-front当rear < front时...
2019-12-03 14:52:33 166
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人