Tag: Python

  • [LeetCode] 1062. Longest Repeating Substring

    [LeetCode] 1062. Longest Repeating Substring

    Description Given a string s, find the length of the longest  substring without repeating characters. Example 1: Input: s = “abcabcbb” Output: 3 Explanation: The answer is “abc”, with the length of 3. Example 2: Input: s = “bbbbb” Output: 1 Explanation: The answer is “b”, with the length of 1. Example 3: Input: s = “pwwkew” Output:…

  • [LeetCode] 271. Encode and Decode Strings

    [LeetCode] 271. Encode and Decode Strings

    Description Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings. Machine 1 (sender) has the function: string encode(vector<string> strs) { // … your code return encoded_string; } Machine 2 (receiver) has the function: vector<string> decode(string s)…

  • [LeetCode] 49. Group Anagram

    [LeetCode] 49. Group Anagram

    Description Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Example 1: Input: strs = [“eat”,”tea”,”tan”,”ate”,”nat”,”bat”] Output: [[“bat”],[“nat”,”tan”],[“ate”,”eat”,”tea”]] Example 2: Input: strs = [“”] Output: [[“”]]…

  • [Leetcode] 217. Contains Duplicate

    [Leetcode] 217. Contains Duplicate

    Problem Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. Example 1: Input: nums = [1,2,3,1] Output: true Example 2: Input: nums = [1,2,3,4] Output: false Example 3: Input: nums = [1,1,1,3,3,4,3,2,4,2] Output: true Constraints: Explanation The simplest approach involves iterating twice through the array to…