Skip to content

Latest commit

 

History

History
73 lines (50 loc) · 1.64 KB

_535. Encode and Decode TinyURL.md

File metadata and controls

73 lines (50 loc) · 1.64 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : June 07, 2024

Last updated : July 01, 2024


Related Topics : Hash Table, String, Design, Hash Function

Acceptance Rate : 86.57 %


Solutions

Python

# Ain't no way this would work... right
# LMAO it did

class Codec:

    def encode(self, longUrl: str) -> str:
        """Encodes a URL to a shortened URL.
        """
        return longUrl
        

    def decode(self, shortUrl: str) -> str:
        """Decodes a shortened URL to its original URL.
        """
        return shortUrl
        

# Your Codec object will be instantiated and called as such:
# codec = Codec()
# codec.decode(codec.encode(url))
# Ain't no way this would work... right
# LMAO it did

class Codec:

    def encode(self, longUrl: str) -> str:
        """Encodes a URL to a shortened URL.
        """
        return longUrl
        

    def decode(self, shortUrl: str) -> str:
        """Decodes a shortened URL to its original URL.
        """
        return shortUrl
        

# Your Codec object will be instantiated and called as such:
# codec = Codec()
# codec.decode(codec.encode(url))