535. Encode and Decode TinyURL

535. Encode and Decode TinyURL Note: This is a companion problem to the System Design problem: Design TinyURL. TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl and it returns a short URL such as http://tinyurl.com/4e9iAk. Design a class to encode a URL and decode a tiny URL. There is no restriction on how your encode/decode algorithm should work. You just need to ensure that a URL can be encoded to a tiny URL and the tiny URL can be decoded to the original URL....

<span title='2021-04-30 00:00:00 +0000 UTC'>April 30, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

28. Implement strStr()

28. Implement strStr() Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Clarification: What should we return when needle is an empty string? This is a great question to ask during an interview. For the purpose of this problem, we will return 0 when needle is an empty string. This is consistent to C’s strstr() and Java’s indexOf()....

<span title='2021-04-27 00:00:00 +0000 UTC'>April 27, 2021</span>&nbsp;·&nbsp;4 min&nbsp;·&nbsp;volyx

567. Permutation in String

567. Permutation in String Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string’s permutations is the substring of the second string. 1 2 3 4 5 Example 1: Input: s1 = "ab" s2 = "eidbaooo" Output: True Explanation: s2 contains one permutation of s1 ("ba"). 1 2 3 4 Example 2: Input:s1= "ab" s2 = "eidboaoo" Output: False Constraints:...

<span title='2021-04-27 00:00:00 +0000 UTC'>April 27, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1016. Binary String With Substrings Representing 1 To N

1016. Binary String With Substrings Representing 1 To N Given a binary string S (a string consisting only of ‘0’ and ‘1’s) and a positive integer N, return true if and only if for every integer X from 1 to N, the binary representation of X is a substring of S. 1 2 3 4 Example 1: Input: S = "0110", N = 3 Output: true 1 2 3 4 Example 2: Input: S = "0110", N = 4 Output: false Note:...

<span title='2021-04-17 00:00:00 +0000 UTC'>April 17, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1365. How Many Numbers Are Smaller Than the Current Number

1365. How Many Numbers Are Smaller Than the Current Number Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each nums[i] you have to count the number of valid j’s such that j != i and nums[j] < nums[i]. Return the answer in an array. 1 2 3 4 5 6 7 8 9 10 Example 1: Input: nums = [8,1,2,2,3] Output: [4,0,1,1,3] Explanation: For nums[0]=8 there exist four smaller numbers than it (1, 2, 2 and 3)....

<span title='2021-04-17 00:00:00 +0000 UTC'>April 17, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1813. Sentence Similarity III

1813. Sentence Similarity III A sentence is a list of words that are separated by a single space with no leading or trailing spaces. For example, “Hello World”, “HELLO”, “hello world hello world” are all sentences. Words consist of only uppercase and lowercase English letters. Two sentences sentence1 and sentence2 are similar if it is possible to insert an arbitrary sentence (possibly empty) inside one of these sentences such that the two sentences become equal....

<span title='2021-04-05 00:00:00 +0000 UTC'>April 5, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

763. Partition Labels

A string s of lowercase English letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing the size of these parts. 1 2 3 4 5 6 7 8 Example 1: Input: s = "ababcbacadefegdehijhklij" Output: [9,7,8] Explanation: The partition is "ababcbaca", "defegde", "hijhklij". This is a partition so that each letter appears in at most one part....

<span title='2020-06-24 00:00:00 +0000 UTC'>June 24, 2020</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx