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 |
|---|---|---|---|---|---|---|---|---|
645 | hey everybody this is Larry this is day 22 of the Le on Discord let me know what you think about today's prom 645 said mismatch uh yeah before I start I want to just say um you know on my Discord and also just here um I talk a lot about grinding and just like working it out and how you know like even when I struggle wi... | Set Mismatch | set-mismatch | You have a set of integers `s`, which originally contains all the numbers from `1` to `n`. Unfortunately, due to some error, one of the numbers in `s` got duplicated to another number in the set, which results in **repetition of one** number and **loss of another** number.
You are given an integer array `nums` represe... | null | Array,Hash Table,Bit Manipulation,Sorting | Easy | 287 |
272 | hello and welcome back to the cracking thing youtube channel today we're going to be solving lead code problem 272 closest binary search tree value 2. before we get into it you guys know the drill subscribe to the channel it helps me grow all right given the root of a binary search tree a target value and an integer k ... | Closest Binary Search Tree Value II | closest-binary-search-tree-value-ii | Given the `root` of a binary search tree, a `target` value, and an integer `k`, return _the_ `k` _values in the BST that are closest to the_ `target`. You may return the answer in **any order**.
You are **guaranteed** to have only one unique set of `k` values in the BST that are closest to the `target`.
**Example 1:*... | Consider implement these two helper functions:
getPredecessor(N), which returns the next smaller node to N.
getSuccessor(N), which returns the next larger node to N. Try to assume that each node has a parent pointer, it makes the problem much easier. Without parent pointer we just need to keep track of the path from ... | Two Pointers,Stack,Tree,Depth-First Search,Binary Search Tree,Heap (Priority Queue),Binary Tree | Hard | 94,270 |
1,300 | hey yo what's up guys babybear4812 coming at you one more time uh first off forgive me for my uh ridiculous looking ensemble it's freezing today the heat isn't on in the building and um yeah that explains the sexy look but here or no he we got questions to answer and today's question is 1300 so it's one of the newer on... | Sum of Mutated Array Closest to Target | critical-connections-in-a-network | Given an integer array `arr` and a target value `target`, return the integer `value` such that when we change all the integers larger than `value` in the given array to be equal to `value`, the sum of the array gets as close as possible (in absolute difference) to `target`.
In case of a tie, return the minimum such in... | Use Tarjan's algorithm. | Depth-First Search,Graph,Biconnected Component | Hard | null |
968 | hey everybody this is larry this is may 16th the 16th day of the may leco daily challenge hit the like button hit the subscribe button join me in discord let me know what you think about this prom this kind uh just this farm i guess and today and whatever as i am you know have this relock style um just to give an updat... | 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 |
208 | hey everybody this is Larry this is day 17 of the liko data and hit the like button to the Subscribe button drop me on Discord let me know what you think about today's form 208 Implement try a prefix tree oh guys I mean there are a couple of ways you can do this but this is uh one of those textbook things I don't know ... | Implement Trie (Prefix Tree) | implement-trie-prefix-tree | A [**trie**](https://en.wikipedia.org/wiki/Trie) (pronounced as "try ") or **prefix tree** is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker.
Implement the Trie class:
* `Trie()` ... | null | Hash Table,String,Design,Trie | Medium | 211,642,648,676,1433,1949 |
406 | hey what's up guys come here and so this time let's take a look at another leet called problem number 406 cue reconstruction by height okay you're given a random list of people standing in a queue and each person is described by a pair of integers H and K where H is the height of the person and the K is a number of peo... | Queue Reconstruction by Height | queue-reconstruction-by-height | You are given an array of people, `people`, which are the attributes of some people in a queue (not necessarily in order). Each `people[i] = [hi, ki]` represents the `ith` person of height `hi` with **exactly** `ki` other people in front who have a height greater than or equal to `hi`.
Reconstruct and return _the queu... | What can you say about the position of the shortest person?
If the position of the shortest person is i, how many people would be in front of the shortest person? Once you fix the position of the shortest person, what can you say about the position of the second shortest person? | Array,Greedy,Binary Indexed Tree,Segment Tree,Sorting | Medium | 315 |
406 | hello everyone welcome to learn workflow in this quick video we will look into the another liquid problem that is the q reconstruction by height so this is a medium level question and we will understand how we can solve this question what exactly the question is asking us to do before going deep into the video subscrib... | Queue Reconstruction by Height | queue-reconstruction-by-height | You are given an array of people, `people`, which are the attributes of some people in a queue (not necessarily in order). Each `people[i] = [hi, ki]` represents the `ith` person of height `hi` with **exactly** `ki` other people in front who have a height greater than or equal to `hi`.
Reconstruct and return _the queu... | What can you say about the position of the shortest person?
If the position of the shortest person is i, how many people would be in front of the shortest person? Once you fix the position of the shortest person, what can you say about the position of the second shortest person? | Array,Greedy,Binary Indexed Tree,Segment Tree,Sorting | Medium | 315 |
6 | aha Roger land or sea yeah I'm like Halle which are the exact conversion sit out here Janaki this is ashwin on one Gary both scream who is a number title total homme the home this is the dreams of the function sure can be digital ta y pa I too late doc didn't puncture in camp idea now I'm kind of energy from the tour I... | 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 |
59 | hello and welcome to another leak code solution video this is problem number 59 spiral Matrix 2 for this problem we're given a positive integer n generate an N byn Matrix filled with elements from 1 to n^2 in spiral order for example one to n^2 in spiral order for example one to n^2 in spiral order for example one we'r... | 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 |
745 | okay 7:45 prefix and suffix search given okay 7:45 prefix and suffix search given okay 7:45 prefix and suffix search given many words word sub I has great I designer class word filter that supports one function word filter that it will return the world with a Kevin prefix and suffix with maximum weight if no word exist... | Prefix and Suffix Search | find-smallest-letter-greater-than-target | Design a special dictionary that searches the words in it by a prefix and a suffix.
Implement the `WordFilter` class:
* `WordFilter(string[] words)` Initializes the object with the `words` in the dictionary.
* `f(string pref, string suff)` Returns _the index of the word in the dictionary,_ which has the prefix `p... | Try to find whether each of 26 next letters are in the given string array. | Array,Binary Search | Easy | 2269 |
147 | hello everyone welcome to kodus camp we are at 15th day of december lead code challenge and the problem we are going to cover in this video is insertion sort list so we are given head ahead of a linked list and we have to return a sorted linked list it is as simple as that but they have given the procedure to sort the ... | Insertion Sort List | insertion-sort-list | Given the `head` of a singly linked list, sort the list using **insertion sort**, and return _the sorted list's head_.
The steps of the **insertion sort** algorithm:
1. Insertion sort iterates, consuming one input element each repetition and growing a sorted output list.
2. At each iteration, insertion sort removes... | null | Linked List,Sorting | Medium | 148,850 |
80 | Rice welcome and welcome back to my channel so in today's video we will solve the fourth problem of top interview 150 remove duplicates from sorted it added to you so this problem is similar to the previous two problems i.e. remove previous two problems i.e. remove previous two problems i.e. remove elements remove dupl... | Remove Duplicates from Sorted Array II | remove-duplicates-from-sorted-array-ii | Given an integer array `nums` sorted in **non-decreasing order**, remove some duplicates [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm) such that each unique element appears **at most twice**. The **relative order** of the elements should be kept the **same**.
Since it is impossible to change the len... | null | Array,Two Pointers | Medium | 26 |
231 | Hello Everyone Also Observed Every Time Without Meaning Suggestion subscribe Video plz subscribe Channel Please subscribe our The Power of Two List Ko 231 So Let's Talk Warden Ne Basically Prostate Consideration 65th Id Number Two subscribe to the Page if you liked The Video then subscribe to The Amazing Subscribe 98 I... | Power of Two | power-of-two | Given an integer `n`, return _`true` if it is a power of two. Otherwise, return `false`_.
An integer `n` is a power of two, if there exists an integer `x` such that `n == 2x`.
**Example 1:**
**Input:** n = 1
**Output:** true
**Explanation:** 20 = 1
**Example 2:**
**Input:** n = 16
**Output:** true
**Explanation:**... | null | Math,Bit Manipulation,Recursion | Easy | 191,326,342 |
350 | Hello guys welcome to banana seeds were being made then suggestion is definitely problem is isko and intersection of two boys so let's get started problem suppose given to a research including verses chapter-2 isko m with me two tight speakers logic code Will be simply food items in set and set as unique values rule ... | 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 |
5 | hello everyone and welcome to python programming practice in this episode we're going to be covering leak code number five called longest palindromic substring this is classified as a medium difficulty problem so it might take some doing to get the answer i'll start by reading through the description and the examples g... | Longest Palindromic Substring | longest-palindromic-substring | Given a string `s`, return _the longest_ _palindromic_ _substring_ in `s`.
**Example 1:**
**Input:** s = "babad "
**Output:** "bab "
**Explanation:** "aba " is also a valid answer.
**Example 2:**
**Input:** s = "cbbd "
**Output:** "bb "
**Constraints:**
* `1 <= s.length <= 1000`
* `s` consist of only dig... | How can we reuse a previously computed palindrome to compute a larger palindrome? If “aba” is a palindrome, is “xabax” a palindrome? Similarly is “xabay” a palindrome? Complexity based hint:
If we use brute-force and check whether for every start and end position a substring is a palindrome we have O(n^2) start - end ... | String,Dynamic Programming | Medium | 214,266,336,516,647 |
229 | Hua Hai Hello Hi Friends Welcome To My Channel Today We Are Going To Solve List Code Problem Number To 9 Majority Element 200 The Problem Statements And Settled In The Draw Size In Find All Elements And Happier Mode On In Three Times Solve We Have Been Given Address Of individuals and also have been given additional sh... | Majority Element II | majority-element-ii | Given an integer array of size `n`, find all elements that appear more than `⌊ n/3 ⌋` times.
**Example 1:**
**Input:** nums = \[3,2,3\]
**Output:** \[3\]
**Example 2:**
**Input:** nums = \[1\]
**Output:** \[1\]
**Example 3:**
**Input:** nums = \[1,2\]
**Output:** \[1,2\]
**Constraints:**
* `1 <= nums.length <... | How many majority elements could it possibly have?
Do you have a better hint? Suggest it! | Array,Hash Table,Sorting,Counting | Medium | 169,1102 |
8 | hi guys welcome to the channel before we dive into the question if you are new to the channel please consider subscribing the question says the function first discard as many as white space characters as necessary until the first known white space character is found then starting from this character takes an optional i... | String to Integer (atoi) | string-to-integer-atoi | Implement the `myAtoi(string s)` function, which converts a string to a 32-bit signed integer (similar to C/C++'s `atoi` function).
The algorithm for `myAtoi(string s)` is as follows:
1. Read in and ignore any leading whitespace.
2. Check if the next character (if not already at the end of the string) is `'-'` or `... | null | String | Medium | 7,65,2168 |
77 | Hello everyone, so today we are going to solve late code 77 problem name combination, so this problem is given under medium category in late code, okay and my request to you is that before solving this problem, you should follow the simple steps of recension plus back tracking. There are problems, either by revising th... | Combinations | combinations | Given two integers `n` and `k`, return _all possible combinations of_ `k` _numbers chosen from the range_ `[1, n]`.
You may return the answer in **any order**.
**Example 1:**
**Input:** n = 4, k = 2
**Output:** \[\[1,2\],\[1,3\],\[1,4\],\[2,3\],\[2,4\],\[3,4\]\]
**Explanation:** There are 4 choose 2 = 6 total combin... | null | Backtracking | Medium | 39,46 |
450 | hey everybody this is larry this is the last day of the august lego day challenge yay congratulations everybody uh yeah let me know what you think uh hit the like button the subscriber and join the discord and let's look at today's problem hopefully it's a fun one delete known as bst uh given a root no and a key delete... | Delete Node in a BST | delete-node-in-a-bst | Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return _the **root node reference** (possibly updated) of the BST_.
Basically, the deletion can be divided into two stages:
1. Search for a node to remove.
2. If the node is found, delete the node.
**Example 1:**
**Inpu... | null | Tree,Binary Search Tree,Binary Tree | Medium | 791 |
1,738 | hi everyone it's albert today let's solve the weekly contest median question find k's largest x or coordinate value 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 question t... | Find Kth Largest XOR Coordinate Value | maximal-network-rank | You are given a 2D `matrix` of size `m x n`, consisting of non-negative integers. You are also given an integer `k`.
The **value** of coordinate `(a, b)` of the matrix is the XOR of all `matrix[i][j]` where `0 <= i <= a < m` and `0 <= j <= b < n` **(0-indexed)**.
Find the `kth` largest value **(1-indexed)** of all th... | Try every pair of different cities and calculate its network rank. The network rank of two vertices is almost the sum of their degrees. How can you efficiently check if there is a road connecting two different cities? | Graph | Medium | null |
1,790 | Hello friends welcome to my channel let's have a look at problem 1790 check if one string swap can make strings equal this problem is essentially the same as problem 859 the body strength problems problem so here we'll first read through the problem statement to digest the problem requirement and then we compare with p... | Check if One String Swap Can Make Strings Equal | lowest-common-ancestor-of-a-binary-tree-iii | You are given two strings `s1` and `s2` of equal length. A **string swap** is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices.
Return `true` _if it is possible to make both strings equal by performing **at most one string swap** on **exactly on... | Store the path from p to the root. Traverse the path from q to the root, the first common point of the two paths is the LCA. | Hash Table,Tree,Binary Tree | Medium | 235,236,1780,1816 |
1,044 | hey everybody this is larry this is day 30th of the leeco daddy challenge hit the like button to subscribe and join me on discord let me know what you think about today's prom longest duplicate substring okay so that sounds kind of hard already um this is one of those problems that feels like it uh it's easy to state w... | Longest Duplicate Substring | find-common-characters | Given a string `s`, consider all _duplicated substrings_: (contiguous) substrings of s that occur 2 or more times. The occurrences may overlap.
Return **any** duplicated substring that has the longest possible length. If `s` does not have a duplicated substring, the answer is `" "`.
**Example 1:**
**Input:** s = "ba... | null | Array,Hash Table,String | Easy | 350 |
1,512 | okay so the description is given an array of integers nums a pair i js call good if nums of i equals number j so the values at those corresponding indexes equal each other and i's less than j return the number of good pairs so this is like an easy problem if you just brute force it but um there's a clever solution and ... | Number of Good Pairs | design-underground-system | Given an array of integers `nums`, return _the number of **good pairs**_.
A pair `(i, j)` is called _good_ if `nums[i] == nums[j]` and `i` < `j`.
**Example 1:**
**Input:** nums = \[1,2,3,1,1,3\]
**Output:** 4
**Explanation:** There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed.
**Example 2:**
**Input:** nu... | Use two hash tables. The first to save the check-in time for a customer and the second to update the total time between two stations. | Hash Table,String,Design | Medium | 2285 |
149 | you guys ready to tackle a brand new problem if you want to code along make sure to hit the link in the description below it's time to pop our daily dose of code max points on a line you're given an array arr in which each element corresponds to a 2d coordinate or a point that is a rfi is x i y i what is the maximum nu... | Max Points on a Line | max-points-on-a-line | Given an array of `points` where `points[i] = [xi, yi]` represents a point on the **X-Y** plane, return _the maximum number of points that lie on the same straight line_.
**Example 1:**
**Input:** points = \[\[1,1\],\[2,2\],\[3,3\]\]
**Output:** 3
**Example 2:**
**Input:** points = \[\[1,1\],\[3,2\],\[5,3\],\[4,1\]... | null | Array,Hash Table,Math,Geometry | Hard | 356,2287 |
149 | Hello friends today I'm going to solve liquid problem number 194 Max points on a line so in this problem we are given an area points where each value in the point array is an x and y coordinate of a point in X and Y plane and what we need to find is the maximum number of points in a line a straight line so here in this... | Max Points on a Line | max-points-on-a-line | Given an array of `points` where `points[i] = [xi, yi]` represents a point on the **X-Y** plane, return _the maximum number of points that lie on the same straight line_.
**Example 1:**
**Input:** points = \[\[1,1\],\[2,2\],\[3,3\]\]
**Output:** 3
**Example 2:**
**Input:** points = \[\[1,1\],\[3,2\],\[5,3\],\[4,1\]... | null | Array,Hash Table,Math,Geometry | Hard | 356,2287 |
1,473 | hello everyone welcome to learn overflow in this video we will discuss about today's late quote problem paint house three okay so this is the heart level problem and we'll understand what this question is trying to say how we can solve this question we'll also visualize this question based on all the example like uh ta... | Paint House III | find-the-longest-substring-containing-vowels-in-even-counts | There is a row of `m` houses in a small city, each house must be painted with one of the `n` colors (labeled from `1` to `n`), some houses that have been painted last summer should not be painted again.
A neighborhood is a maximal group of continuous houses that are painted with the same color.
* For example: `hous... | Represent the counts (odd or even) of vowels with a bitmask. Precompute the prefix xor for the bitmask of vowels and then get the longest valid substring. | Hash Table,String,Bit Manipulation,Prefix Sum | Medium | null |
1,748 | foreign problem and the problem's name is sum of unique elements in this question we are given our integer array called nums and we need to find the sum of unique elements inside that array so by definition a unique element is an element that appears exactly once inside the array it means the count of that element shou... | Sum of Unique Elements | best-team-with-no-conflicts | You are given an integer array `nums`. The unique elements of an array are the elements that appear **exactly once** in the array.
Return _the **sum** of all the unique elements of_ `nums`.
**Example 1:**
**Input:** nums = \[1,2,3,2\]
**Output:** 4
**Explanation:** The unique elements are \[1,3\], and the sum is 4.
... | First, sort players by age and break ties by their score. You can now consider the players from left to right. If you choose to include a player, you must only choose players with at least that score later on. | Array,Dynamic Programming,Sorting | Medium | null |
236 | now I have according interview question worst common ancestor that was recently asked by Twitter he were given a binary tree write a function lowest common ancestor LCA that takes the head of the given tree and to note eight and seven and this function should return one because the ancestor of the node 8 & 7 becaus... | Lowest Common Ancestor of a Binary Tree | lowest-common-ancestor-of-a-binary-tree | Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
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 both `p` and `q` as... | null | Tree,Depth-First Search,Binary Tree | Medium | 235,1190,1354,1780,1790,1816,2217 |
1,608 | all right guys welcome back to study plan binary search day seven the second problem for today last one so special ri with x elements greater than or equal to x you are given normal numbers of non-negative integers not as considerate non-negative integers not as considerate non-negative integers not as considerate spec... | Special Array With X Elements Greater Than or Equal X | calculate-salaries | You are given an array `nums` of non-negative integers. `nums` is considered **special** if there exists a number `x` such that there are **exactly** `x` numbers in `nums` that are **greater than or equal to** `x`.
Notice that `x` **does not** have to be an element in `nums`.
Return `x` _if the array is **special**, ... | null | Database | Medium | null |
1,704 | hi everyone welcome to my YouTube channel and I hope you guys had a wonderful weekend so in this video we will be looking at problem 1704 from the code here is the problem statement um this problem is easy and I think you guys should be okay solving this kind of problem um so actually on my first try I made a mistake b... | Determine if String Halves Are Alike | special-positions-in-a-binary-matrix | You are given a string `s` of even length. Split this string into two halves of equal lengths, and let `a` be the first half and `b` be the second half.
Two strings are **alike** if they have the same number of vowels (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`, `'A'`, `'E'`, `'I'`, `'O'`, `'U'`). Notice that `s` contains uppe... | Keep track of 1s in each row and in each column. Then while iterating over matrix, if the current position is 1 and current row as well as current column contains exactly one occurrence of 1. | Array,Matrix | Easy | null |
1,673 | hi guys how are you I hope all you are doing good welcome to the learn code easily today we will continue with the very stack series and today we will again solve the one more question and here we have solved the 40 plus questions here so if you are new to this Channel please like And subscribe and comment as well and ... | Find the Most Competitive Subsequence | find-the-most-competitive-subsequence | Given an integer array `nums` and a positive integer `k`, return _the most **competitive** subsequence of_ `nums` _of size_ `k`.
An array's subsequence is a resulting sequence obtained by erasing some (possibly zero) elements from the array.
We define that a subsequence `a` is more **competitive** than a subsequence ... | null | null | Medium | null |
94 | all right so let's take a look at this problem is called binary tree inorder traversal so generally for these types of problems you just need to be familiar with the different ways to traverse a binary tree and then once you get used to it should be pretty simple to traverse it in different ways so for n order it means... | 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 |
1,071 | Peace be upon you, my dear friend. How are you, Pasha? What are you doing? I hope you will be fine. God willing. Today we will explain together. If you have not solved the problem, of course you should go first and try it, and if you tried it and did not know it, then it is up to us to solve it together. You must give ... | Greatest Common Divisor of Strings | binary-prefix-divisible-by-5 | For two strings `s` and `t`, we say "`t` divides `s` " if and only if `s = t + ... + t` (i.e., `t` is concatenated with itself one or more times).
Given two strings `str1` and `str2`, return _the largest string_ `x` _such that_ `x` _divides both_ `str1` _and_ `str2`.
**Example 1:**
**Input:** str1 = "ABCABC ", str2... | If X is the first i digits of the array as a binary number, then 2X + A[i] is the first i+1 digits. | Array | Easy | null |
1,895 | hi everyone welcome back to lead coding i am your host faraz so i have decided to make detailed solutions to the lead code by weekly and weekly contest on each weekend so that you don't have to go anywhere else for the solutions so if you're new here make sure to subscribe to the channel and please leave like because i... | Largest Magic Square | minimum-number-of-operations-to-move-all-balls-to-each-box | A `k x k` **magic square** is a `k x k` grid filled with integers such that every row sum, every column sum, and both diagonal sums are **all equal**. The integers in the magic square **do not have to be distinct**. Every `1 x 1` grid is trivially a **magic square**.
Given an `m x n` integer `grid`, return _the **size... | If you want to move a ball from box i to box j, you'll need abs(i-j) moves. To move all balls to some box, you can move them one by one. For each box i, iterate on each ball in a box j, and add abs(i-j) to answers[i]. | Array,String | Medium | 1329 |
929 | uh hey everybody this is larry this is in day 27 of the september lego daily challenge hit the like button to subscribe and join me on discord let me know what you think about these problems so today i am in uh the what city of the beach city of puerto mao uh sullivan portugal so i am just hanging out uh let me know wh... | 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 |
1,920 | Do Handed over to Lakshman English Video Gyan Tree Another problem is this Zoom permission Subscribe button more Return Do Subscribe Bluetooth on Inch 340 DRR AF Subscribe to Quid Element Video subscribe our So let's see how to this problem should not give the Examiner wash 500 to 1000 subscribe half of it Jai Hind Sir... | Build Array from Permutation | determine-color-of-a-chessboard-square | Given a **zero-based permutation** `nums` (**0-indexed**), build an array `ans` of the **same length** where `ans[i] = nums[nums[i]]` for each `0 <= i < nums.length` and return it.
A **zero-based permutation** `nums` is an array of **distinct** integers from `0` to `nums.length - 1` (**inclusive**).
**Example 1:**
*... | Convert the coordinates to (x, y) - that is, "a1" is (1, 1), "d7" is (4, 7). Try add the numbers together and look for a pattern. | Math,String | Easy | null |
20 | welcome to lead codes blind created 75 where i'll be solving the top 75 lead code questions this problem is called valid parentheses and it's a standard problem you'll see given a string containing just the characters open parentheses close parentheses open squiggly bracket open bracket close bracket blah determine if ... | 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 |
121 | today we're looking at lead code number 121 it's a question called best time to buy and sell stock and so here we are given an array of prices where prices index i is the price of a given stock on the ith day and what we want to do is we want to maximize our profit by choosing a single day to buy one stock and choosing... | Best Time to Buy and Sell Stock | best-time-to-buy-and-sell-stock | You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day.
You want to maximize your profit by choosing a **single day** to buy one stock and choosing a **different day in the future** to sell that stock.
Return _the maximum profit you can achieve from this transaction_. If you ... | null | Array,Dynamic Programming | Easy | 53,122,123,188,309,2138,2144 |
934 | hey what's up guys chung here again so this time I want to talk about another lead called problem number 934 shortest bridge here so let's take a look you're given like a 2d binary array basically consists of either 0 or 1 and there are two islands in this 2d binary array here so an island is like it's connected which ... | Shortest Bridge | bitwise-ors-of-subarrays | You are given an `n x n` binary matrix `grid` where `1` represents land and `0` represents water.
An **island** is a 4-directionally connected group of `1`'s not connected to any other `1`'s. There are **exactly two islands** in `grid`.
You may change `0`'s to `1`'s to connect the two islands to form **one island**.
... | null | Array,Dynamic Programming,Bit Manipulation | Medium | null |
1,833 | Hello friends today I'm going to solve liquid problem number 1833 maximum ice cream bars in this problem we are given an area cost and an intensive value coins so the cost the value at each index I in the cost error represents the number of coins that is required by the ice cream and coins is the total number of coins ... | Maximum Ice Cream Bars | find-the-highest-altitude | It is a sweltering summer day, and a boy wants to buy some ice cream bars.
At the store, there are `n` ice cream bars. You are given an array `costs` of length `n`, where `costs[i]` is the price of the `ith` ice cream bar in coins. The boy initially has `coins` coins to spend, and he wants to buy as many ice cream bar... | Let's note that the altitude of an element is the sum of gains of all the elements behind it Getting the altitudes can be done by getting the prefix sum array of the given array | Array,Prefix Sum | Easy | null |
1,094 | Ki Kinnar Information Patna Interesting Problem Hai Main Ister Content Information About Item Number Passengers Patient Topic Hai Next 9 News 200 Shopping Radhe Maa The Work Of Bane Vishal A Main Harish Kumar Sauveer Shut down the hotspot till retrograde and Which was their poetry duplicate loot 9483 hotspot on that aa... | Car Pooling | matrix-cells-in-distance-order | There is a car with `capacity` empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west).
You are given the integer `capacity` and an array `trips` where `trips[i] = [numPassengersi, fromi, toi]` indicates that the `ith` trip has `numPassengersi` passengers and the locations to pick them u... | null | Array,Math,Geometry,Sorting,Matrix | Easy | 2304 |
528 | Hello hello everyone welcome to my channel today is the day 5mm problem is random pick distinction direct problem statements governor-general of weights which governor-general of weights which governor-general of weights which describes of the crescent index of your tips for example of baghwa yadav and the return of th... | Random Pick with Weight | swapping-nodes-in-a-linked-list | You are given a **0-indexed** array of positive integers `w` where `w[i]` describes the **weight** of the `ith` index.
You need to implement the function `pickIndex()`, which **randomly** picks an index in the range `[0, w.length - 1]` (**inclusive**) and returns it. The **probability** of picking an index `i` is `w[i... | We can transform the linked list to an array this should ease things up After transforming the linked list to an array it becomes as easy as swapping two integers in an array then rebuilding the linked list | Linked List,Two Pointers | Medium | 19,24,25 |
1,040 | hi everyone I'm Jack I'll be had a good night today let's look at this new question 10:40 I thought about these questions 10:40 I thought about these questions 10:40 I thought about these questions for a long time and obviously identify myself I read on me some other articles on the web and I finally figured out what i... | Moving Stones Until Consecutive II | maximum-binary-tree-ii | There are some stones in different positions on the X-axis. You are given an integer array `stones`, the positions of the stones.
Call a stone an **endpoint stone** if it has the smallest or largest position. In one move, you pick up an **endpoint stone** and move it to an unoccupied position so that it is no longer a... | null | Tree,Binary Tree | Medium | 654 |
1,438 | hello everyone in this video we are going to solve the problem longest can give a summary with absolute difference less than or equals to limit we are given an array of integers n an integer limit written the size of the longest contiguous array such that absolute difference between any two elements is less than or equ... | Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit | find-the-team-size | Given an array of integers `nums` and an integer `limit`, return the size of the longest **non-empty** subarray such that the absolute difference between any two elements of this subarray is less than or equal to `limit`_._
**Example 1:**
**Input:** nums = \[8,2,4,7\], limit = 4
**Output:** 2
**Explanation:** All su... | null | Database | Easy | null |
200 | hello and welcome back to the cracking fang youtube channel today we're going to be solving leap code problem 200 number of islands at the moment this is a really popular question with amazon microsoft bloomberg google and facebook so if you've got an upcoming on-site interview with any of upcoming on-site interview wi... | Number of Islands | number-of-islands | Given an `m x n` 2D binary grid `grid` which represents a map of `'1'`s (land) and `'0'`s (water), return _the number of islands_.
An **island** is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.
**Exampl... | null | Array,Depth-First Search,Breadth-First Search,Union Find,Matrix | Medium | 130,286,305,323,694,695,2035,2103 |
263 | today we're going to be working only at code question number 263 uh ugly number an ugly number is a positive integer whose prime factors are limited to 2 3 and 5. so we're going to be returning true on uh if n is an is a an ugly number so in this example number one uh n is equal to six uh we're going to be returning tr... | Ugly Number | ugly-number | An **ugly number** is a positive integer whose prime factors are limited to `2`, `3`, and `5`.
Given an integer `n`, return `true` _if_ `n` _is an **ugly number**_.
**Example 1:**
**Input:** n = 6
**Output:** true
**Explanation:** 6 = 2 \* 3
**Example 2:**
**Input:** n = 1
**Output:** true
**Explanation:** 1 has n... | null | Math | Easy | 202,204,264 |
73 | welcome to august leeco challenge today's problem is set matrix zeros given an m times n integer matrix if an element is zero set its entire row and column to zeros and return the matrix you must do it in place so that's kind of big because we can't generate a new temporary or can't generate a new matrix and then retur... | Set Matrix Zeroes | set-matrix-zeroes | Given an `m x n` integer matrix `matrix`, if an element is `0`, set its entire row and column to `0`'s.
You must do it [in place](https://en.wikipedia.org/wiki/In-place_algorithm).
**Example 1:**
**Input:** matrix = \[\[1,1,1\],\[1,0,1\],\[1,1,1\]\]
**Output:** \[\[1,0,1\],\[0,0,0\],\[1,0,1\]\]
**Example 2:**
**In... | If any cell of the matrix has a zero we can record its row and column number using additional memory.
But if you don't want to use extra memory then you can manipulate the array instead. i.e. simulating exactly what the question says. Setting cell values to zero on the fly while iterating might lead to discrepancies. ... | Array,Hash Table,Matrix | Medium | 289,2244,2259,2314 |
116 | hey guys so i'm trying out this problem populating next right pointers in each node okay let's have a read we're given a perfect binary tree it all leaves on the same level and every parent has two children the binary tree the following definition find it as a left it is the right it is the next what is next operate ea... | 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 |
920 | um hello so today we are going to do this problem which is part of Fleet code daily challenge number of music playlists um so we have in different songs and we want to listen to gold songs so this is basically the number of songs in our in a playlist um so you can think of your playlist with tracks like this and this i... | Number of Music Playlists | uncommon-words-from-two-sentences | Your music player contains `n` different songs. You want to listen to `goal` songs (not necessarily different) during your trip. To avoid boredom, you will create a playlist so that:
* Every song is played **at least once**.
* A song can only be played again only if `k` other songs have been played.
Given `n`, `g... | null | Hash Table,String | Easy | 2190 |
863 | hello guys welcome back to take those and in this video we will see the problem of finding all nodes present at distance K in a binary tree so this is from lead code number 863 and we will see all the follow-up problems once we see all the follow-up problems once we see all the follow-up problems once we are done discu... | 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,730 | hello everyone let's solve legal question one seven three zero short is the path to get food and it's a median legal question you are starving and you want to get food quickly as possible you want to find the shortest path to arrive at any food or cell you're giving m multiplex and character matrix grid of different ty... | Shortest Path to Get Food | special-array-with-x-elements-greater-than-or-equal-x | You are starving and you want to eat food as quickly as possible. You want to find the shortest path to arrive at any food cell.
You are given an `m x n` character matrix, `grid`, of these different types of cells:
* `'*'` is your location. There is **exactly one** `'*'` cell.
* `'#'` is a food cell. There may be... | Count the number of elements greater than or equal to x for each x in the range [0, nums.length]. If for any x, the condition satisfies, return that x. Otherwise, there is no answer. | Array,Binary Search,Sorting | Easy | null |
503 | Hello friends, in this video we are going to solve this problem with the next greater element, I will tell you in such a better way that even if you want to forget, you will not be able to forget, so please watch the video till the end, I guarantee you this. I assure you that if you watch the entire video then you will... | Next Greater Element II | next-greater-element-ii | Given a circular integer array `nums` (i.e., the next element of `nums[nums.length - 1]` is `nums[0]`), return _the **next greater number** for every element in_ `nums`.
The **next greater number** of a number `x` is the first greater number to its traversing-order next in the array, which means you could search circu... | null | Array,Stack,Monotonic Stack | Medium | 496,556 |
35 | in this video we'll be going over a search insert position so given a sorted array of distinct integers and a target value return the index if the target is found if not return the index where it would be if it were inserted in order so in our first example we have one three five and six and our target is equal to five... | Search Insert Position | search-insert-position | Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
You must write an algorithm with `O(log n)` runtime complexity.
**Example 1:**
**Input:** nums = \[1,3,5,6\], target = 5
**Output:** 2
**Exa... | null | Array,Binary Search | Easy | 278 |
1,358 | Hello Everyone And Welcome Back To My Channel Algorithm HQ Today I Am Going To Write The Code And Also Explain You All The Algorithm To Solve This Number Of Sub Strings Containing All Three Characters Problem Which Is There In Lead Code Again It Is A Part Of Also like the video and also subscribe to My channel if you h... | 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 |
1,319 | hello so continuing on this little code weekly contest 7171 so the third problem was number of operations to make Network connected so what the problem says is we have in computers numbered from 0 to n minus 1 and they are connected by some Ethernet cables connections forming a network where the connection when you whe... | 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 |
528 | uh let's talk about the random peak with weight so you are given a in array and then the inner rate uh is going to be what uh you want to find out the probability for every single index so uh let me do the drawing so the calculation is this w i over some y that's some w right so the sum is x equal to y uh in this case ... | Random Pick with Weight | swapping-nodes-in-a-linked-list | You are given a **0-indexed** array of positive integers `w` where `w[i]` describes the **weight** of the `ith` index.
You need to implement the function `pickIndex()`, which **randomly** picks an index in the range `[0, w.length - 1]` (**inclusive**) and returns it. The **probability** of picking an index `i` is `w[i... | We can transform the linked list to an array this should ease things up After transforming the linked list to an array it becomes as easy as swapping two integers in an array then rebuilding the linked list | Linked List,Two Pointers | Medium | 19,24,25 |
140 | hello friends today that's the word break 2 problem given string s and the dictionary of strings will dict add spaces in f to construct a sentence where each word is a valid dictionary word return all such possible sentences in any order this problem is different from 139 because that problem only asks us whether it ca... | Word Break II | word-break-ii | Given a string `s` and a dictionary of strings `wordDict`, add spaces in `s` to construct a sentence where each word is a valid dictionary word. Return all such possible sentences in **any order**.
**Note** that the same word in the dictionary may be reused multiple times in the segmentation.
**Example 1:**
**Input:... | null | Hash Table,String,Dynamic Programming,Backtracking,Trie,Memoization | Hard | 139,472 |
215 | Hello everyone welcome to my channel but this is going to be a very easy question, we will make it from multiple approaches, we are ok aa khet largest element in and hey ok main by Microsoft question is very simple, you are waiting for the number and one. The interior of the name has been given, you have to remove the ... | 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 |
143 | foreign hi this is Topher with the lonely Dash and today we're going over leap code number 143 reorder list which states you are given the head of a singly linked list the list can be represented as list 0 list 1 all the way through list of n reorder the list to be in the following form list zero list n list one list n... | Reorder List | reorder-list | You are given the head of a singly linked-list. The list can be represented as:
L0 -> L1 -> ... -> Ln - 1 -> Ln
_Reorder the list to be on the following form:_
L0 -> Ln -> L1 -> Ln - 1 -> L2 -> Ln - 2 -> ...
You may not modify the values in the list's nodes. Only nodes themselves may be changed.
**Example 1:**
**... | null | Linked List,Two Pointers,Stack,Recursion | Medium | 2216 |
470 | Hello, let's start because this is very interesting, and I think even if you are a non-rotating hormone, even if you are a non-rotating hormone, even if you are a non-rotating hormone, you have to take time, that is, very cute chords in English, it is nominal in mathematics, so this question is increment sentence funct... | Implement Rand10() Using Rand7() | implement-rand10-using-rand7 | Given the **API** `rand7()` that generates a uniform random integer in the range `[1, 7]`, write a function `rand10()` that generates a uniform random integer in the range `[1, 10]`. You can only call the API `rand7()`, and you shouldn't call any other API. Please **do not** use a language's built-in random API.
Each ... | null | null | Medium | null |
1,584 | hey what is up guys we're back with another decode video today we're going to be doing 1584 minimum cost connect all points so you're given an array points representing an integer coordinates of some points on a 2d plane reports i is equal to xy okay so just an array of points the cost of connecting two points is the m... | Min Cost to Connect All Points | average-salary-excluding-the-minimum-and-maximum-salary | You are given an array `points` representing integer coordinates of some points on a 2D-plane, where `points[i] = [xi, yi]`.
The cost of connecting two points `[xi, yi]` and `[xj, yj]` is the **manhattan distance** between them: `|xi - xj| + |yi - yj|`, where `|val|` denotes the absolute value of `val`.
Return _the m... | Get the total sum and subtract the minimum and maximum value in the array. Finally divide the result by n - 2. | Array,Sorting | Easy | null |
532 | hey everybody this is larry this is day three of the leeco daily challenge for october uh hit the like button to subscribe and join me on discord let me know what you think about today's farm and today's forum is k diff paris in and away so i'm solving this live let me know if it goes wrong or whatever uh let me know h... | K-diff Pairs in an Array | k-diff-pairs-in-an-array | Given an array of integers `nums` and an integer `k`, return _the number of **unique** k-diff pairs in the array_.
A **k-diff** pair is an integer pair `(nums[i], nums[j])`, where the following are true:
* `0 <= i, j < nums.length`
* `i != j`
* `nums[i] - nums[j] == k`
**Notice** that `|val|` denotes the absol... | null | Array,Hash Table,Two Pointers,Binary Search,Sorting | Medium | 530,2116,2150 |
449 | hello guys welcome to my youtube channel all right hey so today i have come up with a very interesting problem uh it's a medium level problem but uh it can get confusing and i want to do it like a two video kind of series so i'm gonna do uh so this is like this one is like serialized dc live bst and then another one i ... | Serialize and Deserialize BST | serialize-and-deserialize-bst | Serialization is converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment.
Design an algorithm to serialize and deserialize a **binary search t... | null | String,Tree,Depth-First Search,Breadth-First Search,Design,Binary Search Tree,Binary Tree | Medium | 297,652,765 |
1,065 | hi so this question is index pairs of a string so you're giving the string text and a real string words so you are going to just find out if there is a word in the text and if you do then you just find out the index from the beginning to the end so for the story uh this list is going to be the story right so three seve... | Index Pairs of a String | binary-string-with-substrings-representing-1-to-n | Given a string `text` and an array of strings `words`, return _an array of all index pairs_ `[i, j]` _so that the substring_ `text[i...j]` _is in `words`_.
Return the pairs `[i, j]` in sorted order (i.e., sort them by their first coordinate, and in case of ties sort them by their second coordinate).
**Example 1:**
*... | We only need to check substrings of length at most 30, because 10^9 has 30 bits. | String | Medium | null |
1,022 | okay cool 10:22 summer boot to leave okay cool 10:22 summer boot to leave okay cool 10:22 summer boot to leave binary numbers come in a binary tree each node has value zero one each boot to leave path we represent a binary number starting with the most significant bit for example the power 0 1 then this could represent... | Sum of Root To Leaf Binary Numbers | unique-paths-iii | You are given the `root` of a binary tree where each node has a value `0` or `1`. Each root-to-leaf path represents a binary number starting with the most significant bit.
* For example, if the path is `0 -> 1 -> 1 -> 0 -> 1`, then this could represent `01101` in binary, which is `13`.
For all leaves in the tree, c... | null | Array,Backtracking,Bit Manipulation,Matrix | Hard | 37,63,212 |
1,679 | daily lead code challenge so today's question is maximum number of k sum pairs okay so you are given an integer error nums and an integer k in one operation you can pick two numbers from the array whose sum equals to the key and remove them from the array return the maximum number of operations you can perform on the a... | Max Number of K-Sum Pairs | shortest-subarray-to-be-removed-to-make-array-sorted | You are given an integer array `nums` and an integer `k`.
In one operation, you can pick two numbers from the array whose sum equals `k` and remove them from the array.
Return _the maximum number of operations you can perform on the array_.
**Example 1:**
**Input:** nums = \[1,2,3,4\], k = 5
**Output:** 2
**Explana... | The key is to find the longest non-decreasing subarray starting with the first element or ending with the last element, respectively. After removing some subarray, the result is the concatenation of a sorted prefix and a sorted suffix, where the last element of the prefix is smaller than the first element of the suffix... | Array,Two Pointers,Binary Search,Stack,Monotonic Stack | Medium | null |
67 | hey everybody today we're solving lead code 67 which is called ad binary the question asks given two binary strings A and B return their sum as a binary string we'll go over a couple of different ways to solve this today and we'll go ahead and get started with method one our binary strings are A and B respectively of 1... | Add Binary | add-binary | Given two binary strings `a` and `b`, return _their sum as a binary string_.
**Example 1:**
**Input:** a = "11", b = "1"
**Output:** "100"
**Example 2:**
**Input:** a = "1010", b = "1011"
**Output:** "10101"
**Constraints:**
* `1 <= a.length, b.length <= 104`
* `a` and `b` consist only of `'0'` or `'1'` chara... | null | Math,String,Bit Manipulation,Simulation | Easy | 2,43,66,1031 |
1,601 | hey everyone welcome back today we are going to solve problem number 1601 maximum number of achievable transfer requests first we will see the explanation of the problem statement in the logic on the core now let's dive into the solution so in this problem we have a request input so these are the request from the emplo... | Maximum Number of Achievable Transfer Requests | maximum-number-of-achievable-transfer-requests | We have `n` buildings numbered from `0` to `n - 1`. Each building has a number of employees. It's transfer season, and some employees want to change the building they reside in.
You are given an array `requests` where `requests[i] = [fromi, toi]` represents an employee's request to transfer from building `fromi` to bu... | null | null | Hard | null |
201 | hello guys welcome back to my YouTube channel today I'm going to solve day 21 problem of this month only Cod if you guys haven't subscribed my YouTube channel yet then please go ahead and subscribe it now without any delay Let's uh start with our today's problem so in this problem we have given two integers left and ri... | Bitwise AND of Numbers Range | bitwise-and-of-numbers-range | Given two integers `left` and `right` that represent the range `[left, right]`, return _the bitwise AND of all numbers in this range, inclusive_.
**Example 1:**
**Input:** left = 5, right = 7
**Output:** 4
**Example 2:**
**Input:** left = 0, right = 0
**Output:** 0
**Example 3:**
**Input:** left = 1, right = 2147... | null | Bit Manipulation | Medium | null |
1,041 | hello everyone I'm Jack today let's take a look at this new problem 10:41 we're about bounded in a circle 10:41 we're about bounded in a circle 10:41 we're about bounded in a circle well it is actually marked as easy but I took some time to figure it by myself without looking at other materials so it should be easy uh ... | 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 |
138 | hey everybody this is Larry this is day five of the leg go Del challenge H the like button the Subscribe but Jo me on Discord let me know what you think about today's PR 138 copy list with random pointer let's check real quick ah check real quick because I uh on the upper left there's an unbox surprise you click on it ... | Copy List with Random Pointer | copy-list-with-random-pointer | A linked list of length `n` is given such that each node contains an additional random pointer, which could point to any node in the list, or `null`.
Construct a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) of the list. The deep copy should consist of exactly `n` **brand new** nodes, where e... | Just iterate the linked list and create copies of the nodes on the go. Since a node can be referenced from multiple nodes due to the random pointers, make sure you are not making multiple copies of the same node. You may want to use extra space to keep old node ---> new node mapping to prevent creating multiples copies... | Hash Table,Linked List | Medium | 133,1624,1634 |
7 | Hello Everyone, our question today is Reverse Integer, it is a very easy question, like first of all we understand what is given to us in it and what we have to do, so first of all we feel from its name that whatever we have to do. We must have given an integer and we have to reverse it. Now inside this we have to reve... | 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,913 | Hi friends welcome back to another video and in this we will see the maximum product difference between two pairs so this is an easy level problem so let us understand directly from the example and then if we do it then basically we have to select four numbers or you can say two pairs. Suppose the first pair is of A &a... | Maximum Product Difference Between Two Pairs | make-the-xor-of-all-segments-equal-to-zero | The **product difference** between two pairs `(a, b)` and `(c, d)` is defined as `(a * b) - (c * d)`.
* For example, the product difference between `(5, 6)` and `(2, 7)` is `(5 * 6) - (2 * 7) = 16`.
Given an integer array `nums`, choose four **distinct** indices `w`, `x`, `y`, and `z` such that the **product differ... | Let's note that for the XOR of all segments with size K to be equal to zeros, nums[i] has to be equal to nums[i+k] Basically, we need to make the first K elements have XOR = 0 and then modify them. | Array,Dynamic Programming,Bit Manipulation | Hard | null |
141 | hello everyone welcome or welcome back to my channel so today we are going to discuss another problem but before going forward if you have not liked the video please like it subscribe to my channel and hit the bell icon so that you get notified whenever i post a new video so without any further ado let's get started pr... | Linked List Cycle | linked-list-cycle | Given `head`, the head of a linked list, determine if the linked list has a cycle in it.
There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the `next` pointer. Internally, `pos` is used to denote the index of the node that tail's `next` pointer is co... | null | Hash Table,Linked List,Two Pointers | Easy | 142,202 |
113 | foreign daily problem part sum so in this question what the question is asking is we are given a buying treatment right we are given the binary tree and in that binary tree we have to find the path from root to the leaf node so we have to find the path from the root to the leaf node whose node values which sum up to th... | 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 |
110 | what is up youtube today we are going to be going over by balanced binary tree it's an easy problem on the code i know i said i wasn't going to do easy but um this one can be kind of tricky um because you're using recursion i know a lot of people don't find recursion easily and i'm definitely not the best with trees so... | Balanced Binary Tree | balanced-binary-tree | Given a binary tree, determine if it is **height-balanced**.
**Example 1:**
**Input:** root = \[3,9,20,null,null,15,7\]
**Output:** true
**Example 2:**
**Input:** root = \[1,2,2,3,3,null,null,4,4\]
**Output:** false
**Example 3:**
**Input:** root = \[\]
**Output:** true
**Constraints:**
* The number of nodes ... | null | Tree,Depth-First Search,Binary Tree | Easy | 104 |
974 | um hello so today we are going to do this problem which is part of Fleet code daily challenge January Dairy challenge um Subaru is some divisible by K so we get basically an array and we get um an integer K and we want to return the number of non-empty sub to return the number of non-empty sub to return the number of n... | Subarray Sums Divisible by K | reorder-data-in-log-files | Given an integer array `nums` and an integer `k`, return _the number of non-empty **subarrays** that have a sum divisible by_ `k`.
A **subarray** is a **contiguous** part of an array.
**Example 1:**
**Input:** nums = \[4,5,0,-2,-3,1\], k = 5
**Output:** 7
**Explanation:** There are 7 subarrays with a sum divisible b... | null | Array,String,Sorting | Easy | null |
1,961 | foreign and today we guys are going to solve a new lead code question that is check if a string is a prefix of array so let's read out the question C is given a string s and an array of string words determine whether s is a prefix string of words our string as a prefix string of Words If s can be made by concatenating ... | Check If String Is a Prefix of Array | maximum-ice-cream-bars | Given a string `s` and an array of strings `words`, determine whether `s` is a **prefix string** of `words`.
A string `s` is a **prefix string** of `words` if `s` can be made by concatenating the first `k` strings in `words` for some **positive** `k` no larger than `words.length`.
Return `true` _if_ `s` _is a **prefi... | It is always optimal to buy the least expensive ice cream bar first. Sort the prices so that the cheapest ice cream bar comes first. | Array,Greedy,Sorting | Medium | null |
735 | Integers representing steroids in n road ok and this test salut value represent with size absolute value you know without any sign and d sign represent its direction ok positive mens right direction negative mens left direction basically moving forward and moving backward these two options You have h moves aate di se s... | Asteroid Collision | asteroid-collision | We are given an array `asteroids` of integers representing asteroids in a row.
For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed.
Find out the state of the asteroids after all collisio... | Say a row of asteroids is stable. What happens when a new asteroid is added on the right? | Array,Stack | Medium | 605,2245,2317 |
328 | all right so let's talk about all your linked lists so you are given a link list and then you just have to swap the order so if the number comes for the node you just have to connect together even count of the node you just can't activate it and then at the end uh at the end of the all number comes from the linked list... | 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 |
529 | hello everyone today we are gonna talk about um problem 529 my sweeper so uh this one is kind of um can be done both in dfs and the bfs but i today i'm gonna talk about the bfs solution so you are given basically a charm a matrix char matrix which is a board so if you have played a minesweeper um when you are a kid so ... | Minesweeper | minesweeper | Let's play the minesweeper game ([Wikipedia](https://en.wikipedia.org/wiki/Minesweeper_(video_game)), [online game](http://minesweeperonline.com))!
You are given an `m x n` char matrix `board` representing the game board where:
* `'M'` represents an unrevealed mine,
* `'E'` represents an unrevealed empty square,
... | null | Array,Depth-First Search,Breadth-First Search,Matrix | Medium | 2206 |
1,561 | Hello everyone welcome to my channel Quote Sorry with Mike So today we are going to do video number 23 of our Grady playlist today's question is going to be very easy lead code number is 1561 maximum number of coins you can get okay and let's watch the question is quite easy It is simple, it says that three times a pil... | Maximum Number of Coins You Can Get | rearrange-words-in-a-sentence | There are `3n` piles of coins of varying size, you and your friends will take piles of coins as follows:
* In each step, you will choose **any** `3` piles of coins (not necessarily consecutive).
* Of your choice, Alice will pick the pile with the maximum number of coins.
* You will pick the next pile with the ma... | Store each word and their relative position. Then, sort them by length of words in case of tie by their original order. | String,Sorting | Medium | null |
394 | string encoding and decoding are widely used in encryption problems well sometimes they make up good programming problems as well i am talking about the problem decode string on lead code a big hint to solve this problem is to use the stack data structure let us see how we can go about doing that hello friends welcome ... | 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 |
518 | hello guys welcome to our test learnings today we are going to locate the problem number of 518 which is a coin change - number of 518 which is a coin change - number of 518 which is a coin change - there are two types of problems in the coin change so this is the second one okay so you're given a you're given differen... | Coin Change II | coin-change-2 | You are given an integer array `coins` representing coins of different denominations and an integer `amount` representing a total amount of money.
Return _the number of combinations that make up that amount_. If that amount of money cannot be made up by any combination of the coins, return `0`.
You may assume that yo... | null | Array,Dynamic Programming | Medium | 1393 |
6 | in this video we'll be going over zig-zag conversion so the string zig-zag conversion so the string zig-zag conversion so the string is written in a zigzag pattern on a given number of rows so in this case we're given three rows and then we are trying to write this string into a zigzag pattern so we have p a y and a p ... | 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 |
237 | hey everybody this is Larry this is day two of the June decode daily challenge hope everyone's thinks safe hope everyone's staying healthy and you know make sure you find a place to love someone in your life let's get to prom - someone in your life let's get to prom - someone in your life let's get to prom - delete nod... | Delete Node in a Linked List | delete-node-in-a-linked-list | There is a singly-linked list `head` and we want to delete a node `node` in it.
You are given the node to be deleted `node`. You will **not be given access** to the first node of `head`.
All the values of the linked list are **unique**, and it is guaranteed that the given node `node` is not the last node in the linke... | null | Linked List | Easy | 203 |
1,710 | Hello Everyone Welcome back to my channel I am going to discuss the next problem in which the problem is maximum units and ginger ok so what we have to do in this problem is boxing and in this we have a particular type of boxes on the index. How many numbers are given and can be put in that type of box and it is of tha... | Maximum Units on a Truck | find-servers-that-handled-most-number-of-requests | You are assigned to put some amount of boxes onto **one truck**. You are given a 2D array `boxTypes`, where `boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]`:
* `numberOfBoxesi` is the number of boxes of type `i`.
* `numberOfUnitsPerBoxi` is the number of units in each box of the type `i`.
You are also given... | To speed up the next available server search, keep track of the available servers in a sorted structure such as an ordered set. To determine if a server is available, keep track of the end times for each task in a heap and add the server to the available set once the soonest task ending time is less than or equal to th... | Array,Greedy,Heap (Priority Queue),Ordered Set | Hard | null |
147 | hey everyone welcome back and today we'll be doing another lead code problem 147 insertion short list this is a medium one given the head of the single linked list we just have to perform an insertion sort to it and sort the list in a sending order and then return the head so that's straightforward so we will be having... | Insertion Sort List | insertion-sort-list | Given the `head` of a singly linked list, sort the list using **insertion sort**, and return _the sorted list's head_.
The steps of the **insertion sort** algorithm:
1. Insertion sort iterates, consuming one input element each repetition and growing a sorted output list.
2. At each iteration, insertion sort removes... | null | Linked List,Sorting | Medium | 148,850 |
111 | hey everyone today we will be doing another lead for one minimum depth of the binary tree easy problem this is uh we have already done the maximum depth of the binary tree uh this is much easier than that was a bit complicated but in this problem given a binary tree find its minimum depth the minimum depth is the numbe... | Minimum Depth of Binary Tree | minimum-depth-of-binary-tree | Given a binary tree, find its minimum depth.
The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.
**Note:** A leaf is a node with no children.
**Example 1:**
**Input:** root = \[3,9,20,null,null,15,7\]
**Output:** 2
**Example 2:**
**Input:** root = \[2... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Easy | 102,104 |
412 | how's it going guys so today we're going to solve the one of the coolest question this question deserves like this is the easiest question so if you did not able to solve then don't worry i'm over here to help you guys to solve this question okay so what we're going to do in this question so basically uh we have given ... | Fizz Buzz | fizz-buzz | Given an integer `n`, return _a string array_ `answer` _(**1-indexed**) where_:
* `answer[i] == "FizzBuzz "` if `i` is divisible by `3` and `5`.
* `answer[i] == "Fizz "` if `i` is divisible by `3`.
* `answer[i] == "Buzz "` if `i` is divisible by `5`.
* `answer[i] == i` (as a string) if none of the above condit... | null | Math,String,Simulation | Easy | 1316 |
93 | hey guys next is a third Bob Bradley code restoring IP address given a string can't anyone reading it we sorted by returning all possible valid IP and gas companies for example given two by two five one two five we have two ways of people dancing days as a nice idea so we follow the brim and do it similar do you know e... | Restore IP Addresses | restore-ip-addresses | A **valid IP address** consists of exactly four integers separated by single dots. Each integer is between `0` and `255` (**inclusive**) and cannot have leading zeros.
* For example, `"0.1.2.201 "` and `"192.168.1.1 "` are **valid** IP addresses, but `"0.011.255.245 "`, `"192.168.1.312 "` and `"192.168@1.1 "` are **... | null | String,Backtracking | Medium | 752 |
54 | hi guys in this video i'm going to go through this league on problem 54 so we are given a matrix we need to return all the elements of the matrix in the spiral order so um this example has a quick illustration so we go from the top left and then when we hit the wall in the change direction when we hit the wall again ch... | Spiral Matrix | spiral-matrix | Given an `m x n` `matrix`, return _all elements of the_ `matrix` _in spiral order_.
**Example 1:**
**Input:** matrix = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\]
**Output:** \[1,2,3,6,9,8,7,4,5\]
**Example 2:**
**Input:** matrix = \[\[1,2,3,4\],\[5,6,7,8\],\[9,10,11,12\]\]
**Output:** \[1,2,3,4,8,12,11,10,9,5,6,7\]
**Const... | Well for some problems, the best way really is to come up with some algorithms for simulation. Basically, you need to simulate what the problem asks us to do. We go boundary by boundary and move inwards. That is the essential operation. First row, last column, last row, first column and then we move inwards by 1 and th... | Array,Matrix,Simulation | Medium | 59,921 |
1,710 | hello everyone today we'll solve one of the lead for problem uh where it says uh you are assigned to put some amount of boxes onto the truck uh and you are given a 2d area so this is the 2d array that is given and truck size is four so output should be eight why because uh as the formula uh one box of the first type th... | Maximum Units on a Truck | find-servers-that-handled-most-number-of-requests | You are assigned to put some amount of boxes onto **one truck**. You are given a 2D array `boxTypes`, where `boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]`:
* `numberOfBoxesi` is the number of boxes of type `i`.
* `numberOfUnitsPerBoxi` is the number of units in each box of the type `i`.
You are also given... | To speed up the next available server search, keep track of the available servers in a sorted structure such as an ordered set. To determine if a server is available, keep track of the end times for each task in a heap and add the server to the available set once the soonest task ending time is less than or equal to th... | Array,Greedy,Heap (Priority Queue),Ordered Set | Hard | null |
342 | Told the doctor to tell the next problem, this whole saree with video subscribe my YouTube channel and share with coat pant comes before Akshaydeep and 10 back blouse number respond 100 subscribe The Subscribe Seervi Subscribe Blue and Influence Over react check veeravati kuru effects on 10th result subscribe to hua th... | Power of Four | power-of-four | Given an integer `n`, return _`true` if it is a power of four. Otherwise, return `false`_.
An integer `n` is a power of four, if there exists an integer `x` such that `n == 4x`.
**Example 1:**
**Input:** n = 16
**Output:** true
**Example 2:**
**Input:** n = 5
**Output:** false
**Example 3:**
**Input:** n = 1
**O... | null | Math,Bit Manipulation,Recursion | Easy | 231,326 |
219 | hello everyone so in this video let us talk about a problem from lead code it's an easy problem the problem name is contain duplicates part two so the problem statement goes like this that you're given an integer array nums and as well as an integer k return true if there are two distinct indexes i and j inside the arr... | Contains Duplicate II | contains-duplicate-ii | Given an integer array `nums` and an integer `k`, return `true` _if there are two **distinct indices**_ `i` _and_ `j` _in the array such that_ `nums[i] == nums[j]` _and_ `abs(i - j) <= k`.
**Example 1:**
**Input:** nums = \[1,2,3,1\], k = 3
**Output:** true
**Example 2:**
**Input:** nums = \[1,0,1,1\], k = 1
**Outp... | null | Array,Hash Table,Sliding Window | Easy | 217,220 |
81 | Hello hello everyone and welcome back to channel suggestion baikunthpur discus andar important to problem the cutter label kiss problems medium act to problem his approach in routine spotted the ring to this problem is upon by research that china 20 seconds thereby 153 to 9 point research airport children Comment for y... | 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 |
134 | okay so let's continue with our coding exercise so open the and go to exercise so open the and go to exercise so open the and go to the problems tab and if you scroll down the search question number 134 and as an as soon as you hit enter you will find this question that is gas station let's come under the medium catego... | 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 |
907 | hello everyone let's try to be a cheat code ninja today even though this is categorized as a medium problem I consider this to be more challenging than that let's look at it we are given an array and for every contiguous sub array we have to find the minimum and then we have to sum the minimum of 8 sub array at the end... | 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 |
518 | hello everyone this is mustafa from zakocho and today we have another lit good problem this is one of the classics of dynamic programming what we have here is we have the problem itself is about you have like amount of coin or amount of money and you need to find how many ways you can make up this amount of money and y... | Coin Change II | coin-change-2 | You are given an integer array `coins` representing coins of different denominations and an integer `amount` representing a total amount of money.
Return _the number of combinations that make up that amount_. If that amount of money cannot be made up by any combination of the coins, return `0`.
You may assume that yo... | null | Array,Dynamic Programming | Medium | 1393 |
1,380 | welcome guys welcome to my legal solving session uh so this problem is called the lucky number in the matrix okay so i'll give an entire matrix and written all the non-key numbers written all the non-key numbers written all the non-key numbers okay so the logic numbers is what is element of elementary such as minimum a... | Lucky Numbers in a Matrix | number-of-closed-islands | Given an `m x n` matrix of **distinct** numbers, return _all **lucky numbers** in the matrix in **any** order_.
A **lucky number** is an element of the matrix such that it is the minimum element in its row and maximum in its column.
**Example 1:**
**Input:** matrix = \[\[3,7,8\],\[9,11,13\],\[15,16,17\]\]
**Output:*... | Exclude connected group of 0s on the corners because they are not closed island. Return number of connected component of 0s on the grid. | Array,Depth-First Search,Breadth-First Search,Union Find,Matrix | Medium | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.