International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a" maps to ".-", "b" maps to "-...", "c" maps to "-.-.", and so on. For convenience, the full…
S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sorted in some custom order previously. We want to permute the characters of T so that they match the order that S was…
You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones…
Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible…
We are given an array asteroids of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning…
A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0. Also, a self-dividing number is not…
Given a list of accounts where each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails representing emails of the account. Now, we would…
Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. Example 1: Example 2: Example 3: Solution in Python
You are keeping score for a baseball game with strange rules. The game consists of several rounds, where the scores of past rounds may affect future rounds' scores. At the beginning of the game, you start with an empty…
Initially on a notepad only one character 'A' is present. You can perform two operations on this notepad for each step: Copy All: You can copy all the characters present on the notepad (partial copy is not allowed)…
We define the usage of capitals in a word to be right when one of the following cases holds: All letters in this word are capitals, like "USA". All letters in this word are not capitals, like "leetcode". Only the first…
The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, return the Hamming distance between them. Example 1: Example 2…
Given two strings s and p, return an array of all the start indices of p's anagrams in s. You may return the answer in any order. Example 1: Example 2: Constraints: 1 <= s.length, p.length <= 3 * 104 s and p consist of…
You are given a string s, return the number of segments in the string. A segment is defined to be a contiguous sequence of non-space characters. Example 1: Example 2: Example 3: Example 4: Constraints: 0 <= s.length <=…
Given a string s, return the first non-repeating character in it and return its index. If it does not exist, return -1. Example 1: Example 2: Example 3: Constraints: 1 <= s.length <= 105 s consists of only lowercase…
Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; otherwise, it will…
Design a simplified version of Twitter where users can post tweets, follow/unfollow another user, and is able to see the 10 most recent tweets in the user's news feed. Implement the Twitter class: Twitter() Initializes…
Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. Example 1: Example 2: Constraints: 1 <= nums.length <= 105 k is in the range [1, the number of…
Given a string s, reverse only all the vowels in the string and return it. The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both cases. Example 1: Example 2: Constraints: 1 <= s.length <= 3 * 105 s…