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 |
|---|---|---|---|---|---|---|---|---|
1,903 | Do it 200 Hello brother, today we are going to discuss the important thing that has been given to us is that in winters village, if anyone wants a job then he can do it and if no one else among us can speak English then We have to return half so if we see once what is the meaning of Sab Singh then it is given that who ... | 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 |
1,027 | hey guys today we're going to be solving a code question one zero two seven longest arithmetic sequence this is a dynamic programming question it's a very popular question and if you have been struggling with this question don't worry about it because it is not a very intuitive the solution to this question is not very... | Longest Arithmetic Subsequence | sum-of-even-numbers-after-queries | Given an array `nums` of integers, return _the length of the longest arithmetic subsequence in_ `nums`.
**Note** that:
* A **subsequence** is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.
* A sequence `seq` is arithmetic if `s... | null | Array,Simulation | Medium | null |
1,319 | hello everyone welcome to my youtube channel learn to code in this video we are going to talk about problem 1319 number of operations to make network connected from the code so as you have read the question basically in this question we are given few disconnected components of a graph our task is to connect all of them... | Number of Operations to Make Network Connected | unique-number-of-occurrences | There are `n` computers numbered from `0` to `n - 1` connected by ethernet cables `connections` forming a network where `connections[i] = [ai, bi]` represents a connection between computers `ai` and `bi`. Any computer can reach any other computer directly or indirectly through the network.
You are given an initial com... | Find the number of occurrences of each element in the array using a hash map. Iterate through the hash map and check if there is a repeated value. | Array,Hash Table | Easy | null |
1,832 | what is a pan gram is nothing but a special type of string which has all the letters of the English alphabet occurring at least once so it will have every letter A to Z and they can be repeated multiple number of times but every letter will occur at least once you understand this problems becomes fairly simple to solve... | Check if the Sentence Is Pangram | minimum-operations-to-make-a-subsequence | A **pangram** is a sentence where every letter of the English alphabet appears at least once.
Given a string `sentence` containing only lowercase English letters, return `true` _if_ `sentence` _is a **pangram**, or_ `false` _otherwise._
**Example 1:**
**Input:** sentence = "thequickbrownfoxjumpsoverthelazydog "
**O... | The problem can be reduced to computing Longest Common Subsequence between both arrays. Since one of the arrays has distinct elements, we can consider that these elements describe an arrangement of numbers, and we can replace each element in the other array with the index it appeared at in the first array. Then the pro... | Array,Hash Table,Binary Search,Greedy | Hard | null |
345 | hi everyone today we're working on the leak code Challenge number 345 reverse the vowels of a string and in this challenge we're going to be giving the string s and they want you to reverse only the vowels in the string so leave the consonants exactly in place and Swap and reverse the vowels as you go through the strin... | Reverse Vowels of a String | reverse-vowels-of-a-string | Given a string `s`, reverse only all the vowels in the string and return it.
The vowels are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`, and they can appear in both lower and upper cases, more than once.
**Example 1:**
**Input:** s = "hello"
**Output:** "holle"
**Example 2:**
**Input:** s = "leetcode"
**Output:** "leotc... | null | Two Pointers,String | Easy | 344,1089 |
394 | Hello friends welcome to your channel today is our day 49 of challenge so let's go straight to the screen and start today's challenge so the number of today's question is 394 and the name of the question is decode string ok Yesterday also we had given some similar type of questions, basically it is going on the string,... | 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 |
126 | welcome to january's liko challenge hope you all are having a great 2021. uh today's problem is called word ladder now given two words begin word and a dictionary word list return the length of the shortest transformation sequence from begin word to n word such that only one letter can be changed at a time and each tra... | Word Ladder II | word-ladder-ii | A **transformation sequence** from word `beginWord` to word `endWord` using a dictionary `wordList` is a sequence of words `beginWord -> s1 -> s2 -> ... -> sk` such that:
* Every adjacent pair of words differs by a single letter.
* Every `si` for `1 <= i <= k` is in `wordList`. Note that `beginWord` does not need ... | null | Hash Table,String,Backtracking,Breadth-First Search | Hard | 127,2276 |
1,284 | hey welcome back today we're going to continue our journey to bfs so we're going to talk about this minimum number of the flips to convert a binary matrix to zero matrix so basically the question is asking you have a matrix and m times n and in one step you can choose one cell and flip it with all the four neighbors as... | Minimum Number of Flips to Convert Binary Matrix to Zero Matrix | four-divisors | Given a `m x n` binary matrix `mat`. In one step, you can choose one cell and flip it and all the four neighbors of it if they exist (Flip is changing `1` to `0` and `0` to `1`). A pair of cells are called neighbors if they share one edge.
Return the _minimum number of steps_ required to convert `mat` to a zero matrix... | Find the divisors of each element in the array. You only need to loop to the square root of a number to find its divisors. | Array,Math | Medium | null |
47 | hey guys welcome back to my channel and i'm back again with another really interesting coding interview question video so this time guys we are using another backtracking question called as permutations two it is question number 47 of lead code and a medium level question today we'll solve it right here in this video a... | Permutations II | permutations-ii | Given a collection of numbers, `nums`, that might contain duplicates, return _all possible unique permutations **in any order**._
**Example 1:**
**Input:** nums = \[1,1,2\]
**Output:**
\[\[1,1,2\],
\[1,2,1\],
\[2,1,1\]\]
**Example 2:**
**Input:** nums = \[1,2,3\]
**Output:** \[\[1,2,3\],\[1,3,2\],\[2,1,3\],\[2,3,... | null | Array,Backtracking | Medium | 31,46,267,1038 |
48 | Hi Everyone Welcome Back to My Channel Today is Day 41 of our 75 Days Coding Challenge and the coding problem we are going to solve today is Rotate Image I mean the image we have given is in the form of a D array. And we have to rotate it 90 degrees, so let's see what the question is, how we have to solve it. Start so ... | 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 |
94 | hi everyone in this tutorial let's discuss what is in order traversal and how we can implement them using iterative and recursive approach in my previous video tutorials i have already covered two t traversal algorithms one is level order traversal and other is pre-order traversal is pre-order traversal is pre-order tr... | 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 |
301 | so we have remove invalid parentheses probably here so essentially you were given a string and there are a certain amount of left and right or open or closed parenthesis so your goal is to match them so they're a valid a pair of um valid number pairs of parentheses and you can ignore all the non-parentheses char all th... | Remove Invalid Parentheses | remove-invalid-parentheses | Given a string `s` that contains parentheses and letters, remove the minimum number of invalid parentheses to make the input string valid.
Return _a list of **unique strings** that are valid with the minimum number of removals_. You may return the answer in **any order**.
**Example 1:**
**Input:** s = "()())() "
**... | Since we don't know which of the brackets can possibly be removed, we try out all the options! We can use recursion to try out all possibilities for the given expression. For each of the brackets, we have 2 options:
We keep the bracket and add it to the expression that we are building on the fly during recursion.... | String,Backtracking,Breadth-First Search | Hard | 20,2095 |
222 | hey guys this is just how's winning going in this video let's take a look at uh two we're giving a complete binary tree we need to count the number of nodes um so the definition of complete tree is that except the last layer all the layer all level is completely filled and the last layer have all the nodes uh aligned l... | Count Complete Tree Nodes | count-complete-tree-nodes | Given the `root` of a **complete** binary tree, return the number of the nodes in the tree.
According to **[Wikipedia](http://en.wikipedia.org/wiki/Binary_tree#Types_of_binary_trees)**, every level, except possibly the last, is completely filled in a complete binary tree, and all nodes in the last level are as far lef... | null | Binary Search,Tree,Depth-First Search,Binary Tree | Medium | 270 |
1,980 | hey everyone welcome back and let's write some more neat code today so today let's solve the problem find unique binary string a problem from this afternoon's leak code contest and the thing about this problem is that you probably know how to solve it immediately as soon as you read it but you might not know how to cod... | Find Unique Binary String | faulty-sensor | Given an array of strings `nums` containing `n` **unique** binary strings each of length `n`, return _a binary string of length_ `n` _that **does not appear** in_ `nums`_. If there are multiple answers, you may return **any** of them_.
**Example 1:**
**Input:** nums = \[ "01 ", "10 "\]
**Output:** "11 "
**Explanatio... | Check for a common prefix of the two arrays. After this common prefix, there should be one array similar to the other but shifted by one. If both arrays can be shifted, return -1. | Array,Two Pointers | Easy | null |
96 | hello viewers welcome back to coding interviews channel hope you're doing great if you haven't subscribed to the channel yet please go ahead and subscribe I have created a bunch of playlists to cover various categories of problems such as BFS DFS Janek programming stacks queues linked lists race graph and so on please ... | Unique Binary Search Trees | unique-binary-search-trees | Given an integer `n`, return _the number of structurally unique **BST'**s (binary search trees) which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`.
**Example 1:**
**Input:** n = 3
**Output:** 5
**Example 2:**
**Input:** n = 1
**Output:** 1
**Constraints:**
* `1 <= n <= 19` | null | Math,Dynamic Programming,Tree,Binary Search Tree,Binary Tree | Medium | 95 |
1,935 | hey everybody this is larry this is me going with q1 of the weekly contest 250 maximum number of words you can type uh hit the like button hit the subscribe button join me on discord let me know what you think about this from this contest whatever german you know yeah um so this one is pretty straightforward to be fran... | Maximum Number of Words You Can Type | minimum-number-of-operations-to-reinitialize-a-permutation | There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly.
Given a string `text` of words separated by a single space (no leading or trailing spaces) and a string `brokenLetters` of all **distinct** letter keys that are broken, return _the **number of words** i... | It is safe to assume the number of operations isn't more than n The number is small enough to apply a brute force solution. | Array,Math,Simulation | Medium | null |
724 | hi everyone today we are going to solve the readable question find the pivot index so you are given array of integers num and calculate the pivot index of this array so the pivot index is the index where the sum of all the numbers directly to the left of the index is equal to the sum of all the numbers strictly to the ... | Find Pivot Index | find-pivot-index | Given an array of integers `nums`, calculate the **pivot index** of this array.
The **pivot index** is the index where the sum of all the numbers **strictly** to the left of the index is equal to the sum of all the numbers **strictly** to the index's right.
If the index is on the left edge of the array, then the left... | We can precompute prefix sums P[i] = nums[0] + nums[1] + ... + nums[i-1].
Then for each index, the left sum is P[i], and the right sum is P[P.length - 1] - P[i] - nums[i]. | Array,Prefix Sum | Easy | 560,2102,2369 |
1,646 | Hello Hi Everyone Welcome To My Channel It's All The Problem Get Maximum Engine Related Are Sour Given In Interior And Are Number Of Land And Plus One Generated In The Following Verses And Subscribe Where All Lies Between Two Subscribe Button For Inclusive Velvet 16000 Subscription To Solve This problem solve older pos... | Get Maximum in Generated Array | kth-missing-positive-number | You are given an integer `n`. A **0-indexed** integer array `nums` of length `n + 1` is generated in the following way:
* `nums[0] = 0`
* `nums[1] = 1`
* `nums[2 * i] = nums[i]` when `2 <= 2 * i <= n`
* `nums[2 * i + 1] = nums[i] + nums[i + 1]` when `2 <= 2 * i + 1 <= n`
Return _the **maximum** integer in the... | Keep track of how many positive numbers are missing as you scan the array. | Array,Binary Search | Easy | 2305 |
1,624 | So hello everyone welcome back to my channel once again so today we are going to solve today's problem of the date code which is the largest substring between two equal characters lead code 1624 okay now what do we need in this A string A is given, okay, we have to return the length of the longest sub string, okay, bet... | Largest Substring Between Two Equal Characters | clone-binary-tree-with-random-pointer | Given a string `s`, return _the length of the longest substring between two equal characters, excluding the two characters._ If there is no such substring return `-1`.
A **substring** is a contiguous sequence of characters within a string.
**Example 1:**
**Input:** s = "aa "
**Output:** 0
**Explanation:** The optim... | Traverse the tree, keep a hashtable with you and create a nodecopy for each node in the tree. Start traversing the original tree again and connect the left, right and random pointers in the cloned tree the same way as the original tree with the help of the hashtable. | Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree | Medium | 133,138,1634 |
257 | what's up everyone today we're gonna go over Lee code 257 now the input is going to be a binary tree and the output is going to be a list of strings and what we need to return is all the root to leaf paths for example one two and five is one of the strings and one and three is the other string so let's say for example ... | Binary Tree Paths | binary-tree-paths | Given the `root` of a binary tree, return _all root-to-leaf paths in **any order**_.
A **leaf** is a node with no children.
**Example 1:**
**Input:** root = \[1,2,3,null,5\]
**Output:** \[ "1->2->5 ", "1->3 "\]
**Example 2:**
**Input:** root = \[1\]
**Output:** \[ "1 "\]
**Constraints:**
* The number of nodes ... | null | String,Backtracking,Tree,Depth-First Search,Binary Tree | Easy | 113,1030,2217 |
115 | hello friends so today in this video we're gonna discuss another problem from lead code the problem name is distant subsequence so let's start the problem goes like this that you have two strings s and t and you have to turn the number of distinct subsequences of s which equals to t so there's also one example which is... | Distinct Subsequences | distinct-subsequences | Given two strings `s` and `t`, return _the number of distinct_ **_subsequences_** _of_ `s` _which equals_ `t`.
The test cases are generated so that the answer fits on a 32-bit signed integer.
**Example 1:**
**Input:** s = "rabbbit ", t = "rabbit "
**Output:** 3
**Explanation:**
As shown below, there are 3 ways you... | null | String,Dynamic Programming | Hard | 2115 |
424 | all right so let's talk about the longest repeating character replacement so you're giving the student s and integer K so you want to choose any later of us uh in the Stream and then change it to any operator and then you can perform the operation K times so you want to find out the length of the longer substring so uh... | Longest Repeating Character Replacement | longest-repeating-character-replacement | You are given a string `s` and an integer `k`. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most `k` times.
Return _the length of the longest substring containing the same letter you can get after performing the above operations_.
... | null | Hash Table,String,Sliding Window | Medium | 340,1046,2119,2134,2319 |
1,847 | hey what's up guys uh this is sean here so this is this time a little number 1847 closest room okay so you're given like uh un-rooms in the you're given like uh un-rooms in the you're given like uh un-rooms in the hotel right so and each room is represented by a 2d integer array where the first element is the room id a... | Closest Room | largest-subarray-length-k | There is a hotel with `n` rooms. The rooms are represented by a 2D integer array `rooms` where `rooms[i] = [roomIdi, sizei]` denotes that there is a room with room number `roomIdi` and size equal to `sizei`. Each `roomIdi` is guaranteed to be **unique**.
You are also given `k` queries in a 2D array `queries` where `qu... | Search for the largest integer in the range [0, n - k] This integer is the first element in the subarray. You should take it with the k - 1 elements after it. | Array,Greedy | Easy | null |
204 | hi guys my name is khushbu and welcome to algorithms made easy in this video we will see the question count primes count the number of primes that are less than the non-negative number given to us than the non-negative number given to us than the non-negative number given to us which is n in the example one we are give... | Count Primes | count-primes | Given an integer `n`, return _the number of prime numbers that are strictly less than_ `n`.
**Example 1:**
**Input:** n = 10
**Output:** 4
**Explanation:** There are 4 prime numbers less than 10, they are 2, 3, 5, 7.
**Example 2:**
**Input:** n = 0
**Output:** 0
**Example 3:**
**Input:** n = 1
**Output:** 0
**Co... | Let's start with a isPrime function. To determine if a number is prime, we need to check if it is not divisible by any number less than n. The runtime complexity of isPrime function would be O(n) and hence counting the total prime numbers up to n would be O(n2). Could we do better? As we know the number must not be div... | Array,Math,Enumeration,Number Theory | Medium | 263,264,279 |
921 | welcome back everyone we're gonna be solving Lee code 921 minimum add to make parentheses valid so in this problem they give us a parentheses string and we need to return the minimum additions we need to make in order to make a parentheses string valid so let's take a look at example one gives us the string of an openi... | Minimum Add to Make Parentheses Valid | spiral-matrix-iii | A parentheses string is valid if and only if:
* It is the empty string,
* It can be written as `AB` (`A` concatenated with `B`), where `A` and `B` are valid strings, or
* It can be written as `(A)`, where `A` is a valid string.
You are given a parentheses string `s`. In one move, you can insert a parenthesis at... | null | Array,Matrix,Simulation | Medium | 54,59 |
72 | hello friends today less of their added distance problem this is a classic curtain make programming problem let's first see the statement given two words or the one in word to find the minimum number of operations required to convert what the one you were to you have a following three operations permitted on a word ins... | Edit Distance | 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
**Example 1:**
**Input:** word1 = "horse ", word2 = "ros "
**O... | null | String,Dynamic Programming | Hard | 161,583,712,1105,2311 |
1,982 | hey everybody this is larry this is me going with q4 of the weekly contest 255 find a way given subset sums so you may notice that i actually didn't stop this during the contest i actually saw this about 15 minutes after the contest and you can actually watch this live aft after my explanation um it's very long you cou... | Find Array Given Subset Sums | remove-duplicates-from-an-unsorted-linked-list | You are given an integer `n` representing the length of an unknown array that you are trying to recover. You are also given an array `sums` containing the values of all `2n` **subset sums** of the unknown array (in no particular order).
Return _the array_ `ans` _of length_ `n` _representing the unknown array. If **mul... | Is there a way we can know beforehand which nodes to delete? Count the number of appearances for each number. | Hash Table,Linked List | Medium | 82,83 |
103 | all right let's get started it's been a while since i've done elite code question to be honest i've been away for a week on a family vacation plus a developer conference so that's been sort of where i've been so i apologize for not uploading anything within the week in any case let's get back into it and get into our f... | Binary Tree Zigzag Level Order Traversal | binary-tree-zigzag-level-order-traversal | Given the `root` of a binary tree, return _the zigzag level order traversal of its nodes' values_. (i.e., from left to right, then right to left for the next level and alternate between).
**Example 1:**
**Input:** root = \[3,9,20,null,null,15,7\]
**Output:** \[\[3\],\[20,9\],\[15,7\]\]
**Example 2:**
**Input:** roo... | null | Tree,Breadth-First Search,Binary Tree | Medium | 102 |
189 | That aapke Ajay ko hua hai Hello hello everyone welcome to new video this video or any tourists and the question for its question more no problem said that if anything can happen then ghee then subscribe us. Now we will be given this to subscribe, what do we do if we first will come here and that Shruti and 56 if the i... | 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 |
414 | Today we are going to talk about the problem of the third maximum number on the list, so this problem has 3 solutions, subscribe here, so I am going to do this, so see here, share and subscribe and You will have to subscribe maximum number here see it here delegate here now subscribe this number two so you will get men... | Third Maximum Number | third-maximum-number | Given an integer array `nums`, return _the **third distinct maximum** number in this array. If the third maximum does not exist, return the **maximum** number_.
**Example 1:**
**Input:** nums = \[3,2,1\]
**Output:** 1
**Explanation:**
The first distinct maximum is 3.
The second distinct maximum is 2.
The third distin... | null | Array,Sorting | Easy | 215 |
838 | hey everybody this is larry this is me going with july 21st the code daily challenge hit the like button hit subscribe and join me in discord i hope y'all are having a great week uh it's wednesday let's do today's farm push dominoes i usually saw this live so if it's a little bit slow fast forward to whatever you need ... | Push Dominoes | design-linked-list | There are `n` dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to the left or to the right.
After each second, each domino that is falling to the left pushes the adjacent domino on the left. Similarly, the dominoes falling to the righ... | null | Linked List,Design | Medium | 1337 |
792 | That these guys welcome to take good bye Nivedita and in this video we are going to solve 23rd July list challenge so before starting this video I request you guys if you like my video then like share and subscribe if any feedback now You should give everything, you can give Android, ok, let's start the video, hit, wha... | Number of Matching Subsequences | binary-search | Given a string `s` and an array of strings `words`, return _the number of_ `words[i]` _that is a subsequence of_ `s`.
A **subsequence** of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.
* For exa... | null | Array,Binary Search | Easy | 786 |
423 | hey what's up guys uh this is juan here again so uh let's take a look at today's daily challenge problem number 423 reconstruct our original djs from english i mean this one it's a very interesting problem you know not like any other problems only code so basically you're given like an empty string containing an out-of... | Reconstruct Original Digits from English | reconstruct-original-digits-from-english | Given a string `s` containing an out-of-order English representation of digits `0-9`, return _the digits in **ascending** order_.
**Example 1:**
**Input:** s = "owoztneoer"
**Output:** "012"
**Example 2:**
**Input:** s = "fviefuro"
**Output:** "45"
**Constraints:**
* `1 <= s.length <= 105`
* `s[i]` is one of ... | null | Hash Table,Math,String | Medium | null |
48 | hey and welcome today we will solve rotate image interval question which mostly asked by Amazon as lesson other companies like so we will explore two interesting solutions for this problem so without further Ado let's Dive In first example as you can see top Edge moves to the right Edge move to the bottom Edge bottom t... | 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 |
454 | uh hey everyone nitish's side so let's start with the question so the question is four sum two so you have given four integer array number num two num three and m four oh all are of length and it and you have to return the input basically i j k l uh it will be the sum of that pointer is equal to zero so let's see the q... | 4Sum II | 4sum-ii | Given four integer arrays `nums1`, `nums2`, `nums3`, and `nums4` all of length `n`, return the number of tuples `(i, j, k, l)` such that:
* `0 <= i, j, k, l < n`
* `nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0`
**Example 1:**
**Input:** nums1 = \[1,2\], nums2 = \[-2,-1\], nums3 = \[-1,2\], nums4 = \[0,2\]
**Ou... | null | Array,Hash Table | Medium | 18 |
1,706 | hello friends so today in this video we actually gonna discuss the problem from lead code problem name where will the ball fall so it's a medium lamp problem i will first let you understand the problem statement it actually states that you are having a like a 2d grid okay and each grid has some sort of panel okay as yo... | Where Will the Ball Fall | min-cost-to-connect-all-points | You have a 2-D `grid` of size `m x n` representing a box, and you have `n` balls. The box is open on the top and bottom sides.
Each cell in the box has a diagonal board spanning two corners of the cell that can redirect a ball to the right or to the left.
* A board that redirects the ball to the right spans the top... | Connect each pair of points with a weighted edge, the weight being the manhattan distance between those points. The problem is now the cost of minimum spanning tree in graph with above edges. | Array,Union Find,Minimum Spanning Tree | Medium | 2287 |
1,558 | uh hey everybody this is larry this is q3 of the recent nikko contest if you stayed to the end you're watching me solve it live during the contest um hit the like button hit the subscribe button draw me a discord and let's get started uh minimum number of function calls to make target array so we get this function whic... | Minimum Numbers of Function Calls to Make Target Array | course-schedule-iv | You are given an integer array `nums`. You have an integer array `arr` of the same length with all values set to `0` initially. You also have the following `modify` function:
You want to use the modify function to covert `arr` to `nums` using the minimum number of calls.
Return _the minimum number of function calls t... | Imagine if the courses are nodes of a graph. We need to build an array isReachable[i][j]. Start a bfs from each course i and assign for each course j you visit isReachable[i][j] = True. Answer the queries from the isReachable array. | Depth-First Search,Breadth-First Search,Graph,Topological Sort | Medium | null |
1,639 | Hello friends a very happy good morning good afternoon good evening come to the problem of the day series and today we are going to solve problem number 1639 the number of ways to form a Target string given is dictionary from the lead code it has been categorized a hard problem and to be honest it is a really scary pro... | Number of Ways to Form a Target String Given a Dictionary | friendly-movies-streamed-last-month | You are given a list of strings of the **same length** `words` and a string `target`.
Your task is to form `target` using the given `words` under the following rules:
* `target` should be formed from left to right.
* To form the `ith` character (**0-indexed**) of `target`, you can choose the `kth` character of th... | null | Database | Easy | null |
430 | hey guys welcome back to another video and today we're going to be solving the lead code question flatten a multi-level lead code question flatten a multi-level lead code question flatten a multi-level doubly linked list okay so we're given a doubly linked list which has a pointer to the next node and to the previous n... | 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 |
61 | welcome to october's leeco challenge today's problem is rotate list given the link to list rotate the list to the right by k places where k is a non-negative if k places where k is a non-negative if k places where k is a non-negative if we're given the list one two three four five and a k of two we're going to shift it... | Rotate List | rotate-list | Given the `head` of a linked list, rotate the list to the right by `k` places.
**Example 1:**
**Input:** head = \[1,2,3,4,5\], k = 2
**Output:** \[4,5,1,2,3\]
**Example 2:**
**Input:** head = \[0,1,2\], k = 4
**Output:** \[2,0,1\]
**Constraints:**
* The number of nodes in the list is in the range `[0, 500]`.
* ... | null | Linked List,Two Pointers | Medium | 189,725 |
304 | hi guys hope you're doing great arteries question has ranged some very 2d immutable this is an extension to a AZ problem alright some query immutable which I have covered in another video to understand this question and its solution better it's recommend that you watch that one first alright so given a 2d matrix find s... | Range Sum Query 2D - Immutable | range-sum-query-2d-immutable | Given a 2D matrix `matrix`, handle multiple queries of the following type:
* Calculate the **sum** of the elements of `matrix` inside the rectangle defined by its **upper left corner** `(row1, col1)` and **lower right corner** `(row2, col2)`.
Implement the `NumMatrix` class:
* `NumMatrix(int[][] matrix)` Initial... | null | Array,Design,Matrix,Prefix Sum | Medium | 303,308 |
374 | Yes, hello. I am Gary, a developer. I will not delay. The problem to be solved today is pass number 374, Haier 5 Lower. They say they are playing a choo-choo game. They say Lower. They say they are playing a choo-choo game. They say Lower. They say they are playing a choo-choo game. They say this game is as follows. I ... | Guess Number Higher or Lower | guess-number-higher-or-lower | We are playing the Guess Game. The game is as follows:
I pick a number from `1` to `n`. You have to guess which number I picked.
Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess.
You call a pre-defined API `int guess(int num)`, which returns three possible re... | null | Binary Search,Interactive | Easy | 278,375,658 |
1,008 | in this problem we have to construct a binary search tree from pre-order binary search tree from pre-order binary search tree from pre-order traversal so given a preorder traversal we have to construct a binary search tree and return its root node and how this output is printed so actually when you do the level order t... | Construct Binary Search Tree from Preorder Traversal | binary-tree-cameras | Given an array of integers preorder, which represents the **preorder traversal** of a BST (i.e., **binary search tree**), construct the tree and return _its root_.
It is **guaranteed** that there is always possible to find a binary search tree with the given requirements for the given test cases.
A **binary search tr... | null | Dynamic Programming,Tree,Depth-First Search,Binary Tree | Hard | 1021 |
213 | we are given an array of integers representing the amount of money present in the house and these houses are arranged in a circle we need to rob the maximum amount of money from these houses such that we do not drop from two adjacent houses this problem is lot similar to the previous problem so it would be better if yo... | House Robber II | house-robber-ii | You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are **arranged in a circle.** That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have a security system connected, and **it will automatical... | Since House[1] and House[n] are adjacent, they cannot be robbed together. Therefore, the problem becomes to rob either House[1]-House[n-1] or House[2]-House[n], depending on which choice offers more money. Now the problem has degenerated to the House Robber, which is already been solved. | Array,Dynamic Programming | Medium | 198,256,276,337,600,656 |
563 | Jhal Hello Hi Guys Welcome To Co Dear Students Question In The Street In This Question Root Of Ministry And At Least Ones Every Tree Not To Notice The Difference Between All Subscribe 12345 Left Side Factory Values Is 30 Minutes Not The Dirty Factory Values Is 30 Minutes Not The Dirty Factory Values Is 30 Minutes... | Binary Tree Tilt | binary-tree-tilt | Given the `root` of a binary tree, return _the sum of every tree node's **tilt**._
The **tilt** of a tree node is the **absolute difference** between the sum of all left subtree node **values** and all right subtree node **values**. If a node does not have a left child, then the sum of the left subtree node **values**... | Don't think too much, this is an easy problem. Take some small tree as an example. Can a parent node use the values of its child nodes? How will you implement it? May be recursion and tree traversal can help you in implementing. What about postorder traversal, using values of left and right childs? | Tree,Depth-First Search,Binary Tree | Easy | 1609 |
59 | Hello everyone welcome to my channel court sorry with mike so today you have 59 but it is not medium at which rape is quite an edgy question if you have watched my video of spiral matrix one, you have to copy paste the code from it, you have to do a little notification, this question The solution is ok, that's why watc... | Spiral Matrix II | spiral-matrix-ii | Given a positive integer `n`, generate an `n x n` `matrix` filled with elements from `1` to `n2` in spiral order.
**Example 1:**
**Input:** n = 3
**Output:** \[\[1,2,3\],\[8,9,4\],\[7,6,5\]\]
**Example 2:**
**Input:** n = 1
**Output:** \[\[1\]\]
**Constraints:**
* `1 <= n <= 20` | null | Array,Matrix,Simulation | Medium | 54,921 |
1,238 | so today we would be solving lead code question number one two three eight and that is circular permutation in binary representation so what the question says is that you need to put in uh numbers from zero up till two s to the power n minus 1 and N would be given to us in an array such that the first number start that... | Circular Permutation in Binary Representation | alphabet-board-path | Given 2 integers `n` and `start`. Your task is return **any** permutation `p` of `(0,1,2.....,2^n -1)` such that :
* `p[0] = start`
* `p[i]` and `p[i+1]` differ by only one bit in their binary representation.
* `p[0]` and `p[2^n -1]` must also differ by only one bit in their binary representation.
**Example 1:*... | Create a hashmap from letter to position on the board. Now for each letter, try moving there in steps, where at each step you check if it is inside the boundaries of the board. | Hash Table,String | Medium | null |
499 | hey everybody this is Larry this is December 11th uh where I will do an extra bonus uh problem that I haven't done before I'm gonna do it is Sunday and I am doing a little bit earlier in the day so I'm going to try to do a hard one and get it out of the way let's do a random okay so today's problem is 4.99 the maze fre... | The Maze III | the-maze-iii | There is a ball in a `maze` with empty spaces (represented as `0`) and walls (represented as `1`). The ball can go through the empty spaces by rolling **up, down, left or right**, but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction. There is also a hole in this maze. ... | null | Depth-First Search,Breadth-First Search,Graph,Heap (Priority Queue),Shortest Path | Hard | 490,505 |
125 | hey are you sleeping yes please shut up the stream bracket bike is now palindrome but this is well the palindrome is a straightforward two-pointer problem we have two pointers two-pointer problem we have two pointers two-pointer problem we have two pointers L and R which start at the leftmost and rightmost positions of... | Valid Palindrome | valid-palindrome | A phrase is a **palindrome** if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers.
Given a string `s`, return `true` _if it is a **palindrome**, or_ `false` _otherwise_... | null | Two Pointers,String | Easy | 234,680,2130,2231 |
42 | so we have this idea of trapping rainwater so we're given this array which represents the heights of individual mountains so we can see zero one zero and the array represent individual this side zero one zero here the black squares are kind of the mountains and the blue squares are the water that is trapped so if we co... | Trapping Rain Water | trapping-rain-water | Given `n` non-negative integers representing an elevation map where the width of each bar is `1`, compute how much water it can trap after raining.
**Example 1:**
**Input:** height = \[0,1,0,2,1,0,1,3,2,1,2,1\]
**Output:** 6
**Explanation:** The above elevation map (black section) is represented by array \[0,1,0,2,1,... | null | Array,Two Pointers,Dynamic Programming,Stack,Monotonic Stack | Hard | 11,238,407,756 |
164 | hey what's up guys so that song is 164 uh oh maximum gap uh yeah i hope you guys subscribe to my channel yeah so my channel autophysics must be abstract mathematics and horrible mathematics and sometimes since i'm practicing my coding so sometimes i pop post the code solution basically based on my understanding yeah so... | Maximum Gap | maximum-gap | Given an integer array `nums`, return _the maximum difference between two successive elements in its sorted form_. If the array contains less than two elements, return `0`.
You must write an algorithm that runs in linear time and uses linear extra space.
**Example 1:**
**Input:** nums = \[3,6,9,1\]
**Output:** 3
**E... | null | Array,Sorting,Bucket Sort,Radix Sort | Hard | null |
343 | in this video we're going to take a look at a legal problem called integer break so basically the question is that we're given an integer n and we want to break it into sum of k positive integers where k is bigger than or equal to two so basically we're given an integer n right let's say in this case n is like 2 for ex... | Integer Break | integer-break | Given an integer `n`, break it into the sum of `k` **positive integers**, where `k >= 2`, and maximize the product of those integers.
Return _the maximum product you can get_.
**Example 1:**
**Input:** n = 2
**Output:** 1
**Explanation:** 2 = 1 + 1, 1 \* 1 = 1.
**Example 2:**
**Input:** n = 10
**Output:** 36
**Exp... | There is a simple O(n) solution to this problem. You may check the breaking results of n ranging from 7 to 10 to discover the regularities. | Math,Dynamic Programming | Medium | 1936 |
134 | hey what's up guys John here so today I want to talk about another let's take a look at this little code problem 134 gas station and okay nice tickly let's take a look at this that's at this problem here so you're given like n gas stations along a circular route right where did the amount of gas at station Isaac a sigh... | Gas Station | gas-station | There are `n` gas stations along a circular route, where the amount of gas at the `ith` station is `gas[i]`.
You have a car with an unlimited gas tank and it costs `cost[i]` of gas to travel from the `ith` station to its next `(i + 1)th` station. You begin the journey with an empty tank at one of the gas stations.
Gi... | null | Array,Greedy | Medium | 1346 |
271 | others the next question is include and decode string so basically you have to design your own algorithm to you know including the visual screen or energy code afterwards so you're not able to use the sterilized method so you cannot you know improve letter over here right so um so one way of doing this is straightforwa... | Encode and Decode Strings | encode-and-decode-strings | Design an algorithm to encode **a list of strings** to **a string**. The encoded string is then sent over the network and is decoded back to the original list of strings.
Machine 1 (sender) has the function:
string encode(vector strs) {
// ... your code
return encoded\_string;
}
Machine 2 (receiver) has the func... | null | Array,String,Design | Medium | 38,297,443,696 |
131 | hey what's up guys this is sean here so today let's take a look at it called problem number 131 palindrome partitioning given like a string as partition as such that every substring of the partition is a palindrome okay and then return all the possible palindrome partition of s so i believe all of you should have known... | Palindrome Partitioning | palindrome-partitioning | Given a string `s`, partition `s` such that every substring of the partition is a **palindrome**. Return _all possible palindrome partitioning of_ `s`.
**Example 1:**
**Input:** s = "aab"
**Output:** \[\["a","a","b"\],\["aa","b"\]\]
**Example 2:**
**Input:** s = "a"
**Output:** \[\["a"\]\]
**Constraints:**
* `1... | null | String,Dynamic Programming,Backtracking | Medium | 132,1871 |
113 | so today we're looking at lead code number 113 it's called path sum2 very similar to path sum 1 which is also in this playlist so if you haven't checked out that video highly recommend checking out that video first because we're using a very similar template to solve this one just making some slight modifications okay ... | Path Sum II | path-sum-ii | Given the `root` of a binary tree and an integer `targetSum`, return _all **root-to-leaf** paths where the sum of the node values in the path equals_ `targetSum`_. Each path should be returned as a list of the node **values**, not node references_.
A **root-to-leaf** path is a path starting from the root and ending at... | null | Backtracking,Tree,Depth-First Search,Binary Tree | Medium | 112,257,437,666,2217 |
59 | given a positive integer in generate a square matrix filled with the elements from 1 to n square in spiral order that's about today's video less I mean kamalii this is where my dream started everyone this is Steve here today we are going through another little problem dude called 59 spiral matrix to you as we have gone... | Spiral Matrix II | spiral-matrix-ii | Given a positive integer `n`, generate an `n x n` `matrix` filled with elements from `1` to `n2` in spiral order.
**Example 1:**
**Input:** n = 3
**Output:** \[\[1,2,3\],\[8,9,4\],\[7,6,5\]\]
**Example 2:**
**Input:** n = 1
**Output:** \[\[1\]\]
**Constraints:**
* `1 <= n <= 20` | null | Array,Matrix,Simulation | Medium | 54,921 |
1,248 | Hello everyone, this is our problem today and in this we have to find how many numbers of off we will say to whom, OD number should be present and one key should be given to us in the input, as if we understand it through the example. Our first example is that we have been given the name 1211, like 1211 is also free an... | Count Number of Nice Subarrays | binary-tree-coloring-game | Given an array of integers `nums` and an integer `k`. A continuous subarray is called **nice** if there are `k` odd numbers on it.
Return _the number of **nice** sub-arrays_.
**Example 1:**
**Input:** nums = \[1,1,2,1,1\], k = 3
**Output:** 2
**Explanation:** The only sub-arrays with 3 odd numbers are \[1,1,2,1\] an... | The best move y must be immediately adjacent to x, since it locks out that subtree. Can you count each of (up to) 3 different subtrees neighboring x? | Tree,Depth-First Search,Binary Tree | Medium | null |
128 | hello and welcome back to the cracking fan YouTube channel today we're solving lead code problem 128 longest consecutive sequence given an unsorted array of integers numb return the length of the longest consecutive elements sequence you must write an algorithm that runs in Big O of end time let's look at a very basic ... | Longest Consecutive Sequence | longest-consecutive-sequence | Given an unsorted array of integers `nums`, return _the length of the longest consecutive elements sequence._
You must write an algorithm that runs in `O(n)` time.
**Example 1:**
**Input:** nums = \[100,4,200,1,3,2\]
**Output:** 4
**Explanation:** The longest consecutive elements sequence is `[1, 2, 3, 4]`. Therefor... | null | Array,Hash Table,Union Find | Medium | 298,2278 |
1,662 | hello guys welcome to algorithms made easy today we will be discussing the question check if two strings arrays are equivalent in this question we are given two string array word one word two and we need to return true if the two arrays represent the same string and false otherwise a string is represented by an array i... | Check If Two String Arrays are Equivalent | minimum-numbers-of-function-calls-to-make-target-array | Given two string arrays `word1` and `word2`, return `true` _if the two arrays **represent** the same string, and_ `false` _otherwise._
A string is **represented** by an array if the array elements concatenated **in order** forms the string.
**Example 1:**
**Input:** word1 = \[ "ab ", "c "\], word2 = \[ "a ", "bc "... | Work backwards: try to go from nums to arr. You should try to divide by 2 as much as possible, but you can only divide by 2 if everything is even. | Array,Greedy | Medium | null |
1,169 | hello yours welcome back to my channel I am back with another problem from read code I hope you are enjoying all the problems there I am applauding today's problem is invalid transactions from lead course so a transaction is possibly invalid if the amount exceeds thousand dollars are it if it occurs within 60 minutes o... | Invalid Transactions | largest-values-from-labels | A transaction is possibly invalid if:
* the amount exceeds `$1000`, or;
* if it occurs within (and including) `60` minutes of another transaction with the **same name** in a **different city**.
You are given an array of strings `transaction` where `transactions[i]` consists of comma-separated values representing ... | Consider the items in order from largest to smallest value, and greedily take the items if they fall under the use_limit. We can keep track of how many items of each label are used by using a hash table. | Array,Hash Table,Greedy,Sorting,Counting | Medium | null |
1,358 | Hello welcome to me youtube channel number characters a b and c so basically we have given a string ok and in it we have to extract the number and substance in which a list of a b and c i.e. abc should be present i.e. abc should be present i.e. abc should be present in this so let's take an example After that, what wil... | Number of Substrings Containing All Three Characters | find-positive-integer-solution-for-a-given-equation | Given a string `s` consisting only of characters _a_, _b_ and _c_.
Return the number of substrings containing **at least** one occurrence of all these characters _a_, _b_ and _c_.
**Example 1:**
**Input:** s = "abcabc "
**Output:** 10
**Explanation:** The substrings containing at least one occurrence of the charact... | Loop over 1 ≤ x,y ≤ 1000 and check if f(x,y) == z. | Math,Two Pointers,Binary Search,Interactive | Medium | null |
205 | hey everyone welcome back and let's write some more neat code today so today let's solve the problem isomorphic strings we are given two strings and we want to determine if they are isomorphic but what are isomorphic strings well the simple definition is they are isomorphic if all the characters of one string can be re... | Isomorphic Strings | isomorphic-strings | Given two strings `s` and `t`, _determine if they are isomorphic_.
Two strings `s` and `t` are isomorphic if the characters in `s` can be replaced to get `t`.
All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same characte... | null | Hash Table,String | Easy | 290 |
1,448 | hey everyone welcome back and let's write some more neat code today so today let's solve count good nodes in a binary tree this is according to leak code this is microsoft's most asked question of 2021 so far and in my opinion it's actually a pretty good problem to understand a lot of good fundamental knowledge can be ... | Count Good Nodes in Binary Tree | maximum-69-number | Given a binary tree `root`, a node _X_ in the tree is named **good** if in the path from root to _X_ there are no nodes with a value _greater than_ X.
Return the number of **good** nodes in the binary tree.
**Example 1:**
**Input:** root = \[3,1,4,3,null,1,5\]
**Output:** 4
**Explanation:** Nodes in blue are **good*... | Convert the number in an array of its digits. Brute force on every digit to get the maximum number. | Math,Greedy | Easy | null |
1,324 | elephants so today we discuss this question of lien code being clean 172 question number 1 3 2 4 print words vertically so in this question you are given a sequence of words or like a sentence in this there are different words and you have to stack them vertically in vertical order and then print the words as it is in ... | Print Words Vertically | where-will-the-ball-fall | Given a string `s`. Return all the words vertically in the same order in which they appear in `s`.
Words are returned as a list of strings, complete with spaces when is necessary. (Trailing spaces are not allowed).
Each word would be put on only one column and that in one column there will be only one word.
**Exam... | Use DFS. Traverse the path of the ball downwards until you reach the bottom or get stuck. | Array,Dynamic Programming,Depth-First Search,Matrix,Simulation | Medium | null |
7 | now i have a coding interview question integer reversal that was asked by linkin you are given an integer that integer can be positive or negative and you have to reversed the integer the reversed order would be like this four three two one and this integer can be negative for negative this value we should return minus... | 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 |
81 | mmm-hmm hey guys how's it been going mmm-hmm hey guys how's it been going mmm-hmm hey guys how's it been going long time no see there's outbreak of new I don't know coronavirus here everything's tend to be like stressful and we are starting to work remotely from home I hope this could be suppressed as soon as possible ... | Search in Rotated Sorted Array II | search-in-rotated-sorted-array-ii | There is an integer array `nums` sorted in non-decreasing order (not necessarily with **distinct** values).
Before being passed to your function, `nums` is **rotated** at an unknown pivot index `k` (`0 <= k < nums.length`) such that the resulting array is `[nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nu... | null | Array,Binary Search | Medium | 33 |
1,041 | hey everyone welcome back and let's write some more neat code today so today let's solve the problem robot bounded in circle and this actually according to leak code premium happens to be the number one asked question by amazon of this year 2021 and this is actually a pretty unique problem what makes this problem diffi... | Robot Bounded In Circle | available-captures-for-rook | On an infinite plane, a robot initially stands at `(0, 0)` and faces north. Note that:
* The **north direction** is the positive direction of the y-axis.
* The **south direction** is the negative direction of the y-axis.
* The **east direction** is the positive direction of the x-axis.
* The **west direction**... | null | Array,Matrix,Simulation | Easy | null |
232 | yo everyone this is Leo 232 Implement Q using Stacks I don't particularly like this problem I don't know if it's CU it's trivial or why but I just don't really like this problem that much but um I'll do it anyways because it's on the grand 75 list but uh we just have to implement a first in first out Q using two stacks... | 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 |
713 | hey what's up guys this is john here so uh this time i want to talk about uh today's daily challenge problem uh number 713 subarray product less than k a pretty good medium problem okay so you're given like an array of positive integers okay so this everything every number is positive and it asks you to count and print... | Subarray Product Less Than K | subarray-product-less-than-k | Given an array of integers `nums` and an integer `k`, return _the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than_ `k`.
**Example 1:**
**Input:** nums = \[10,5,2,6\], k = 100
**Output:** 8
**Explanation:** The 8 subarrays that have product less than 100 are:
... | For each j, let opt(j) be the smallest i so that nums[i] * nums[i+1] * ... * nums[j] is less than k. opt is an increasing function. | Array,Sliding Window | Medium | 152,325,560,1083,2233 |
1,611 | hello and welcome to another video in this problem we're going to be working on minimum one bit operations to make integers zero and you're given an iner n and you must transform into zero using the following operations you can change the rightmost bit or you can change the I bit in the binary representation if the IUS... | Minimum One Bit Operations to Make Integers Zero | making-file-names-unique | Given an integer `n`, you must transform it into `0` using the following operations any number of times:
* Change the rightmost (`0th`) bit in the binary representation of `n`.
* Change the `ith` bit in the binary representation of `n` if the `(i-1)th` bit is set to `1` and the `(i-2)th` through `0th` bits are set... | Keep a map of each name and the smallest valid integer that can be appended as a suffix to it. If the name is not present in the map, you can use it without adding any suffixes. If the name is present in the map, append the smallest proper suffix, and add the new name to the map. | Array,Hash Table,String | Medium | null |
74 | hey guys how's everything going I'm Jay sir I'm not tech lead today let's take a look at number 74 our lease code search a 2d matrix we're asked to write an efficient algorithm that search for a value in an MN matrix the matrix has following properties the first one integers you know each row are sorted from left to ri... | 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,754 | hi everyone welcome back to the channel today let's solve the median question from the contest largest merge of two strings and before we start don't forget to subscribe to my channel i'll be constantly solving good and classic clinical questions with clear explanation animation and visualization now let's look at a qu... | Largest Merge Of Two Strings | largest-merge-of-two-strings | You are given two strings `word1` and `word2`. You want to construct a string `merge` in the following way: while either `word1` or `word2` are non-empty, choose **one** of the following options:
* If `word1` is non-empty, append the **first** character in `word1` to `merge` and delete it from `word1`.
* For e... | null | null | Medium | null |
76 | Minimum Window Substance So basically we have two strings given soti and we have to find d minimum window in s which contains all d characters in t so first of all we will create a mapping of which character is occurring how many times so that On the basis of this, we can get the window valid date, then we will start t... | Minimum Window Substring | minimum-window-substring | Given two strings `s` and `t` of lengths `m` and `n` respectively, return _the **minimum window**_ **_substring_** _of_ `s` _such that every character in_ `t` _(**including duplicates**) is included in the window_. If there is no such substring, return _the empty string_ `" "`.
The testcases will be generated such tha... | Use two pointers to create a window of letters in S, which would have all the characters from T. Since you have to find the minimum window in S which has all the characters from T, you need to expand and contract the window using the two pointers and keep checking the window for all the characters. This approach is als... | Hash Table,String,Sliding Window | Hard | 30,209,239,567,632,727 |
374 | hi coders today we will solve two binary search problems in the first one we will apply binary search on the indices of the array while in the second one we'll apply binary search on a number range the first problem is problem 704 binary search on lead code i am discussing this problem for two reasons first to familiar... | Guess Number Higher or Lower | guess-number-higher-or-lower | We are playing the Guess Game. The game is as follows:
I pick a number from `1` to `n`. You have to guess which number I picked.
Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess.
You call a pre-defined API `int guess(int num)`, which returns three possible re... | null | Binary Search,Interactive | Easy | 278,375,658 |
20 | all right so today we're looking at leeco 20 valid parentheses i'm going to first start by creating a stack and then i'm going to create a dictionary filled with the parentheses i already did that because it's a little hard to type out and then we're going to say for the character in the string if the character is in t... | Valid Parentheses | valid-parentheses | Given a string `s` containing just the characters `'('`, `')'`, `'{'`, `'}'`, `'['` and `']'`, determine if the input string is valid.
An input string is valid if:
1. Open brackets must be closed by the same type of brackets.
2. Open brackets must be closed in the correct order.
3. Every close bracket has a corres... | An interesting property about a valid parenthesis expression is that a sub-expression of a valid expression should also be a valid expression. (Not every sub-expression) e.g.
{ { } [ ] [ [ [ ] ] ] } is VALID expression
[ [ [ ] ] ] is VALID sub-expression
{ } [ ] is VALID sub-express... | String,Stack | Easy | 22,32,301,1045,2221 |
1,326 | hey what's up guys sean here so this time let's talk about another dp problem uh number 1326 minimum number of tabs to water to open to water a garden so basically you're given like a number of gardens right from zero to five and also another array of the tabs so at each tab on each tab the range this tab can converter... | Minimum Number of Taps to Open to Water a Garden | sum-of-floored-pairs | There is a one-dimensional garden on the x-axis. The garden starts at the point `0` and ends at the point `n`. (i.e The length of the garden is `n`).
There are `n + 1` taps located at points `[0, 1, ..., n]` in the garden.
Given an integer `n` and an integer array `ranges` of length `n + 1` where `ranges[i]` (0-index... | Find the frequency (number of occurrences) of all elements in the array. For each element, iterate through its multiples and multiply frequencies to find the answer. | Array,Math,Binary Search,Prefix Sum | Hard | null |
72 | Hello hello friends welcome back to my channel home or doing great and space administration difficult my channel please do subscribe my favorite playlist subscribe statue subscribe research by research different on president of the rings for all players in description subscribe this video Distance That Given There Word... | Edit Distance | 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
**Example 1:**
**Input:** word1 = "horse ", word2 = "ros "
**O... | null | String,Dynamic Programming | Hard | 161,583,712,1105,2311 |
1,178 | so lead code practice question so in this question i'm going in this video i'm going to cover uh the question called number of valid words for each puzzle so i'm going to explain the solution and explain this piece of code and also at the same time i'm going to cover the procedure we should follow in the real code inte... | Number of Valid Words for Each Puzzle | valid-palindrome-iii | With respect to a given `puzzle` string, a `word` is _valid_ if both the following conditions are satisfied:
* `word` contains the first letter of `puzzle`.
* For each letter in `word`, that letter is in `puzzle`.
* For example, if the puzzle is `"abcdefg "`, then valid words are `"faced "`, `"cabbage "`, an... | Can you reduce this problem to a classic problem? The problem is equivalent to finding any palindromic subsequence of length at least N-K where N is the length of the string. Try to find the longest palindromic subsequence. Use DP to do that. | String,Dynamic Programming | Hard | 680 |
95 | All Everyone Today In Solving Question Light Turn On The Question Unique Binary Search Tree Rated By Over 250 Million Professionals Pacific Given In Increased And Western Australia Unique Poisonous Trees Which Mention Notes Of Unique Values To Trees Which Mention Notes Of Unique Values To Trees Which Mention Notes ... | Unique Binary Search Trees II | unique-binary-search-trees-ii | Given an integer `n`, return _all the structurally unique **BST'**s (binary search trees), which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`. Return the answer in **any order**.
**Example 1:**
**Input:** n = 3
**Output:** \[\[1,null,2,null,3\],\[1,null,3,2\],\[2,1,3\],\[3,1,null,null,2\],\[3,2,null,1\... | null | Dynamic Programming,Backtracking,Tree,Binary Search Tree,Binary Tree | Medium | 96,241 |
1,671 | Hello viewers welcome to my video recording pregnant very important problem in this corner minimum number free mode to make mountaineering president so energy amazon forms of mountain structure galaxy wall mounted safe supposed to have elements like just one to three layer investment disappointing subscribe first you h... | Minimum Number of Removals to Make Mountain Array | the-most-recent-three-orders | You may recall that an array `arr` is a **mountain array** if and only if:
* `arr.length >= 3`
* There exists some index `i` (**0-indexed**) with `0 < i < arr.length - 1` such that:
* `arr[0] < arr[1] < ... < arr[i - 1] < arr[i]`
* `arr[i] > arr[i + 1] > ... > arr[arr.length - 1]`
Given an integer arr... | null | Database | Medium | 1688 |
338 | hello and welcome today we're doing a question from leak code called Counting bits it's an easy we're going to jump right into it given an integer n return an array answer of length n plus one such that for each I and I is going to be in the range of 0 and N answer of I is the number of ones in the binary representatio... | Counting Bits | counting-bits | Given an integer `n`, return _an array_ `ans` _of length_ `n + 1` _such that for each_ `i` (`0 <= i <= n`)_,_ `ans[i]` _is the **number of**_ `1`_**'s** in the binary representation of_ `i`.
**Example 1:**
**Input:** n = 2
**Output:** \[0,1,1\]
**Explanation:**
0 --> 0
1 --> 1
2 --> 10
**Example 2:**
**Input:** n =... | You should make use of what you have produced already. Divide the numbers in ranges like [2-3], [4-7], [8-15] and so on. And try to generate new range from previous. Or does the odd/even status of the number help you in calculating the number of 1s? | Dynamic Programming,Bit Manipulation | Easy | 191 |
688 | hello everyone welcome back here is Vanessa and today we are going to unravel fascinating problem the Knight probability in chessboard so this problem is a medium level uh problem and uh but our trusty pattern by our side we can concur it together so let me lay out the problem for you we have a night starting at n by n... | Knight Probability in Chessboard | knight-probability-in-chessboard | On an `n x n` chessboard, a knight starts at the cell `(row, column)` and attempts to make exactly `k` moves. The rows and columns are **0-indexed**, so the top-left cell is `(0, 0)`, and the bottom-right cell is `(n - 1, n - 1)`.
A chess knight has eight possible moves it can make, as illustrated below. Each move is ... | null | Dynamic Programming | Medium | 576 |
116 | hey everyone in this video we are going to solve the populating next right pointer in each node only it could what the question says is we are given a balanced binary tree a perfect binary tree which is which means it's perfectly balanced every node other than the leaf nodes have exactly two childrens and what we need ... | 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 |
109 | hello guys welcome to another video in the series of coding today we are going to do the problem which is called sorted linked list to bst so you're given a singly link list you have to convert it to balanced binary search tree which has the same data value so this is the linked list that is given you have to convert i... | Convert Sorted List to Binary Search Tree | convert-sorted-list-to-binary-search-tree | Given the `head` of a singly linked list where elements are sorted in **ascending order**, convert _it to a_ **_height-balanced_** _binary search tree_.
**Example 1:**
**Input:** head = \[-10,-3,0,5,9\]
**Output:** \[0,-3,9,-10,null,5\]
**Explanation:** One possible answer is \[0,-3,9,-10,null,5\], which represents t... | null | Linked List,Divide and Conquer,Tree,Binary Search Tree,Binary Tree | Medium | 108,2306 |
223 | hey everybody this is Larry this is day 17 of the liko day challenge hit the like button and the Subscribe button join me on Discord let me know what you think about this problem um okay is it only what's going on here um okay what am I doing oh yeah checking for the extra coins nope um okay so yeah um what am I doing ... | Rectangle Area | rectangle-area | Given the coordinates of two **rectilinear** rectangles in a 2D plane, return _the total area covered by the two rectangles_.
The first rectangle is defined by its **bottom-left** corner `(ax1, ay1)` and its **top-right** corner `(ax2, ay2)`.
The second rectangle is defined by its **bottom-left** corner `(bx1, by1)` ... | null | Math,Geometry | Medium | 866 |
1,766 | so hello coders welcome to my channel and in this video i will be explaining the problem tree of co-primes the problem tree of co-primes the problem tree of co-primes and you know to be honest it is a really tough problem because not only it is difficult to think about the approach that what you have to do but even if ... | Tree of Coprimes | minimum-number-of-removals-to-make-mountain-array | There is a tree (i.e., a connected, undirected graph that has no cycles) consisting of `n` nodes numbered from `0` to `n - 1` and exactly `n - 1` edges. Each node has a value associated with it, and the **root** of the tree is node `0`.
To represent this tree, you are given an integer array `nums` and a 2D array `edge... | Think the opposite direction instead of minimum elements to remove the maximum mountain subsequence Think of LIS it's kind of close | Array,Binary Search,Dynamic Programming,Greedy | Hard | 300,875,882,978,1185 |
426 | okay so lead code practice time convert binary search cheat to sorted double linked list uh as usual two goals the first of all it is to find a solution to do some solid code uh in the lead code platform to solve this problem and the other thing is to see how to solve this problem in the interview properly so as usual ... | Convert Binary Search Tree to Sorted Doubly Linked List | convert-binary-search-tree-to-sorted-doubly-linked-list | Convert a **Binary Search Tree** to a sorted **Circular Doubly-Linked List** in place.
You can think of the left and right pointers as synonymous to the predecessor and successor pointers in a doubly-linked list. For a circular doubly linked list, the predecessor of the first element is the last element, and the succe... | null | null | Medium | null |
1,962 | hey guys today we will solve remove stones to minimize the totals uh you are given zero indexed integer array piles and piles I represent the number of stones of is file and you have given k a integer K where you can apply the operation exactly K times and in any operation choose any piles I and remove the uh that numb... | Remove Stones to Minimize the Total | single-threaded-cpu | You are given a **0-indexed** integer array `piles`, where `piles[i]` represents the number of stones in the `ith` pile, and an integer `k`. You should apply the following operation **exactly** `k` times:
* Choose any `piles[i]` and **remove** `floor(piles[i] / 2)` stones from it.
**Notice** that you can apply the ... | To simulate the problem we first need to note that if at any point in time there are no enqueued tasks we need to wait to the smallest enqueue time of a non-processed element We need a data structure like a min-heap to support choosing the task with the smallest processing time from all the enqueued tasks | Array,Sorting,Heap (Priority Queue) | Medium | 2176 |
1,706 | hello everyone so today we are going to do the question where will the Call fall so in this question we are given 2D grid Matrix of size M into n which is representing a box and which has n bonds what we are given is that we are given this box now what is it that if we are given Matrix like this if there is the value o... | Where Will the Ball Fall | min-cost-to-connect-all-points | You have a 2-D `grid` of size `m x n` representing a box, and you have `n` balls. The box is open on the top and bottom sides.
Each cell in the box has a diagonal board spanning two corners of the cell that can redirect a ball to the right or to the left.
* A board that redirects the ball to the right spans the top... | Connect each pair of points with a weighted edge, the weight being the manhattan distance between those points. The problem is now the cost of minimum spanning tree in graph with above edges. | Array,Union Find,Minimum Spanning Tree | Medium | 2287 |
922 | hua hai hello everyone hindi player am going to explain about shot are brother party software give no insight into the shoes of no anchor for the one more subscription 14257 24247 more fuel pimple 232 to 234 quinton points and who is the logic state today at andheri West * create equal to today at andheri West * create... | Sort Array By Parity II | possible-bipartition | Given an array of integers `nums`, half of the integers in `nums` are **odd**, and the other half are **even**.
Sort the array so that whenever `nums[i]` is odd, `i` is **odd**, and whenever `nums[i]` is even, `i` is **even**.
Return _any answer array that satisfies this condition_.
**Example 1:**
**Input:** nums =... | null | Depth-First Search,Breadth-First Search,Union Find,Graph | Medium | null |
500 | hey guys in this video i'll be going through how to solve leapfrog question 500 called keyboard row um so the question is we're going to be given an array of strings and we have to output an array of strings with all of the words that could have been made up with only one row of the keyboard so in the example here we w... | Keyboard Row | keyboard-row | Given an array of strings `words`, return _the words that can be typed using letters of the alphabet on only one row of American keyboard like the image below_.
In the **American keyboard**:
* the first row consists of the characters `"qwertyuiop "`,
* the second row consists of the characters `"asdfghjkl "`, and... | null | Array,Hash Table,String | Easy | null |
1,457 | hey everyone welcome back and let's write some more neat code today so today let's solve the problem pseudo palindromic paths in a binary tree we're given a binary tree where the values are only going to be in the range from 1 to 9 and in this problem we care about the paths in the binary tree that go from The Root Dow... | Pseudo-Palindromic Paths in a Binary Tree | minimum-difficulty-of-a-job-schedule | Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be **pseudo-palindromic** if at least one permutation of the node values in the path is a palindrome.
_Return the number of **pseudo-palindromic** paths going from the root node to leaf nodes._
**Example 1:**
**Input:*... | Use DP. Try to cut the array into d non-empty sub-arrays. Try all possible cuts for the array. Use dp[i][j] where DP states are i the index of the last cut and j the number of remaining cuts. Complexity is O(n * n * d). | Array,Dynamic Programming | Hard | null |
101 | okay welcome back to algojs in today's question we're going to be looking at the code 101 symmetric tree so given the root of a binary tree check whether it is a mirror of itself so symmetric around its center so in this first example we are comparing the left subtree with the right subtree so around the center and thi... | Symmetric Tree | symmetric-tree | Given the `root` of a binary tree, _check whether it is a mirror of itself_ (i.e., symmetric around its center).
**Example 1:**
**Input:** root = \[1,2,2,3,4,4,3\]
**Output:** true
**Example 2:**
**Input:** root = \[1,2,2,null,3,null,3\]
**Output:** false
**Constraints:**
* The number of nodes in the tree is in... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Easy | null |
59 | welcome to tim's leco challenge today's problem is spiral matrix two given a positive integer n generate an n times n matrix filled with elements one to n squared in spiral order for given number three we're going to return a three by three matrix with the order one two three four five six seven eight nine in major lik... | Spiral Matrix II | spiral-matrix-ii | Given a positive integer `n`, generate an `n x n` `matrix` filled with elements from `1` to `n2` in spiral order.
**Example 1:**
**Input:** n = 3
**Output:** \[\[1,2,3\],\[8,9,4\],\[7,6,5\]\]
**Example 2:**
**Input:** n = 1
**Output:** \[\[1\]\]
**Constraints:**
* `1 <= n <= 20` | null | Array,Matrix,Simulation | Medium | 54,921 |
948 | Hi gas welcome and welcome back to my channel so what is our problem today Bag of Tokens so what have you given us in this problem statement here we have been given initial power which is an initial score which is zero and given a bag of tokens OK, in which tokens i is representing the value of your token. Rectangle is... | Bag of Tokens | sort-an-array | You have an initial **power** of `power`, an initial **score** of `0`, and a bag of `tokens` where `tokens[i]` is the value of the `ith` token (0-indexed).
Your goal is to maximize your total **score** by potentially playing each token in one of two ways:
* If your current **power** is at least `tokens[i]`, you may... | null | Array,Divide and Conquer,Sorting,Heap (Priority Queue),Merge Sort,Bucket Sort,Radix Sort,Counting Sort | Medium | null |
1,027 | hello everyone welcome back here is vanamsin and today we are going to tackle daily uh lyrical challenge longest arithmetic subsequence it's a medium difficulty problem and it can be quite tricky to understand but once you do it's incredibly rewarding experience so let's dive into the problem so we are given an array o... | Longest Arithmetic Subsequence | sum-of-even-numbers-after-queries | Given an array `nums` of integers, return _the length of the longest arithmetic subsequence in_ `nums`.
**Note** that:
* A **subsequence** is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.
* A sequence `seq` is arithmetic if `s... | null | Array,Simulation | Medium | null |
438 | Ko Very slow Look at this Going to do a question Point Eyeliner Grams' actress We will have Point Eyeliner Grams' actress We will have Point Eyeliner Grams' actress We will have friends Ribbon AIDS patients And P What do we have to do with this ribbon P K Find these grams Okay Listen carefully S A string Happy string H... | 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 |
1,021 | all right let's talk about the remove outermost parentheses so you're given a valid parenthesis screens it's either empty or you have the something inside the parentheses so this is the example um so here we go so uh you are going to remove the outermost parentheses so you basically return this right so for this exampl... | Remove Outermost Parentheses | distribute-coins-in-binary-tree | A valid parentheses string is either empty `" "`, `"( " + A + ") "`, or `A + B`, where `A` and `B` are valid parentheses strings, and `+` represents string concatenation.
* For example, `" "`, `"() "`, `"(())() "`, and `"(()(())) "` are all valid parentheses strings.
A valid parentheses string `s` is primitive if i... | null | Tree,Depth-First Search,Binary Tree | Medium | 863,1008 |
402 | Jai hind is tutorial am going to discuss programming question remove kids for the problem statement that has given unknown negative interior name represented as a spring remove kids from the numbers for the new number is this small as possible and a great two important points improve length of number So on this day the... | Remove K Digits | remove-k-digits | Given string num representing a non-negative integer `num`, and an integer `k`, return _the smallest possible integer after removing_ `k` _digits from_ `num`.
**Example 1:**
**Input:** num = "1432219 ", k = 3
**Output:** "1219 "
**Explanation:** Remove the three digits 4, 3, and 2 to form the new number 1219 which ... | null | String,Stack,Greedy,Monotonic Stack | Medium | 321,738,1792,2305 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.