Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 677ff6d

Browse files
authored
Merge pull request neetcode-gh#2300 from singhaniket98/patch-1
0535-encode-and-decode-tinyurl.java
2 parents 9fcf47c + 2ab874f commit 677ff6d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
public class Codec {
2+
Map<String, String> map = new HashMap<>();
3+
4+
// Encodes a URL to a shortened URL.
5+
public String encode(String longUrl) {
6+
String key = "gjhgjhg7666";
7+
map.put(key, longUrl);
8+
return key;
9+
}
10+
11+
// Decodes a shortened URL to its original URL.
12+
public String decode(String shortUrl) {
13+
return map.get(shortUrl);
14+
15+
}
16+
}

0 commit comments

Comments
 (0)