Leetcode#949. Largest Time for Given Digits
ProblemGiven an array arr of 4 digits, find the latest 24-hour time that can be made using each digit exactly once.
24-hour times are formatted as "HH:MM", where HH is between 00 and 23, and MM is between 00 and 59. The earliest 24-hour time is 00:00, and the latest is 23:59.
Return the latest 24-hour time in "HH:MM" format. If no valid time can be made, return an empty string.
Example 1:
1234Input: arr = [1,2,3,4]Output: "23:41"Explanation: The valid 24-hour times ...
Leetcode#205. Isomorphic Strings
ProblemGiven two strings s and t, determine if they are isomorphic.
Two strings s and t are isomorphic if the characters in s can be replaced to get t.
All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character, but a character may map to itself.
Example 1:
Input: s = “egg”, t = “add”
Output: true
Explanation:
The strings s and t can be made identical by:
Mapping 'e' to 'a ...
Leetcode#383. Ransom Note
ProblemGiven two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise.
Each letter in magazine can only be used once in ransomNote.
Example 1:
123Input: ransomNote = "a", magazine = "b"Output: false
Example 2:
12Input: ransomNote = "aa", magazine = "ab"Output: false
Example 3:
123Input: ransomNote = "aa", magazine = "aab"Output: true
Constraints:
1 <= ...
Leetcode#20. Valid Parentheses
ProblemGiven a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
An input string is valid if:
Open brackets must be closed by the same type of brackets.
Open brackets must be closed in the correct order.
Every close bracket has a corresponding open bracket of the same type.
Example 1:
123Input: s = "()"Output: true
Example 2:
123Input: s = "()[]{}&q ...
Leetcode#76. Minimum Window Substring
ProblemGiven two strings s and t of lengths m and n respectively, return the minimum window
substring
of
1s
such that every character in
1t
(including duplicates) is included in the window
. If there is no such substring, return
the empty string
1""
.
The testcases will be generated such that the answer is unique.
Example 1:
1234Input: s = "ADOBECODEBANC", t = "ABC"Output: "BANC"Explanation: The minimum window substring "BANC" includes 'A ...
Leetcode#5. Longest Palindromic Substring
ProblemGiven a string s, return the longest
palindromic
substring
in
1s
.
Example 1:
1234Input: s = "babad"Output: "bab"Explanation: "aba" is also a valid answer.
Example 2:
123Input: s = "cbbd"Output: "bb"
Constraints:
1 <= s.length <= 1000
s consist of only digits and English letters.
Solve123456789101112131415161718192021class Solution: def longestPalindrome(self, s: str) -> str: res = "" for i in range ...
Leetcode#392. Is Subsequence
ProblemGiven two strings s and t, return true if s is a subsequence of t, or false otherwise.
A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a subsequence of "abcde" while "aec" is not).
Example 1:
123Input: s = "abc", t = "ahbgdc"Output: true
Example 2:
123Input: s = "axc ...
Leetcode#1456. Maximum Number of Vowels in a Substring of Given Length
ProblemGiven a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k.
Vowel letters in English are 'a', 'e', 'i', 'o', and 'u'.
Example 1:
1234Input: s = "abciiidef", k = 3Output: 3Explanation: The substring "iii" contains 3 vowel letters.
Example 2:
1234Input: s = "aeiou", k = 2Output: 2Explanation: Any substring of length 2 contains 2 vowels.
Example 3:
1234Input: s = &qu ...
Leetcode#1768. Merge Strings Alternately
ProblemYou are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional letters onto the end of the merged string.
Return the merged string.
Example 1:
1234567Input: word1 = "abc", word2 = "pqr"Output: "apbqcr"Explanation: The merged string will be merged as so:word1: a b cword2: p q rmerged: a p b q c r
Example 2:
1234567Input: word1 = & ...
Leetcode#139. Word Break
ProblemGiven a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words.
Note that the same word in the dictionary may be reused multiple times in the segmentation.
Example 1:
1234Input: s = "leetcode", wordDict = ["leet","code"]Output: trueExplanation: Return true because "leetcode" can be segmented as "leet code".
Example 2:
12345Input: s = "applepenap ...