We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 9fcf47c + 2ab874f commit 677ff6dCopy full SHA for 677ff6d
java/0535-encode-and-decode-tinyurl.java
@@ -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