auto commit

This commit is contained in:
CyC2018
2019-10-27 00:52:52 +08:00
parent 898bff377b
commit 39e10a02d9
30 changed files with 1050 additions and 350 deletions

View File

@ -10,12 +10,16 @@
- Java 中的 **HashSet** 用于存储一个集合可以查找元素是否在集合中如果元素有穷并且范围不大那么可以用一个布尔数组来存储一个元素是否存在例如对于只有小写字符的元素就可以用一个长度为 26 的布尔数组来存储一个字符集合使得空间复杂度降低为 O(1)
- Java 中的 **HashMap** 主要用于映射关系从而把两个元素联系起来HashMap 也可以用来对元素进行计数统计此时键为元素值为计数 HashSet 类似如果元素有穷并且范围不大可以用整型数组来进行统计在对一个内容进行压缩或者其它转换时利用 HashMap 可以把原始内容和转换后的内容联系起来例如在一个简化 url 的系统中 [Leetcdoe : 535. Encode and Decode TinyURL (Medium)](https://leetcode.com/problems/encode-and-decode-tinyurl/description/),利用 HashMap 就可以存储精简后的 url 到原始 url 的映射,使得不仅可以显示简化的 url也可以根据简化的 url 得到原始 url 从而定位到正确的资源。
Java 中的 **HashMap** 主要用于映射关系从而把两个元素联系起来HashMap 也可以用来对元素进行计数统计此时键为元素值为计数 HashSet 类似如果元素有穷并且范围不大可以用整型数组来进行统计在对一个内容进行压缩或者其它转换时利用 HashMap 可以把原始内容和转换后的内容联系起来例如在一个简化 url 的系统中 [Leetcdoe : 535. Encode and Decode TinyURL (Medium)
[Leetcode](https://leetcode.com/problems/encode-and-decode-tinyurl/description/),利用 HashMap 就可以存储精简后的 url 到原始 url 的映射,使得不仅可以显示简化的 url也可以根据简化的 url 得到原始 url 从而定位到正确的资源<E8B584>) / [力扣](https://leetcode-cn.com/problems/encode-and-decode-tinyurl/description/),利用 HashMap 就可以存储精简后的 url 到原始 url 的映射,使得不仅可以显示简化的 url也可以根据简化的 url 得到原始 url 从而定位到正确的资源<E8B584>)
# 1. 数组中两个数的和为给定值
[1. Two Sum (Easy)](https://leetcode.com/problems/two-sum/description/)
1\. Two Sum (Easy)
[Leetcode](https://leetcode.com/problems/two-sum/description/) / [力扣](https://leetcode-cn.com/problems/two-sum/description/)
可以先对数组进行排序然后使用双指针方法或者二分查找方法这样做的时间复杂度为 O(NlogN)空间复杂度为 O(1)
@ -37,7 +41,9 @@ public int[] twoSum(int[] nums, int target) {
# 2. 判断数组是否含有重复元素
[217. Contains Duplicate (Easy)](https://leetcode.com/problems/contains-duplicate/description/)
217\. Contains Duplicate (Easy)
[Leetcode](https://leetcode.com/problems/contains-duplicate/description/) / [力扣](https://leetcode-cn.com/problems/contains-duplicate/description/)
```java
public boolean containsDuplicate(int[] nums) {
@ -51,7 +57,9 @@ public boolean containsDuplicate(int[] nums) {
# 3. 最长和谐序列
[594. Longest Harmonious Subsequence (Easy)](https://leetcode.com/problems/longest-harmonious-subsequence/description/)
594\. Longest Harmonious Subsequence (Easy)
[Leetcode](https://leetcode.com/problems/longest-harmonious-subsequence/description/) / [力扣](https://leetcode-cn.com/problems/longest-harmonious-subsequence/description/)
```html
Input: [1,3,2,2,5,2,3,7]
@ -79,7 +87,9 @@ public int findLHS(int[] nums) {
# 4. 最长连续序列
[128. Longest Consecutive Sequence (Hard)](https://leetcode.com/problems/longest-consecutive-sequence/description/)
128\. Longest Consecutive Sequence (Hard)
[Leetcode](https://leetcode.com/problems/longest-consecutive-sequence/description/) / [力扣](https://leetcode-cn.com/problems/longest-consecutive-sequence/description/)
```html
Given [100, 4, 200, 1, 3, 2],