Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c31f23c

Browse files
committed
增加No535
1 parent 38c56a9 commit c31f23c

File tree

6 files changed

+39
-4
lines changed

6 files changed

+39
-4
lines changed

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,15 @@
8686
| No196 | [196. 删除重复的电子邮箱](https://leetcode-cn.com/problems/delete-duplicate-emails/) | [MySql](https://github.com/Programming-With-Love/leetcode/blob/master/leetcode/SQL/No196.sql) | 判断Email相等而且id不能相等。 |
8787
| No197 | [197. 上升的温度](https://leetcode-cn.com/problems/rising-temperature/) | [MySql](https://github.com/Programming-With-Love/leetcode/blob/master/leetcode/SQL/No197.sql) | 采用DATEDIFF函数 并且其结果等于1。 |
8888

89+
---
90+
91+
####Hash
92+
93+
| # | Title | Solution | Note |
94+
| ----- | ------------------------------------------------------------ | -------- | ---- |
95+
| No535 | [535. TinyURL 的加密与解密](https://leetcode-cn.com/problems/encode-and-decode-tinyurl/) | | |
96+
| | | | |
97+
| | | | |
98+
8999

90100

leetcode/hashtable/No349.java renamed to leetcode/hash/No349.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package Algorithm.leetcode.hashtable;
1+
package Algorithm.leetcode.hash;
22

33
import java.util.HashSet;
44
import java.util.Set;

leetcode/hashtable/No389.java renamed to leetcode/hash/No389.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package Algorithm.leetcode.hashtable;
1+
package Algorithm.leetcode.hash;
22

33
/**
44
*

leetcode/hashtable/No409.java renamed to leetcode/hash/No409.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package Algorithm.leetcode.hashtable;
1+
package Algorithm.leetcode.hash;
22

33
import java.util.HashSet;
44
import java.util.Set;

leetcode/hash/No535.java

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package Algorithm.leetcode.hash;
2+
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
6+
/**
7+
*
8+
* Created by tujietg on Feb 11, 2020
9+
*/
10+
public class No535 {
11+
12+
Map<Integer, String> map = new HashMap<>();
13+
int i = 0;
14+
15+
// Encodes a URL to a shortened URL.
16+
public String encode(String longUrl) {
17+
map.put(i, longUrl);
18+
return "http://tinyurl.com/" + i++;
19+
}
20+
21+
// Decodes a shortened URL to its original URL.
22+
public String decode(String shortUrl) {
23+
return map.get(Integer.parseInt(shortUrl.replace("http://tinyurl.com/", "")));
24+
}
25+
}

leetcode/hashtable/No771.java renamed to leetcode/hash/No771.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package Algorithm.leetcode.hashtable;
1+
package Algorithm.leetcode.hash;
22

33
import java.util.HashSet;
44

0 commit comments

Comments
 (0)