id int64 1 2k | content stringlengths 272 88.9k | title stringlengths 3 77 | title_slug stringlengths 3 79 | question_content stringlengths 230 5k | question_hints stringclasses 695
values | tag stringclasses 618
values | level stringclasses 3
values | similar_question_ids stringclasses 822
values |
|---|---|---|---|---|---|---|---|---|
783 | hey everyone welcome back and let's write some more neat code today so today let's solve the problem minimum distance between BST nodes so we're given the root of a binary search tree and that's the first observation that you should make this is not just a regular binary tree it is a binary search tree which has the so... | Minimum Distance Between BST Nodes | search-in-a-binary-search-tree | Given the `root` of a Binary Search Tree (BST), return _the minimum difference between the values of any two different nodes in the tree_.
**Example 1:**
**Input:** root = \[4,2,6,1,3\]
**Output:** 1
**Example 2:**
**Input:** root = \[1,0,48,null,null,12,49\]
**Output:** 1
**Constraints:**
* The number of nodes... | null | Tree,Binary Search Tree,Binary Tree | Easy | 270,784 |
241 | Hello gas welcome back to my channel different way so add paranthesis and its difficulty level is medium before starting it is a one minute message for all of you because I have also started my YouTube channel so what is it you guys can connect one To make it easier than others, what little I have done is that I have c... | Different Ways to Add Parentheses | different-ways-to-add-parentheses | Given a string `expression` of numbers and operators, return _all possible results from computing all the different possible ways to group numbers and operators_. You may return the answer in **any order**.
The test cases are generated such that the output values fit in a 32-bit integer and the number of different res... | null | Math,String,Dynamic Programming,Recursion,Memoization | Medium | 95,224,282,2147,2328 |
119 | hey so welcome back and here's another lead code problem so today we're doing one called Pascal's triangle so all that we're given here is a two-dimensional we're given here is a two-dimensional we're given here is a two-dimensional Matrix that kind of resembles more of a staircase I know they represent it as a triangl... | Pascal's Triangle II | pascals-triangle-ii | Given an integer `rowIndex`, return the `rowIndexth` (**0-indexed**) row of the **Pascal's triangle**.
In **Pascal's triangle**, each number is the sum of the two numbers directly above it as shown:
**Example 1:**
**Input:** rowIndex = 3
**Output:** \[1,3,3,1\]
**Example 2:**
**Input:** rowIndex = 0
**Output:** \[... | null | Array,Dynamic Programming | Easy | 118,2324 |
49 | take a look at a legal problem called group anagrams so given an array of strains and then group the anagrams together you can return the answer in any order an enneagram is a word or phrase formed by rearranging the letters of a different word or phrase typically using all the original letters exactly once so you can ... | Group Anagrams | group-anagrams | 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... | null | Hash Table,String,Sorting | Medium | 242,249 |
135 | hey guys welcome back to my series of videos of me solving lead code problems from scratch and now we're going to solve 135 candy you know I keep that candy more like okay so what's this it's a hard one cool there are n children standing in the line each child is assigned the rating value given in the integr array rati... | Candy | candy | There are `n` children standing in a line. Each child is assigned a rating value given in the integer array `ratings`.
You are giving candies to these children subjected to the following requirements:
* Each child must have at least one candy.
* Children with a higher rating get more candies than their neighbors.... | null | Array,Greedy | Hard | null |
48 | all right so this question is rotate image so you want to rotate the image by 90 degree clockwise so you know you don't need to allocate the memory to rotate so if you don't know the trick here's the trick so let's not look in the rotated image let's look at the original one so the idea is that you want to swap the rle... | Rotate Image | rotate-image | You are given an `n x n` 2D `matrix` representing an image, rotate the image by **90** degrees (clockwise).
You have to rotate the image [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm), which means you have to modify the input 2D matrix directly. **DO NOT** allocate another 2D matrix and do the rotati... | null | Array,Math,Matrix | Medium | 2015 |
678 | Hello Everyone and Welcome Back to my Channel Algorithm Hk Today I am going to write the code and also explain to you all the algorithm to solve this valid penis string which is there in lead code it is a medium level problem and we are going to Solve it using a Stack Data Structure and Ag Greedy Algorithm But before m... | Valid Parenthesis String | valid-parenthesis-string | Given a string `s` containing only three types of characters: `'('`, `')'` and `'*'`, return `true` _if_ `s` _is **valid**_.
The following rules define a **valid** string:
* Any left parenthesis `'('` must have a corresponding right parenthesis `')'`.
* Any right parenthesis `')'` must have a corresponding left p... | null | String,Dynamic Programming,Stack,Greedy | Medium | 763,2221 |
380 | question 380 insert delete get random at constant time complexity from liquid so the question is asking us to implement a randomized set class so this shows this is a design question and this class it's supposed to insert delete and get random at constant time complexity so when we are talking about constant time compl... | Insert Delete GetRandom O(1) | insert-delete-getrandom-o1 | Implement the `RandomizedSet` class:
* `RandomizedSet()` Initializes the `RandomizedSet` object.
* `bool insert(int val)` Inserts an item `val` into the set if not present. Returns `true` if the item was not present, `false` otherwise.
* `bool remove(int val)` Removes an item `val` from the set if present. Retur... | null | Array,Hash Table,Math,Design,Randomized | Medium | 381 |
403 | welcome to another video so let's start the question but before that let's start with the joke of the day so the job is how to ask for money from your dad example you can hold your mom hostage okay let's start the question so the first question i got the idea to this question last night while i was sleeping so a frog i... | Frog Jump | frog-jump | A frog is crossing a river. The river is divided into some number of units, and at each unit, there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water.
Given a list of `stones`' positions (in units) in sorted **ascending order**, determine if the frog can cross the river by... | null | Array,Dynamic Programming | Hard | 1952,2262 |
153 | hey what's up guys Nick white here I do tech encoding stuff on twitch and YouTube check the description for all my information please support my own you know whatever if you got Amazon Prime I got that twitch I got that patreon you can join the discord you like and subscribe all of you know all that stuff but I know yo... | Find Minimum in Rotated Sorted Array | find-minimum-in-rotated-sorted-array | Suppose an array of length `n` sorted in ascending order is **rotated** between `1` and `n` times. For example, the array `nums = [0,1,2,4,5,6,7]` might become:
* `[4,5,6,7,0,1,2]` if it was rotated `4` times.
* `[0,1,2,4,5,6,7]` if it was rotated `7` times.
Notice that **rotating** an array `[a[0], a[1], a[2], .... | Array was originally in ascending order. Now that the array is rotated, there would be a point in the array where there is a small deflection from the increasing sequence. eg. The array would be something like [4, 5, 6, 7, 0, 1, 2]. You can divide the search space into two and see which direction to go.
Can you think ... | Array,Binary Search | Medium | 33,154 |
306 | my name is eric lee and today i want to talk about recall 306 additive number ltd number is a string whose digits can form additive sequence and what do i mean let's let me give you an example for example one the input is one two three five eight if we record one as the first number and the one as a second number then ... | Additive Number | additive-number | An **additive number** is a string whose digits can form an **additive sequence**.
A valid **additive sequence** should contain **at least** three numbers. Except for the first two numbers, each subsequent number in the sequence must be the sum of the preceding two.
Given a string containing only digits, return `true... | null | String,Backtracking | Medium | 872 |
953 | hey everybody this is Larry this is day two of the February legal daily challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's spot where to find an alien dictionary 953 all right so yeah but possibly in a different order the order of the alphabet some present... | Verifying an Alien Dictionary | reverse-only-letters | In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different `order`. The `order` of the alphabet is some permutation of lowercase letters.
Given a sequence of `words` written in the alien language, and the `order` of the alphabet, return `true` if and only if the given `wor... | This problem is exactly like reversing a normal string except that there are certain characters that we have to simply skip. That should be easy enough to do if you know how to reverse a string using the two-pointer approach. | Two Pointers,String | Easy | null |
430 | welcome to July's LICO challenge today's problem is flatten a multi-level problem is flatten a multi-level problem is flatten a multi-level doubly-linked list I'm a little strapped doubly-linked list I'm a little strapped doubly-linked list I'm a little strapped on time today so I'll have to make a quick you're given a... | Flatten a Multilevel Doubly Linked List | flatten-a-multilevel-doubly-linked-list | You are given a doubly linked list, which contains nodes that have a next pointer, a previous pointer, and an additional **child pointer**. This child pointer may or may not point to a separate doubly linked list, also containing these special nodes. These child lists may have one or more children of their own, and so ... | null | null | Medium | null |
1,770 | hello guys today I will solve the question 1770 maximum score from performing multiplication operation the question is they will give us two arrays nums and multipliers and we need to return the maximum score by multiplying each digits of multiplier to the digits of the num and we have constant we can take the inputs f... | Maximum Score from Performing Multiplication Operations | minimum-deletions-to-make-character-frequencies-unique | You are given two **0-indexed** integer arrays `nums` and `multipliers` of size `n` and `m` respectively, where `n >= m`.
You begin with a score of `0`. You want to perform **exactly** `m` operations. On the `ith` operation (**0-indexed**) you will:
* Choose one integer `x` from **either the start or the end** of t... | As we can only delete characters, if we have multiple characters having the same frequency, we must decrease all the frequencies of them, except one. Sort the alphabet characters by their frequencies non-increasingly. Iterate on the alphabet characters, keep decreasing the frequency of the current character until it re... | String,Greedy,Sorting | Medium | 1355,2212 |
334 | hey guys welcome to a new video in today's video we're going to look at Elite code problem and the problem's name is increasing triplet subsequence so in this question we given an integer array called nums and we have to return a Boolean value true or false we have to return true if there exists a triplet of indexes i ... | Increasing Triplet Subsequence | increasing-triplet-subsequence | Given an integer array `nums`, return `true` _if there exists a triple of indices_ `(i, j, k)` _such that_ `i < j < k` _and_ `nums[i] < nums[j] < nums[k]`. If no such indices exists, return `false`.
**Example 1:**
**Input:** nums = \[1,2,3,4,5\]
**Output:** true
**Explanation:** Any triplet where i < j < k is valid.
... | null | Array,Greedy | Medium | 300,2122,2280 |
17 | That A Hello Hi Guys Posted In Funny People Come To The Video Tourist Question Is Letter To Minister Phone Number Pitch Set Given String Contents Images From Tonight Inclusive Return All Possible Letter Combinations Sweater Number To Deep Recent Updates To Letters Given Below Not Minutes So Acid And Nurses Parents Teac... | Letter Combinations of a Phone Number | letter-combinations-of-a-phone-number | Given a string containing digits from `2-9` inclusive, return all possible letter combinations that the number could represent. Return the answer in **any order**.
A mapping of digits to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.
**Example 1:**
**Input:** di... | null | Hash Table,String,Backtracking | Medium | 22,39,401 |
309 | Hello friends today I'm going to solve with code problem number 309 best time to buy and sell stock with cooldown in this problem we are given an array prices where each element represents the price of stock on that day and we need to find the maximum profit that we can achieve and the restrictions given to us is that ... | Best Time to Buy and Sell Stock with Cooldown | best-time-to-buy-and-sell-stock-with-cooldown | You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day.
Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times) with the following restrictions:
* After you sell your stock, yo... | null | Array,Dynamic Programming | Medium | 121,122 |
1,583 | hey everybody this is larry this is me going over q2 of the lead code daily con uh sorry delete code contest uh count unhappy friends so this ends up being a data structure lookup problem um but the idea is that and there's a lot of things to read about this problem uh but yeah but while you do that hit the like button... | Count Unhappy Friends | paint-house-iii | You are given a list of `preferences` for `n` friends, where `n` is always **even**.
For each person `i`, `preferences[i]` contains a list of friends **sorted** in the **order of preference**. In other words, a friend earlier in the list is more preferred than a friend later in the list. Friends in each list are denot... | Use Dynamic programming. Define dp[i][j][k] as the minimum cost where we have k neighborhoods in the first i houses and the i-th house is painted with the color j. | Array,Dynamic Programming | Hard | null |
427 | Peace be upon you, my dear friend. How are you doing? Oh God, you will be fine and in the best condition. God willing, today we will solve it together. If you don’t try the issue, go to the first one before you watch the video. And if you try, let’s be together, in the name of God. He is if you try, let’s be together, ... | Construct Quad Tree | construct-quad-tree | Given a `n * n` matrix `grid` of `0's` and `1's` only. We want to represent `grid` with a Quad-Tree.
Return _the root of the Quad-Tree representing_ `grid`.
A Quad-Tree is a tree data structure in which each internal node has exactly four children. Besides, each node has two attributes:
* `val`: True if the node r... | null | null | Medium | null |
392 | hey there fellow colors welcome back to another engaging episode called Master Quest today we are going to solve this subsequence problem but this time in Python so if you are interested in the solution for this question please check out the link in the description below otherwise let's try to implement this question i... | Is Subsequence | is-subsequence | Given 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... | null | Two Pointers,String,Dynamic Programming | Easy | 808,1051 |
718 | hello everyone today i will solve the question maximum length of repeated sub array the question type is medium one and the question statement is given two integers array numbers one and nums two return the maximum length of sub array that appears in both arrows this question is like the maximum length subsequence ques... | Maximum Length of Repeated Subarray | maximum-length-of-repeated-subarray | Given two integer arrays `nums1` and `nums2`, return _the maximum length of a subarray that appears in **both** arrays_.
**Example 1:**
**Input:** nums1 = \[1,2,3,2,1\], nums2 = \[3,2,1,4,7\]
**Output:** 3
**Explanation:** The repeated subarray with maximum length is \[3,2,1\].
**Example 2:**
**Input:** nums1 = \[0... | Use dynamic programming. dp[i][j] will be the answer for inputs A[i:], B[j:]. | Array,Binary Search,Dynamic Programming,Sliding Window,Rolling Hash,Hash Function | Medium | 209,2051 |
62 | Hello Guys Welcome Back To Decades And This Video Will See The Unique Pass Problem Wishes From List To Day 29th June Challenge So Let's Know Problem Statement In This Problem Organized At Gang Problem Organized At Gang Problem Organized At Gang Raped And Where To Find All Possible 500 Minus One Will Start from the firs... | Unique Paths | unique-paths | There is a robot on an `m x n` grid. The robot is initially located at the **top-left corner** (i.e., `grid[0][0]`). The robot tries to move to the **bottom-right corner** (i.e., `grid[m - 1][n - 1]`). The robot can only move either down or right at any point in time.
Given the two integers `m` and `n`, return _the nu... | null | Math,Dynamic Programming,Combinatorics | Medium | 63,64,174,2192 |
739 | hello everyone welcome to quartus camp we are 13th day of november later challenge and the problem we are going to cover in this video is daily temperatures so it is a medium category problem and the input given here is integer array which denotes temperature at each day and we have to return the number of days you hav... | Daily Temperatures | daily-temperatures | Given an array of integers `temperatures` represents the daily temperatures, return _an array_ `answer` _such that_ `answer[i]` _is the number of days you have to wait after the_ `ith` _day to get a warmer temperature_. If there is no future day for which this is possible, keep `answer[i] == 0` instead.
**Example 1:**... | If the temperature is say, 70 today, then in the future a warmer temperature must be either 71, 72, 73, ..., 99, or 100. We could remember when all of them occur next. | Array,Stack,Monotonic Stack | Medium | 496,937 |
907 | hey guys i hope you are doing well today we are going to talk about the problem 907 from lead code which is named as sum of sub array minimums uh please note that amazon currently is asking question which is based on some similar logic related to shopping amazon shopping items so let's start we are given an array of an... | Sum of Subarray Minimums | koko-eating-bananas | Given an array of integers arr, find the sum of `min(b)`, where `b` ranges over every (contiguous) subarray of `arr`. Since the answer may be large, return the answer **modulo** `109 + 7`.
**Example 1:**
**Input:** arr = \[3,1,2,4\]
**Output:** 17
**Explanation:**
Subarrays are \[3\], \[1\], \[2\], \[4\], \[3,1\], \... | null | Array,Binary Search | Medium | 788,1335,2188 |
990 | uh let's talk about the satisfiability of equality equation so you are given a string array of equations so they represent a relationship between variable for each string equation i is the length of a four and every single string has two variables and you have to have you have an equal bit operation and an equal bit op... | Satisfiability of Equality Equations | verifying-an-alien-dictionary | You are given an array of strings `equations` that represent relationships between variables where each string `equations[i]` is of length `4` and takes one of two different forms: `"xi==yi "` or `"xi!=yi "`.Here, `xi` and `yi` are lowercase letters (not necessarily different) that represent one-letter variable names.
... | null | Array,Hash Table,String | Easy | null |
504 | Kevin in the jury returned its base seven string representation okay I mean this seems actually great I mean I think for these palms is always at least four kind of for the purpose of twitching and maybe even for interviews you always try to figure out like what's the best way to kind of think about these things and wh... | Base 7 | base-7 | Given an integer `num`, return _a string of its **base 7** representation_.
**Example 1:**
**Input:** num = 100
**Output:** "202"
**Example 2:**
**Input:** num = -7
**Output:** "-10"
**Constraints:**
* `-107 <= num <= 107` | null | Math | Easy | null |
328 | to work um hi guys this is vaga we are going to do another little question the question in question is number three to eight even linked list pretty straightforward so you're given um a linked list you're supposed to add the odd nudes and um followed by the even nudes note that we're not talking about the value but we'... | Odd Even Linked List | odd-even-linked-list | Given the `head` of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return _the reordered list_.
The **first** node is considered **odd**, and the **second** node is **even**, and so on.
Note that the relative order inside both the even and odd groups s... | null | Linked List | Medium | 725 |
968 | hello everyone welcome to the 17th of june eco challenge and i hope all of you are having a great time my name is sanchez i'm working as technical architect sd4 at adobe and here i present binary tree cameras it's a hard level question on lead code and i also feel the same however for all those who have been associated... | Binary Tree Cameras | beautiful-array | You are given the `root` of a binary tree. We install cameras on the tree nodes where each camera at a node can monitor its parent, itself, and its immediate children.
Return _the minimum number of cameras needed to monitor all nodes of the tree_.
**Example 1:**
**Input:** root = \[0,0,null,0,0\]
**Output:** 1
**Exp... | null | Array,Math,Divide and Conquer | Medium | null |
349 | welcome back to next problem of lead code 349 intersection of two arrays so we are asked we are given two arrays nums one and nums two return and we are asked to return an array of their intersection and intersection should contain only the unique elements so for example uh one two one and two num uh these are nums one... | Intersection of Two Arrays | intersection-of-two-arrays | Given two integer arrays `nums1` and `nums2`, return _an array of their intersection_. Each element in the result must be **unique** and you may return the result in **any order**.
**Example 1:**
**Input:** nums1 = \[1,2,2,1\], nums2 = \[2,2\]
**Output:** \[2\]
**Example 2:**
**Input:** nums1 = \[4,9,5\], nums2 = \... | null | Array,Hash Table,Two Pointers,Binary Search,Sorting | Easy | 350,1149,1392,2190,2282 |
508 | hey everyone today we are going to serve with a little question most frequent subtree sum so you are given root of binary three Returns the most frequent subdivision if there is a tie return all the values with the highest frequency in any order the subtree sum over node is defined as the sum of all the nodes values fo... | Most Frequent Subtree Sum | most-frequent-subtree-sum | Given the `root` of a binary tree, return the most frequent **subtree sum**. If there is a tie, return all the values with the highest frequency in any order.
The **subtree sum** of a node is defined as the sum of all the node values formed by the subtree rooted at that node (including the node itself).
**Example 1:*... | null | Hash Table,Tree,Depth-First Search,Binary Tree | Medium | 572,2126 |
139 | lead code problem number 139 word break so this problem gives us a string called s and a dictionary of strings called word dict and what we have to do is return true if the string s can be segmented into a space separated sequence of one of more dictionary words and here it also states that we can use the same word in ... | Word Break | word-break | Given 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:**
**Input:** s = "leetcode ", wordDict = \[ "... | null | Hash Table,String,Dynamic Programming,Trie,Memoization | Medium | 140 |
438 | hello and welcome to another CS tutor Center video in this video we're going to talk about the problem finding all anagrams in a string but before we get started please go ahead and subscribe to the channel if you're enjoying these videos when you subscribe to the channel that lets me know that you enjoy these videos a... | Find All Anagrams in a String | find-all-anagrams-in-a-string | 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**.
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:**
*... | null | Hash Table,String,Sliding Window | Medium | 242,567 |
114 | hey everybody this is larry this is day uh was it 27 of the leeco day challenge wow my loading is a little bit slow today hit the like button hit the subscribe button join me on discord let me know what you think about this farm and yeah hit every bun uh okay so today's problem is flatten binary tree to link less okay ... | Flatten Binary Tree to Linked List | flatten-binary-tree-to-linked-list | Given the `root` of a binary tree, flatten the tree into a "linked list ":
* The "linked list " should use the same `TreeNode` class where the `right` child pointer points to the next node in the list and the `left` child pointer is always `null`.
* The "linked list " should be in the same order as a [**pre-order*... | If you notice carefully in the flattened tree, each node's right child points to the next node of a pre-order traversal. | Linked List,Stack,Tree,Depth-First Search,Binary Tree | Medium | 766,1796 |
232 | Hello gas message Samiksha Agarwal welcome tu freaks channel made for you made by today late good problem nowadays name of late good problem is implement why using tax is easy level problem and trust me is very simple problem there is nothing to worry about So first of all let's see what is 'Apne' and 'Apne' in the que... | Implement Queue using Stacks | implement-queue-using-stacks | Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (`push`, `peek`, `pop`, and `empty`).
Implement the `MyQueue` class:
* `void push(int x)` Pushes element x to the back of the queue.
* `int pop()` Removes the element from th... | null | Stack,Design,Queue | Easy | 225 |
1,026 | hey guys how's everything going this is Jay sir he's not really good at he's not very good at algorithm and I'm recording this video to prepare my interview from Facebook in June which is exactly like one month from now so actually not that time not that much time is enough so I'm trying to do as much practice as I can... | Maximum Difference Between Node and Ancestor | string-without-aaa-or-bbb | Given the `root` of a binary tree, find the maximum value `v` for which there exist **different** nodes `a` and `b` where `v = |a.val - b.val|` and `a` is an ancestor of `b`.
A node `a` is an ancestor of `b` if either: any child of `a` is equal to `b` or any child of `a` is an ancestor of `b`.
**Example 1:**
**Input... | null | String,Greedy | Medium | null |
705 | Watch this Hello everyone welcome to my channel today to of birth change any problem in design is decided so design is without using any in built in the festival of red tube specific sexual day function and value interview in to the sentence value return of the rebel remove This example subscribe content with to proper... | Design HashSet | design-hashset | Design a HashSet without using any built-in hash table libraries.
Implement `MyHashSet` class:
* `void add(key)` Inserts the value `key` into the HashSet.
* `bool contains(key)` Returns whether the value `key` exists in the HashSet or not.
* `void remove(key)` Removes the value `key` in the HashSet. If `key` do... | null | null | Easy | null |
394 | hi guys hope you're doing great a today's question is the code string given an encoded string return its decoded string the encoding rule is K and then will be given in square brackets encoded string where the encoded string inside the square brackets is being repeated exactly K times note that K is guaranteed to be a ... | Decode String | decode-string | Given an encoded string, return its decoded string.
The encoding rule is: `k[encoded_string]`, where the `encoded_string` inside the square brackets is being repeated exactly `k` times. Note that `k` is guaranteed to be a positive integer.
You may assume that the input string is always valid; there are no extra white... | null | String,Stack,Recursion | Medium | 471,726,1076 |
368 | hey everyone welcome back and let's write some more neat code today so today let's solve the problem largest divisible subset I really like this problem we're given a set of distinct positive integers and we want to return the largest subset answer such that every pair of values satisfies this condition one of the numb... | Largest Divisible Subset | largest-divisible-subset | Given a set of **distinct** positive integers `nums`, return the largest subset `answer` such that every pair `(answer[i], answer[j])` of elements in this subset satisfies:
* `answer[i] % answer[j] == 0`, or
* `answer[j] % answer[i] == 0`
If there are multiple solutions, return any of them.
**Example 1:**
**Inp... | null | Array,Math,Dynamic Programming,Sorting | Medium | null |
1,887 | Vrat month mein sandeep android problem 1872 in this problem bichuran head and went to make all the elements equal to zero for diploma in operation what is that operation it is only white shoes largest army in the second largest element hindi are and you replace the largest and oldest And largest for example in this he... | Reduction Operations to Make the Array Elements Equal | minimum-degree-of-a-connected-trio-in-a-graph | Given an integer array `nums`, your goal is to make all elements in `nums` equal. To complete one operation, follow these steps:
1. Find the **largest** value in `nums`. Let its index be `i` (**0-indexed**) and its value be `largest`. If there are multiple elements with the largest value, pick the smallest `i`.
2. F... | Consider a trio with nodes u, v, and w. The degree of the trio is just degree(u) + degree(v) + degree(w) - 6. The -6 comes from subtracting the edges u-v, u-w, and v-w, which are counted twice each in the vertex degree calculation. To get the trios (u,v,w), you can iterate on u, then iterate on each w,v such that w and... | Graph | Hard | null |
74 | hey everyone welcome back and let's write some more neat code today so today let's solve search a 2d matrix and i really like this problem because it's not one of those problems that you need a fancy trick for you can actually solve this problem just by using logic so we are tasked with creating an efficient algorithm ... | Search a 2D Matrix | search-a-2d-matrix | You are given an `m x n` integer matrix `matrix` with the following two properties:
* Each row is sorted in non-decreasing order.
* The first integer of each row is greater than the last integer of the previous row.
Given an integer `target`, return `true` _if_ `target` _is in_ `matrix` _or_ `false` _otherwise_.
... | null | Array,Binary Search,Matrix | Medium | 240 |
1,074 | hey what's up guys this is john here so today let's take a look at this 1074 number of sub matrixes that sum to target so it's a hard problem okay let's take a look at the description here so you're given like a 2d matrix and a target so and it just asks you to return the number of non empty sub matrices whose sum is e... | Number of Submatrices That Sum to Target | high-five | Given a `matrix` and a `target`, return the number of non-empty submatrices that sum to target.
A submatrix `x1, y1, x2, y2` is the set of all cells `matrix[x][y]` with `x1 <= x <= x2` and `y1 <= y <= y2`.
Two submatrices `(x1, y1, x2, y2)` and `(x1', y1', x2', y2')` are different if they have some coordinate that is... | How can we solve the problem if we have just one student? Given an student sort their grades and get the top 5 average. Generalize the idea to do it for many students. | Array,Hash Table,Sorting | Easy | null |
51 | hi guys uh we are solving a new question today this is a n queens question in this question we are given uh n cross n checkpoint and we have to put n queens on it so first we have to you know draw the chess board so this is a chess board and it's basically we have to put a cue for a queen so we are using a string if yo... | N-Queens | n-queens | The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other.
Given an integer `n`, return _all distinct solutions to the **n-queens puzzle**_. You may return the answer in **any order**.
Each solution contains a distinct board configuration of the n-... | null | Array,Backtracking | Hard | 52,1043 |
355 | hello everyone so in this video let us talk about a problem from lead code the problem name is design twitter so let us go to the problem statement it goes like this that you have to design a simplified version of twitter where user can post tweets follow unfollow another user and is able to see the 10 most recent twee... | Design Twitter | design-twitter | 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 your twitter object.
* `void postTweet(int userId, int tweetId)` Composes a new tweet w... | null | Hash Table,Linked List,Design,Heap (Priority Queue) | Medium | 1640 |
739 | hello and welcome to another video in this video we're going to be working on daily temperatures and it's definitely a solid interview problem that you should know how to do it's not super hard and it has fundamental algorithms so in this problem you're given an array integers temperatures represents the daily temperat... | Daily Temperatures | daily-temperatures | Given an array of integers `temperatures` represents the daily temperatures, return _an array_ `answer` _such that_ `answer[i]` _is the number of days you have to wait after the_ `ith` _day to get a warmer temperature_. If there is no future day for which this is possible, keep `answer[i] == 0` instead.
**Example 1:**... | If the temperature is say, 70 today, then in the future a warmer temperature must be either 71, 72, 73, ..., 99, or 100. We could remember when all of them occur next. | Array,Stack,Monotonic Stack | Medium | 496,937 |
863 | okay so hello everyone this is AA here and let us proceed with today's question given so today's question is a hard category question but we will do it in a very simple way we will use the very basic fundamentals of the binary tree so let us read the question first and then we can proceed here with the solutions so we ... | All Nodes Distance K in Binary Tree | sum-of-distances-in-tree | Given the `root` of a binary tree, the value of a target node `target`, and an integer `k`, return _an array of the values of all nodes that have a distance_ `k` _from the target node._
You can return the answer in **any order**.
**Example 1:**
**Input:** root = \[3,5,1,6,2,0,8,null,null,7,4\], target = 5, k = 2
**O... | null | Dynamic Programming,Tree,Depth-First Search,Graph | Hard | 1021,2175 |
1,647 | hello everyone and welcome back to the helgi kareena and today we are back with yet another very interesting problem on lead code which is minimum deletions to make character frequencies unique now let's take a look at this problem so according to this problem a string s is called good if there are no two characters di... | Minimum Deletions to Make Character Frequencies Unique | can-convert-string-in-k-moves | A string `s` is called **good** if there are no two different characters in `s` that have the same **frequency**.
Given a string `s`, return _the **minimum** number of characters you need to delete to make_ `s` _**good**._
The **frequency** of a character in a string is the number of times it appears in the string. F... | Observe that shifting a letter x times has the same effect of shifting the letter x + 26 times. You need to check whether k is large enough to cover all shifts with the same remainder after modulo 26. | Hash Table,String | Medium | null |
1,443 | hey everybody this is larry i'm doing this prom as part of a contest so you're gonna watch me live as i go through my darts as i'm coding uh there'll be an explanation near the end and for more context there'll be a link below on this actual screencast of the contest uh how did you do let me know how you do hit the lik... | Minimum Time to Collect All Apples in a Tree | minimum-distance-to-type-a-word-using-two-fingers | Given an undirected tree consisting of `n` vertices numbered from `0` to `n-1`, which has some apples in their vertices. You spend 1 second to walk over one edge of the tree. _Return the minimum time in seconds you have to spend to collect all apples in the tree, starting at **vertex 0** and coming back to this vertex.... | Use dynamic programming. dp[i][j][k]: smallest movements when you have one finger on i-th char and the other one on j-th char already having written k first characters from word. | String,Dynamic Programming | Hard | 2088 |
929 | hello everyone so in this video let us talk about one more problem from lead code the problem name is unique email addresses so let's go to the problem statement uh it is a problem also in different interviews so stay focused uh the problem statement goes like this that for every valid email consisting of a local name ... | Unique Email Addresses | groups-of-special-equivalent-strings | Every **valid email** consists of a **local name** and a **domain name**, separated by the `'@'` sign. Besides lowercase letters, the email may contain one or more `'.'` or `'+'`.
* For example, in `"alice@leetcode.com "`, `"alice "` is the **local name**, and `"leetcode.com "` is the **domain name**.
If you add pe... | null | Array,Hash Table,String | Medium | null |
327 | hey everybody this is Larry I hit the like button hit the subscribe button let me know how you're doing this farm I'm gonna stop alive right about now you'll be ahead of me 3:27 can arrange some be ahead of me 3:27 can arrange some be ahead of me 3:27 can arrange some given an integer way gnomes we turned a number of r... | Count of Range Sum | count-of-range-sum | Given an integer array `nums` and two integers `lower` and `upper`, return _the number of range sums that lie in_ `[lower, upper]` _inclusive_.
Range sum `S(i, j)` is defined as the sum of the elements in `nums` between indices `i` and `j` inclusive, where `i <= j`.
**Example 1:**
**Input:** nums = \[-2,5,-1\], lowe... | null | Array,Binary Search,Divide and Conquer,Binary Indexed Tree,Segment Tree,Merge Sort,Ordered Set | Hard | 315,493 |
264 | hello guys welcome to algorithms made easy today we will go through day 4 problem from july lead coding challenge ugly number 2. please like the video and if you are new don't forget to subscribe to our channel so that you never miss any update write a program to find the nth ugly number ugly numbers are positive numbe... | Ugly Number II | ugly-number-ii | An **ugly number** is a positive integer whose prime factors are limited to `2`, `3`, and `5`.
Given an integer `n`, return _the_ `nth` _**ugly number**_.
**Example 1:**
**Input:** n = 10
**Output:** 12
**Explanation:** \[1, 2, 3, 4, 5, 6, 8, 9, 10, 12\] is the sequence of the first 10 ugly numbers.
**Example 2:**
... | The naive approach is to call isUgly for every number until you reach the nth one. Most numbers are not ugly. Try to focus your effort on generating only the ugly ones. An ugly number must be multiplied by either 2, 3, or 5 from a smaller ugly number. The key is how to maintain the order of the ugly numbers. Try a simi... | Hash Table,Math,Dynamic Programming,Heap (Priority Queue) | Medium | 23,204,263,279,313,1307 |
1,187 | hey everybody this is Larry this is day 17 of the leeco daily challenge hit the like button hit the Subscribe and join me on Discord let me know what you think about today's poem make a race strictly increasing okay I mean that's the title I have to actually wait for it to load don't know why it's loading so slowly int... | Make Array Strictly Increasing | print-foobar-alternately | Given two integer arrays `arr1` and `arr2`, return the minimum number of operations (possibly zero) needed to make `arr1` strictly increasing.
In one operation, you can choose two indices `0 <= i < arr1.length` and `0 <= j < arr2.length` and do the assignment `arr1[i] = arr2[j]`.
If there is no way to make `arr1` str... | null | Concurrency | Medium | 1203,1216 |
1,689 | Hello Everyone Welcome To Our Channel Switch Sunny And Skill Develop In Talking About The Very Easy Problem Chopped Beans This Problem Through Synthetic Partition In Terminal Number Desi Boys Numbers Index Number 8 And The Problem Of Medium Time But It Considers It's Okay Solved Problems So 9th Basic Concept Was Happen... | Partitioning Into Minimum Number Of Deci-Binary Numbers | detect-pattern-of-length-m-repeated-k-or-more-times | A decimal number is called **deci-binary** if each of its digits is either `0` or `1` without any leading zeros. For example, `101` and `1100` are **deci-binary**, while `112` and `3001` are not.
Given a string `n` that represents a positive decimal integer, return _the **minimum** number of positive **deci-binary** n... | Use a three-layer loop to check all possible patterns by iterating through all possible starting positions, all indexes less than m, and if the character at the index is repeated k times. | Array,Enumeration | Easy | 1764 |
847 | hello everyone welcome to day 26 of every record challenge and i hope all of you are having a great time the question that we have in today's shortest path visiting all nodes after a very long time we are seeing a graph problem that you have hard category and i promise it's going to be an interesting solution for all o... | Shortest Path Visiting All Nodes | shortest-path-visiting-all-nodes | You have an undirected, connected graph of `n` nodes labeled from `0` to `n - 1`. You are given an array `graph` where `graph[i]` is a list of all the nodes connected with node `i` by an edge.
Return _the length of the shortest path that visits every node_. You may start and stop at any node, you may revisit nodes mul... | null | null | Hard | null |
404 | hey everybody this is larry this is day five day four of the league code daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about this prom uh so is it four or four yeezy so okay i mean i found the problem okay but uh some of left leaves okay so yeah if you enjoye... | Sum of Left Leaves | sum-of-left-leaves | Given the `root` of a binary tree, return _the sum of all left leaves._
A **leaf** is a node with no children. A **left leaf** is a leaf that is the left child of another node.
**Example 1:**
**Input:** root = \[3,9,20,null,null,15,7\]
**Output:** 24
**Explanation:** There are two left leaves in the binary tree, wit... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Easy | null |
1,856 | hey everyone welcome back and let's write some more neat code today so today let's solve a problem fresh off the leak code contest for today maximum subarray min product so this is a pretty hard problem even though it's categorized as medium and i'm just going to tell you that this is a problem that can be solved with ... | Maximum Subarray Min-Product | maximum-subarray-min-product | The **min-product** of an array is equal to the **minimum value** in the array **multiplied by** the array's **sum**.
* For example, the array `[3,2,5]` (minimum value is `2`) has a min-product of `2 * (3+2+5) = 2 * 10 = 20`.
Given an array of integers `nums`, return _the **maximum min-product** of any **non-empty ... | null | null | Medium | null |
71 | hello everyone welcome to day 14th of march eco challenge and i hope all of you having a great time i know it's monday views are back i still we have to maintain the consistency and solve daily lead code challenges i am doing it even before starting my day today's question that we have is simplify paths this question i... | Simplify Path | simplify-path | Given a string `path`, which is an **absolute path** (starting with a slash `'/'`) to a file or directory in a Unix-style file system, convert it to the simplified **canonical path**.
In a Unix-style file system, a period `'.'` refers to the current directory, a double period `'..'` refers to the directory up a level,... | null | String,Stack | Medium | null |
1,637 | hey guys welcome to a new video in today's video we're going to look at a lead code problem and the problem's name is widest vertical area between two points containing no points so in this question we are given n points on a 2d plane containing of a point with X and Y coordinates and we have to return the widest verti... | Widest Vertical Area Between Two Points Containing No Points | string-compression-ii | Given `n` `points` on a 2D plane where `points[i] = [xi, yi]`, Return _the **widest vertical area** between two points such that no points are inside the area._
A **vertical area** is an area of fixed-width extending infinitely along the y-axis (i.e., infinite height). The **widest vertical area** is the one with the ... | Use dynamic programming. The state of the DP can be the current index and the remaining characters to delete. Having a prefix sum for each character can help you determine for a certain character c in some specific range, how many characters you need to delete to merge all occurrences of c in that range. | String,Dynamic Programming | Hard | null |
232 | welcome to my uh legal service session this is called the incredible queue uh using stack okay so uh the queue is basically uh our first thing for now the stack is amazing unfortunately and that's out okay so the problem is uh so the key points that we need to use the stack to import so stack looks like this suppose yo... | Implement Queue using Stacks | implement-queue-using-stacks | Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (`push`, `peek`, `pop`, and `empty`).
Implement the `MyQueue` class:
* `void push(int x)` Pushes element x to the back of the queue.
* `int pop()` Removes the element from th... | null | Stack,Design,Queue | Easy | 225 |
145 | how's it going guys today we're going to be going over another problem this problem is called binary tree post order traversal I just want to point out too that this is a hard problem according to leak code some people have been asking me to do medium or hard problems so things that are just generally harder than what ... | Binary Tree Postorder Traversal | binary-tree-postorder-traversal | Given the `root` of a binary tree, return _the postorder traversal of its nodes' values_.
**Example 1:**
**Input:** root = \[1,null,2,3\]
**Output:** \[3,2,1\]
**Example 2:**
**Input:** root = \[\]
**Output:** \[\]
**Example 3:**
**Input:** root = \[1\]
**Output:** \[1\]
**Constraints:**
* The number of the n... | null | Stack,Tree,Depth-First Search,Binary Tree | Easy | 94,776 |
235 | foreign welcome to my channel coding together my name is vikar soja today we will see another lead code problem that is lowest common ancestor of a binary search tree LCA so it's a medium level question and it's a very popular question as you can see from the likes so let's read the problem statement we are given a bin... | Lowest Common Ancestor of a Binary Search Tree | lowest-common-ancestor-of-a-binary-search-tree | Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST.
According to the [definition of LCA on Wikipedia](https://en.wikipedia.org/wiki/Lowest_common_ancestor): "The lowest common ancestor is defined between two nodes `p` and `q` as the lowest node in `T` that has bo... | null | Tree,Depth-First Search,Binary Search Tree,Binary Tree | Easy | 236,1190,1780,1790,1816 |
815 | hello guys and welcome back to lead Logics this is the bus routs problem for lead code it is a lead code hard and the number for this is 815 so in this question we are given with an array Roots representing the bus routs where roots of I is a bus root that I bus repeats forever for example roots of I roots of 0 equal t... | Bus Routes | champagne-tower | You are given an array `routes` representing bus routes where `routes[i]` is a bus route that the `ith` bus repeats forever.
* For example, if `routes[0] = [1, 5, 7]`, this means that the `0th` bus travels in the sequence `1 -> 5 -> 7 -> 1 -> 5 -> 7 -> 1 -> ...` forever.
You will start at the bus stop `source` (You... | null | Dynamic Programming | Medium | 1385 |
400 | Hello friends, in this video we are not going to solve this problem, basically we have been given one wait, one more wait, what we have to do is to return to digital, one infinite wait sequence, now what does it mean? Sir, this means that we have been given an infinite waiting sequence and a number has been given to us... | Nth Digit | nth-digit | Given an integer `n`, return the `nth` digit of the infinite integer sequence `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...]`.
**Example 1:**
**Input:** n = 3
**Output:** 3
**Example 2:**
**Input:** n = 11
**Output:** 0
**Explanation:** The 11th digit of the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... is a 0, which ... | null | Math,Binary Search | Medium | null |
139 | Hello viewers welcome back to decades and this video will see what problem which from list is number 139 and this problem has service five different solution so I will be planning for this video and the video of the problem subscribe share also problem Problem Solving Your Interview Subscribe Our Everything You Need Fo... | Word Break | word-break | Given 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:**
**Input:** s = "leetcode ", wordDict = \[ "... | null | Hash Table,String,Dynamic Programming,Trie,Memoization | Medium | 140 |
461 | hey everybody this is Larry this is day fifth of the July daily legal challenge I had like button hit the subscribe button join me on discord ask questions and all that stuff yeah so today's question Hamming distance we're having distance between two integers is just a number position in which they're different bits so... | Hamming Distance | hamming-distance | The [Hamming distance](https://en.wikipedia.org/wiki/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:**
**Input:** x = 1, y = 4
**Output:** 2
**Explanation:**
1... | null | Bit Manipulation | Easy | 191,477 |
215 | all right so let's talk about okay largest element array so you're giving the initial real numbers and then it's a k so you have to return the k largest element inside the array and this question is really simple so uh again uh let me join so uh if this is a red and then the k equal to two which is the second largest e... | Kth Largest Element in an Array | kth-largest-element-in-an-array | Given an integer array `nums` and an integer `k`, return _the_ `kth` _largest element in the array_.
Note that it is the `kth` largest element in the sorted order, not the `kth` distinct element.
You must solve it in `O(n)` time complexity.
**Example 1:**
**Input:** nums = \[3,2,1,5,6,4\], k = 2
**Output:** 5
**Ex... | null | Array,Divide and Conquer,Sorting,Heap (Priority Queue),Quickselect | Medium | 324,347,414,789,1014,2113,2204,2250 |
1,926 | hi friends uh welcome to my channel let's have a look at problem 1926 nearest exit from entries in maze so in this video we're going to share a solution based on breadth first search so here our main goal is to emphasize the treatment to avoid repetition in the traversal so this problem requires to return the number of... | Nearest Exit from Entrance in Maze | products-price-for-each-store | You are given an `m x n` matrix `maze` (**0-indexed**) with empty cells (represented as `'.'`) and walls (represented as `'+'`). You are also given the `entrance` of the maze, where `entrance = [entrancerow, entrancecol]` denotes the row and column of the cell you are initially standing at.
In one step, you can move o... | null | Database | Easy | 1948 |
771 | I will be doing almost m71 because which is to called Jules and songs the body fat be given a string of J representing types of stones that are jewels and as representing the stones that you have each character and s is a type of stone you want to know how many stones you have our also tools the letters and K are guara... | Jewels and Stones | encode-n-ary-tree-to-binary-tree | 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 you have are also jewels.
Letters are case sensitive, so `"a "` is considered a different type o... | null | Tree,Depth-First Search,Breadth-First Search,Design,Binary Tree | Hard | 765 |
1,604 | hey what is up guys this is my new video uh hey what is up guys this is my first video on my new channel abroad does software engineering um today we're gonna be doing a leak code problem this is the first video on this channel so if you don't know i used to make leak code videos on my old channel called abrar share an... | Alert Using Same Key-Card Three or More Times in a One Hour Period | least-number-of-unique-integers-after-k-removals | LeetCode company workers use key-cards to unlock office doors. Each time a worker uses their key-card, the security system saves the worker's name and the time when it was used. The system emits an **alert** if any worker uses the key-card **three or more times** in a one-hour period.
You are given a list of strings `... | Use a map to count the frequencies of the numbers in the array. An optimal strategy is to remove the numbers with the smallest count first. | Array,Hash Table,Greedy,Sorting,Counting | Medium | null |
1,352 | and welcome back to the cracking thing youtube channel today we're going to be solving lead code problem 1352 product of the last k numbers before we read the question prompt just want to ask you guys to subscribe help my channel grow i can make more videos and you guys can get those jobs in fang all right let's read i... | Product of the Last K Numbers | maximum-profit-in-job-scheduling | Design an algorithm that accepts a stream of integers and retrieves the product of the last `k` integers of the stream.
Implement the `ProductOfNumbers` class:
* `ProductOfNumbers()` Initializes the object with an empty stream.
* `void add(int num)` Appends the integer `num` to the stream.
* `int getProduct(int... | Think on DP. Sort the elements by starting time, then define the dp[i] as the maximum profit taking elements from the suffix starting at i. Use binarySearch (lower_bound/upper_bound on C++) to get the next index for the DP transition. | Array,Binary Search,Dynamic Programming,Sorting | Hard | 2118,2164 |
316 | hey guys welcome back to another video and today we're going to be solving the lee code question remove duplicate letters all right so when you just look at the title uh the question seems pretty simple right but there's actually a small catch in the question which makes it slightly complicated all right so in this que... | Remove Duplicate Letters | remove-duplicate-letters | Given a string `s`, remove duplicate letters so that every letter appears once and only once. You must make sure your result is **the smallest in lexicographical order** among all possible results.
**Example 1:**
**Input:** s = "bcabc "
**Output:** "abc "
**Example 2:**
**Input:** s = "cbacdcbc "
**Output:** "a... | Greedily try to add one missing character. How to check if adding some character will not cause problems ? Use bit-masks to check whether you will be able to complete the sub-sequence if you add the character at some index i. | String,Stack,Greedy,Monotonic Stack | Medium | 2157 |
1 | let's solve lead code number one to sum this is the most commonly asked coding interview question in this question we're given an input array and a Target value we need to find two numbers that add up to the Target value in this example 2 plus 7 is equal to nine and we return their indices the index for 2 is 0 and for ... | Two Sum | two-sum | Given an array of integers `nums` and an integer `target`, return _indices of the two numbers such that they add up to `target`_.
You may assume that each input would have **_exactly_ one solution**, and you may not use the _same_ element twice.
You can return the answer in any order.
**Example 1:**
**Input:** nums... | A really brute force way would be to search for all possible pairs of numbers but that would be too slow. Again, it's best to try out brute force solutions for just for completeness. It is from these brute force solutions that you can come up with optimizations. So, if we fix one of the numbers, say x, we have to scan ... | Array,Hash Table | Easy | 15,18,167,170,560,653,1083,1798,1830,2116,2133,2320 |
841 | Everyone welcome to my channel, so today I will do question number 5 of my Grahas Palace, this is also long term, this is open which you can open from zero number three, okay then you will start from room zero, okay if you can open room van then room. You go to the van, there are 30 and 1, which means you can open thre... | Keys and Rooms | shortest-distance-to-a-character | There are `n` rooms labeled from `0` to `n - 1` and all the rooms are locked except for room `0`. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key.
When you visit a room, you may find a set of **distinct keys** in it. Each key has a number on it, denoting which room i... | null | Array,Two Pointers,String | Easy | null |
880 | Hua Hai Song in MP3 Tu Yeh Question Hai Decoding Arvind Act Ko Deputy Friends Basically Director Nirkhyou Hai Ek Train Hai And Got From Main Side That Train We Have To Write A Temple Tubelight Straight To Take Off To One Any Other It is for the media industry and they have to decode the rate setting and we do not have ... | Decoded String at Index | rectangle-area-ii | You are given an encoded string `s`. To decode the string to a tape, the encoded string is read one character at a time and the following steps are taken:
* If the character read is a letter, that letter is written onto the tape.
* If the character read is a digit `d`, the entire current tape is repeatedly written... | null | Array,Segment Tree,Line Sweep,Ordered Set | Hard | null |
1,759 | hey everyone today we are going to solve theal question count number of homogeneous substrings okay so seems like we have a lot of patterns for this question right so when I feel that I usually think about output with small input so let's think about the input is only a in this case there's only one pattern right singl... | Count Number of Homogenous Substrings | find-the-missing-ids | Given a string `s`, return _the number of **homogenous** substrings of_ `s`_._ Since the answer may be too large, return it **modulo** `109 + 7`.
A string is **homogenous** if all the characters of the string are the same.
A **substring** is a contiguous sequence of characters within a string.
**Example 1:**
**Inpu... | null | Database | Medium | 1357,1420,1467 |
105 | the most important part about this problem is to understand how you can relate to different traverses and then combine them to create a unique tree and that is what makes this problem so very important for your interviews because it helps the interviewer to understand that you are understanding the tree traverses exact... | Construct Binary Tree from Preorder and Inorder Traversal | construct-binary-tree-from-preorder-and-inorder-traversal | Given two integer arrays `preorder` and `inorder` where `preorder` is the preorder traversal of a binary tree and `inorder` is the inorder traversal of the same tree, construct and return _the binary tree_.
**Example 1:**
**Input:** preorder = \[3,9,20,15,7\], inorder = \[9,3,15,20,7\]
**Output:** \[3,9,20,null,null,... | null | Array,Hash Table,Divide and Conquer,Tree,Binary Tree | Medium | 106 |
94 | and take a look at a legal problem called binary tree inward traversal so for binary treatment or traversal the order goes something like this where we're traversing the left side first and then the current node then the right side okay so let's say we have an example like this where we have the current node the left s... | Binary Tree Inorder Traversal | binary-tree-inorder-traversal | Given the `root` of a binary tree, return _the inorder traversal of its nodes' values_.
**Example 1:**
**Input:** root = \[1,null,2,3\]
**Output:** \[1,3,2\]
**Example 2:**
**Input:** root = \[\]
**Output:** \[\]
**Example 3:**
**Input:** root = \[1\]
**Output:** \[1\]
**Constraints:**
* The number of nodes i... | null | Stack,Tree,Depth-First Search,Binary Tree | Easy | 98,144,145,173,230,272,285,758,799 |
7 | foreign with the lonely Dash and today we're going over lead code question 7 reverse integer which says given a signed 32-bit integer which says given a signed 32-bit integer which says given a signed 32-bit integer X return x with its digits reversed if reversing X causes the value to go outside the signed 32-bit inte... | Reverse Integer | reverse-integer | Given a signed 32-bit integer `x`, return `x` _with its digits reversed_. If reversing `x` causes the value to go outside the signed 32-bit integer range `[-231, 231 - 1]`, then return `0`.
**Assume the environment does not allow you to store 64-bit integers (signed or unsigned).**
**Example 1:**
**Input:** x = 123
... | null | Math | Medium | 8,190,2238 |
1,011 | hey what's up guys John here again so this time I want to talk about another problem 1011 capacity to ship packages within D days okay let's take a look at this problem the comfort of description of the problem so you have a comic-con ver the problem so you have a comic-con ver the problem so you have a comic-con ver b... | Capacity To Ship Packages Within D Days | flip-binary-tree-to-match-preorder-traversal | A conveyor belt has packages that must be shipped from one port to another within `days` days.
The `ith` package on the conveyor belt has a weight of `weights[i]`. Each day, we load the ship with packages on the conveyor belt (in the order given by `weights`). We may not load more weight than the maximum weight capaci... | null | Tree,Depth-First Search,Binary Tree | Medium | null |
189 | I am your everybody, how are you all? In today's video we are solving the problem of rotation, so there is 189 problem, what is the problem on your list court, I will tell you as you must have read, only then you can see the solution. Coming in the other way, let's go straight to the discussion, okay, first of all you ... | Rotate Array | rotate-array | Given an integer array `nums`, rotate the array to the right by `k` steps, where `k` is non-negative.
**Example 1:**
**Input:** nums = \[1,2,3,4,5,6,7\], k = 3
**Output:** \[5,6,7,1,2,3,4\]
**Explanation:**
rotate 1 steps to the right: \[7,1,2,3,4,5,6\]
rotate 2 steps to the right: \[6,7,1,2,3,4,5\]
rotate 3 steps to... | The easiest solution would use additional memory and that is perfectly fine. The actual trick comes when trying to solve this problem without using any additional memory. This means you need to use the original array somehow to move the elements around. Now, we can place each element in its original location and shift ... | Array,Math,Two Pointers | Medium | 61,186 |
1,963 | So Hi Everyone, my name is Shashwat Tiwari and in today's video we are going to do another bracket balance question. It is a very interesting problem but at a medium level, you will have to think a little intuitively, so let's start today's video. If you are on this channel. If you are new then go and watch the old vid... | Minimum Number of Swaps to Make the String Balanced | find-xor-sum-of-all-pairs-bitwise-and | You are given a **0-indexed** string `s` of **even** length `n`. The string consists of **exactly** `n / 2` opening brackets `'['` and `n / 2` closing brackets `']'`.
A string is called **balanced** if and only if:
* It is the empty string, or
* It can be written as `AB`, where both `A` and `B` are **balanced** s... | Think about (a&b) ^ (a&c). Can you simplify this expression? It is equal to a&(b^c). Then, (arr1[i]&arr2[0])^(arr1[i]&arr2[1]).. = arr1[i]&(arr2[0]^arr2[1]^arr[2]...). Let arr2XorSum = (arr2[0]^arr2[1]^arr2[2]...), arr1XorSum = (arr1[0]^arr1[1]^arr1[2]...) so the final answer is (arr2XorSum&arr1[0]) ^ (arr2XorSum&arr1[... | Array,Math,Bit Manipulation | Hard | null |
290 | hey everybody welcome back and today we'll be doing another Lead Core 290 word pattern this is an easy one given a pattern and a string for a find if s follows the same pattern so uh here follows me in a full match so what is a match uh by seeing the example one you can see that there is a pattern A B A and let me writ... | Word Pattern | word-pattern | Given a `pattern` and a string `s`, find if `s` follows the same pattern.
Here **follow** means a full match, such that there is a bijection between a letter in `pattern` and a **non-empty** word in `s`.
**Example 1:**
**Input:** pattern = "abba ", s = "dog cat cat dog "
**Output:** true
**Example 2:**
**Input:*... | null | Hash Table,String | Easy | 205,291 |
456 | hello and welcome to another video in this video we're going to be working on a 132 pattern so in this problem you're given an array of nums and a 132 pattern is a subsequence of three integers nums I nums J and K such that I is less than J is less than K and it's index-wise and is less than K and it's index-wise and i... | 132 Pattern | 132-pattern | Given an array of `n` integers `nums`, a **132 pattern** is a subsequence of three integers `nums[i]`, `nums[j]` and `nums[k]` such that `i < j < k` and `nums[i] < nums[k] < nums[j]`.
Return `true` _if there is a **132 pattern** in_ `nums`_, otherwise, return_ `false`_._
**Example 1:**
**Input:** nums = \[1,2,3,4\]
... | null | Array,Binary Search,Stack,Monotonic Stack,Ordered Set | Medium | null |
74 | Hello Hi Everyone Welcome To My Channel Today We Will Solve The Problems Of Today Matrix So Right Edition Elva Edison That Search For Value In And Processes For Subscribe And Subscribe The Channel 30000000 Withdrawal Element Person Subscribed On Thursday Time Complexity Of Dissolution His Wife In This Classification Op... | Search a 2D Matrix | search-a-2d-matrix | You are given an `m x n` integer matrix `matrix` with the following two properties:
* Each row is sorted in non-decreasing order.
* The first integer of each row is greater than the last integer of the previous row.
Given an integer `target`, return `true` _if_ `target` _is in_ `matrix` _or_ `false` _otherwise_.
... | null | Array,Binary Search,Matrix | Medium | 240 |
350 | hello everyone today we are going to solve another lead code problem this is called as intersection of two arrays two so we are given two arrays nums one and nums nums2 and we have to find intersection between them and numbers can be repeated so in this case for example there are two tools and here also there are two t... | Intersection of Two Arrays II | intersection-of-two-arrays-ii | Given two integer arrays `nums1` and `nums2`, return _an array of their intersection_. Each element in the result must appear as many times as it shows in both arrays and you may return the result in **any order**.
**Example 1:**
**Input:** nums1 = \[1,2,2,1\], nums2 = \[2,2\]
**Output:** \[2,2\]
**Example 2:**
**I... | null | Array,Hash Table,Two Pointers,Binary Search,Sorting | Easy | 349,1044,1392,2282 |
672 | hi guys good morning welcome back to the next video which is a bulb switcher although the problem a rating is not marked as that good but I say it's a good problem if you just want to have that math understanding and all that stuff so yeah I'll just say okay it's actually a good problem not actually a medium problem in... | Bulb Switcher II | bulb-switcher-ii | There is a room with `n` bulbs labeled from `1` to `n` that all are turned on initially, and **four buttons** on the wall. Each of the four buttons has a different functionality where:
* **Button 1:** Flips the status of all the bulbs.
* **Button 2:** Flips the status of all the bulbs with even labels (i.e., `2, 4... | null | Math,Bit Manipulation,Depth-First Search,Breadth-First Search | Medium | 319,1491 |
6 | Jhaal hey brother and welcome to get specific today if just any thing problem the continent of victory in the Christian eminent people and subscribe problems can they give me the number of district rule in it's true lies in it's a our field here being different is directly Day The See For Example Of Benefits Through To... | Zigzag Conversion | zigzag-conversion | The string `"PAYPALISHIRING "` is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
P A H N
A P L S I I G
Y I R
And then read line by line: `"PAHNAPLSIIGYIR "`
Write the code that will take a string and make this co... | null | String | Medium | null |
278 | foreign the latest version of your product fails the quality check so since each motion is developed based on the previous version all the versions after a bad version are also bad suppose you have n versions from 1 to n and you want to find out the first bad one which costs all the following ones to be bad there are b... | First Bad Version | first-bad-version | You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.
Suppose you have `n` versions `[1, 2, ..., n]` an... | null | Binary Search,Interactive | Easy | 34,35,374 |
963 | hey everybody this is larry this is me trying to do uh something new which is that i'm going to try to do one problem that i haven't solved before so um because the daily problems have been repeats for me so yeah let's see let's check that out uh let's just say to do and yeah let's just click on it is there an easy way... | Minimum Area Rectangle II | three-equal-parts | You are given an array of points in the **X-Y** plane `points` where `points[i] = [xi, yi]`.
Return _the minimum area of any rectangle formed from these points, with sides **not necessarily parallel** to the X and Y axes_. If there is not any such rectangle, return `0`.
Answers within `10-5` of the actual answer will... | null | Array,Math | Hard | null |
1,477 | hey everybody this is Larry I'm doing this problem as part of a contest so you're gonna watch me live as I go through my daughter's I'm coding they've been explanation near the end and for more context they'll be a link below on this actual screencast of the contest how did you do let me know you do hit the like button... | Find Two Non-overlapping Sub-arrays Each With Target Sum | product-of-the-last-k-numbers | You are given an array of integers `arr` and an integer `target`.
You have to find **two non-overlapping sub-arrays** of `arr` each with a sum equal `target`. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is **minimum**.
Return _the minimum sum of the l... | Keep all prefix products of numbers in an array, then calculate the product of last K elements in O(1) complexity. When a zero number is added, clean the array of prefix products. | Array,Math,Design,Queue,Data Stream | Medium | null |
278 | any guys are doing this is Jay sir who started good at algorithms I'm recording these videos to prepare my interviewing smile in this video I want to take a look at two 7a which is marked as easy first bad version I'm a product manager when currently leading a team to develop a new product unfortunately the latest vers... | First Bad Version | first-bad-version | You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.
Suppose you have `n` versions `[1, 2, ..., n]` an... | null | Binary Search,Interactive | Easy | 34,35,374 |
714 | hi guys welcome to algorithms made easy my name is khushboo and in this video we are going to see the question best time to buy and sell stock with transaction fee you are given an array prices where prices of i is the price of the given stock on the ith day and an integer fee representing the transaction fee find the ... | Best Time to Buy and Sell Stock with Transaction Fee | best-time-to-buy-and-sell-stock-with-transaction-fee | You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day, and an integer `fee` representing a transaction fee.
Find the maximum profit you can achieve. You may complete as many transactions as you like, but you need to pay the transaction fee for each transaction.
**Note:** You... | Consider the first K stock prices. At the end, the only legal states are that you don't own a share of stock, or that you do. Calculate the most profit you could have under each of these two cases. | Array,Dynamic Programming,Greedy | Medium | 122 |
1 | hello everyone and welcome to Python programming practice this video we're going to be coding up a couple different solutions to leet code number one so we're just gonna start by reading through the problem and then we will code up a couple different solutions for it so the problem is called to sum it has a difficulty ... | Two Sum | two-sum | Given an array of integers `nums` and an integer `target`, return _indices of the two numbers such that they add up to `target`_.
You may assume that each input would have **_exactly_ one solution**, and you may not use the _same_ element twice.
You can return the answer in any order.
**Example 1:**
**Input:** nums... | A really brute force way would be to search for all possible pairs of numbers but that would be too slow. Again, it's best to try out brute force solutions for just for completeness. It is from these brute force solutions that you can come up with optimizations. So, if we fix one of the numbers, say x, we have to scan ... | Array,Hash Table | Easy | 15,18,167,170,560,653,1083,1798,1830,2116,2133,2320 |
191 | hello guys hope all you are doing good so today i am going to discuss this question it got 191 number of one bits i'm going to solve this in two languages which is one of uh i mean one is c plus and another is java so let me first do it in java i'm not going to implement this by uh my own there are some built-in functi... | Number of 1 Bits | number-of-1-bits | Write a function that takes the binary representation of an unsigned integer and returns the number of '1' bits it has (also known as the [Hamming weight](http://en.wikipedia.org/wiki/Hamming_weight)).
**Note:**
* Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input ... | null | Bit Manipulation | Easy | 190,231,338,401,461,693,767 |
152 | hello friends this is shravan kumar mantri technical trainer welcome to my channel csc gurus in the series of video lectures i want to explain some of lead code problems which are mostly asked in top level companies and here i want to explain them clearly hope it works well for you so the first one i have taken the max... | Maximum Product Subarray | maximum-product-subarray | Given an integer array `nums`, find a subarray that has the largest product, and return _the product_.
The test cases are generated so that the answer will fit in a **32-bit** integer.
**Example 1:**
**Input:** nums = \[2,3,-2,4\]
**Output:** 6
**Explanation:** \[2,3\] has the largest product 6.
**Example 2:**
**I... | null | Array,Dynamic Programming | Medium | 53,198,238,628,713 |
908 | oh welcome guys so nine hundred eight okay nine zero eight yeah so given array of integer uh for each individual ai you can choose x uh this s belongs to minus k and s to a after this process we have some array b i reason smallest possible difference between maximum value and the minimum value of b uh so it is one k ze... | Smallest Range I | middle-of-the-linked-list | You are given an integer array `nums` and an integer `k`.
In one operation, you can choose any index `i` where `0 <= i < nums.length` and change `nums[i]` to `nums[i] + x` where `x` is an integer from the range `[-k, k]`. You can apply this operation **at most once** for each index `i`.
The **score** of `nums` is the... | null | Linked List,Two Pointers | Easy | 2216,2236 |
1,903 | welcome back for another video we are going to do analytical question the question is largest odd number in string you are given a string noun representing a large integer return the largest valued odd integer as a string that is a noun empty substring of noun or a empty string if no odd integer exists a substring is a... | Largest Odd Number in String | design-most-recently-used-queue | You are given a string `num`, representing a large integer. Return _the **largest-valued odd** integer (as a string) that is a **non-empty substring** of_ `num`_, or an empty string_ `" "` _if no odd integer exists_.
A **substring** is a contiguous sequence of characters within a string.
**Example 1:**
**Input:** nu... | You can store the data in an array and apply each fetch by moving the ith element to the end of the array (i.e, O(n) per operation). A better way is to use the square root decomposition technique. You can build chunks of size sqrt(n). For each fetch operation, You can search for the chunk which has the ith element and ... | Array,Hash Table,Stack,Design,Binary Indexed Tree,Ordered Set | Medium | 146 |
116 | hey everybody this is larry this is day 29 three days left of the december league code daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's farm populating nick's right pointers in each node okay so you're given a perfect binary tree where all leaves a... | Populating Next Right Pointers in Each Node | populating-next-right-pointers-in-each-node | You are given a **perfect binary tree** where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:
struct Node {
int val;
Node \*left;
Node \*right;
Node \*next;
}
Populate each next pointer to point to its next right node. If there is no next righ... | null | Linked List,Tree,Depth-First Search,Breadth-First Search,Binary Tree | Medium | 117,199 |
812 | uh so somebody gave you a set of points and you try to output the what are you trying to try to return and we have largest triangle okay so basically you need to choose three points and uh give you the triangle give you a try uh the area of triangle okay so the key point is that you need to know the formula of this so ... | Largest Triangle Area | rotate-string | Given an array of points on the **X-Y** plane `points` where `points[i] = [xi, yi]`, return _the area of the largest triangle that can be formed by any three different points_. Answers within `10-5` of the actual answer will be accepted.
**Example 1:**
**Input:** points = \[\[0,0\],\[0,1\],\[1,0\],\[0,2\],\[2,0\]\]
*... | null | String,String Matching | Easy | null |
629 | hey everybody this is Larry this is day 27 of the leco d challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's Farm ah we got a hard one yay 629k inverse pairs away um so I was going to say that uh I was saving this for a hard one but I am a little bit lazy a... | K Inverse Pairs Array | k-inverse-pairs-array | For an integer array `nums`, an **inverse pair** is a pair of integers `[i, j]` where `0 <= i < j < nums.length` and `nums[i] > nums[j]`.
Given two integers n and k, return the number of different arrays consist of numbers from `1` to `n` such that there are exactly `k` **inverse pairs**. Since the answer can be huge,... | null | Dynamic Programming | Hard | null |
728 | what's up guys my name is Michael and welcome to my youtube channel today we're going to do another league code challenge self dividing numbers a self dividing number is a number that is divisible by every digit it contains for example 1 2 8 is a self dividing number because 1 - 8 mod 1 is equal to 0 1 - 8 because 1 - ... | Self Dividing Numbers | self-dividing-numbers | 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`.
A **self-dividing number** is not allowed to contain the digit zero.
Given two integers `left` and `right`, return _a l... | For each number in the range, check whether it is self dividing by converting that number to a character array (or string in Python), then checking that each digit is nonzero and divides the original number. | Math | Easy | 507 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.