diff --git a/java/0535-encode-and-decode-tinyurl.java b/java/0535-encode-and-decode-tinyurl.java new file mode 100644 index 000000000..56db59a72 --- /dev/null +++ b/java/0535-encode-and-decode-tinyurl.java @@ -0,0 +1,16 @@ +public class Codec { + Map map = new HashMap<>(); + + // Encodes a URL to a shortened URL. + public String encode(String longUrl) { + String key = "gjhgjhg7666"; + map.put(key, longUrl); + return key; + } + + // Decodes a shortened URL to its original URL. + public String decode(String shortUrl) { + return map.get(shortUrl); + + } +}