1207. Unique Number of Occurrences

1207. Unique Number of Occurrences Given an array of integers arr, write a function that returns true if and only if the number of occurrences of each value in the array is unique. 1 2 3 4 5 Example 1: Input: arr = [1,2,2,1,1,3] Output: true Explanation: The value 1 has 3 occurrences, 2 has 2 and 3 has 1. No two values have the same number of occurrences. 1 2 3 4 Example 2: Input: arr = [1,2] Output: false 1 2 3 4 Example 3: Input: arr = [-3,0,1,-3,1,1,1,-3,10,0] Output: true Constraints:...

<span title='2021-05-09 00:00:00 +0000 UTC'>May 9, 2021</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;volyx

1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence

1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence Given a sentence that consists of some words separated by a single space, and a searchWord. You have to check if searchWord is a prefix of any word in sentence. Return the index of the word in sentence where searchWord is a prefix of this word (1-indexed). If searchWord is a prefix of more than one word, return the index of the first word (minimum index)....

<span title='2021-05-08 00:00:00 +0000 UTC'>May 8, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

1844. Replace All Digits with Characters

1844. Replace All Digits with Characters You are given a 0-indexed string s that has lowercase English letters in its even indices and digits in its odd indices. There is a function shift(c, x), where c is a character and x is a digit, that returns the xth character after c. For example, shift(‘a’, 5) = ‘f’ and shift(‘x’, 0) = ‘x’. For every odd index i, you want to replace the digit s[i] with shift(s[i-1], s[i])....

<span title='2021-05-08 00:00:00 +0000 UTC'>May 8, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1845. Seat Reservation Manager

1845. Seat Reservation Manager Design a system that manages the reservation state of n seats that are numbered from 1 to n. Implement the SeatManager class: SeatManager(int n) Initializes a SeatManager object that will manage n seats numbered from 1 to n. All seats are initially available. int reserve() Fetches the smallest-numbered unreserved seat, reserves it, and returns its number. void unreserve(int seatNumber) Unreserves the seat with the given seatNumber. 1 2 3 4 5 6 7 Example 1: Input ["SeatManager", "reserve", "reserve", "unreserve", "reserve", "reserve", "reserve", "reserve", "unreserve"] [[5], [], [], [2], [], [], [], [], [5]] Output [null, 1, 2, null, 2, 3, 4, 5, null] Explanation SeatManager seatManager = new SeatManager(5); // Initializes a SeatManager with 5 seats....

<span title='2021-05-08 00:00:00 +0000 UTC'>May 8, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

1846. Maximum Element After Decreasing and Rearranging

1846. Maximum Element After Decreasing and Rearranging You are given an array of positive integers arr. Perform some operations (possibly none) on arr so that it satisfies these conditions: The value of the first element in arr must be 1. The absolute difference between any 2 adjacent elements must be less than or equal to 1. In other words, abs(arr[i] - arr[i - 1]) <= 1 for each i where 1 <= i < arr....

<span title='2021-05-08 00:00:00 +0000 UTC'>May 8, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

859. Buddy Strings

859. Buddy Strings Given two strings a and b, return true if you can swap two letters in a so the result is equal to b, otherwise, return false. Swapping letters is defined as taking two indices i and j (0-indexed) such that i != j and swapping the characters at a[i] and a[j]. For example, swapping at indices 0 and 2 in “abcd” results in “cbad”. 1 2 3 4 5 Example 1: Input: a = "ab", b = "ba" Output: true Explanation: You can swap a[0] = 'a' and a[1] = 'b' to get "ba", which is equal to b....

<span title='2021-05-08 00:00:00 +0000 UTC'>May 8, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

98. Validate Binary Search Tree

98. Validate Binary Search Tree Given the root of a binary tree, determine if it is a valid binary search tree (BST). A valid BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node’s key. The right subtree of a node contains only nodes with keys greater than the node’s key. Both the left and right subtrees must also be binary search trees....

<span title='2021-05-07 00:00:00 +0000 UTC'>May 7, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

211. Design Add and Search Words Data Structure

211. Design Add and Search Words Data Structure Design a data structure that supports adding new words and finding if a string matches any previously added string. Implement the WordDictionary class: WordDictionary() Initializes the object. void addWord(word) Adds word to the data structure, it can be matched later. bool search(word) Returns true if there is any string in the data structure that - matches word or false otherwise. word may contain dots ‘....

<span title='2021-05-06 00:00:00 +0000 UTC'>May 6, 2021</span>&nbsp;·&nbsp;4 min&nbsp;·&nbsp;volyx

72. Edit Distance

72. Edit Distance Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You have the following three operations permitted on a word: Insert a character Delete a character Replace a character 1 2 3 4 5 6 7 8 Example 1: Input: word1 = "horse", word2 = "ros" Output: 3 Explanation: horse -> rorse (replace 'h' with 'r') rorse -> rose (remove 'r') rose -> ros (remove 'e') 1 2 3 4 5 6 7 8 9 10 Example 2: Input: word1 = "intention", word2 = "execution" Output: 5 Explanation: intention -> inention (remove 't') inention -> enention (replace 'i' with 'e') enention -> exention (replace 'n' with 'x') exention -> exection (replace 'n' with 'c') exection -> execution (insert 'u') Constraints:...

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

720. Longest Word in Dictionary

720. Longest Word in Dictionary Given an array of strings words representing an English Dictionary, return the longest word in words that can be built one character at a time by other words in words. If there is more than one possible answer, return the longest word with the smallest lexicographical order. If there is no answer, return the empty string. 1 2 3 4 5 Example 1: Input: words = ["w","wo","wor","worl","world"] Output: "world" Explanation: The word "world" can be built one character at a time by "w", "wo", "wor", and "worl"....

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

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

1828. Queries on Number of Points Inside a Circle

1828. Queries on Number of Points Inside a Circle You are given an array points where points[i] = [xi, yi] is the coordinates of the ith point on a 2D plane. Multiple points can have the same coordinates. You are also given an array queries where queries[j] = [xj, yj, rj] describes a circle centered at (xj, yj) with a radius of rj. For each query queries[j], compute the number of points inside the jth circle....

<span title='2021-04-24 00:00:00 +0000 UTC'>April 24, 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