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,676 | hello everyone let's solve this nickel problem lowest common ancestor of a binary fort today so many similar problems for example on 236 16451 fifty so there are always common ancestor entry one two and three so if you haven't practiced those problems you can practice some force since they are very similar questions ok... | Lowest Common Ancestor of a Binary Tree IV | minimum-number-of-days-to-eat-n-oranges | Given the `root` of a binary tree and an array of `TreeNode` objects `nodes`, return _the lowest common ancestor (LCA) of **all the nodes** in_ `nodes`. All the nodes will exist in the tree, and all values of the tree's nodes are **unique**.
Extending the **[definition of LCA on Wikipedia](https://en.wikipedia.org/wik... | In each step, choose between 2 options:
minOranges = 1 + min( (n%2) + f(n/2), (n%3) + f(n/3) )
where f(n) is the minimum number of days to eat n oranges. | Dynamic Programming,Memoization | Hard | null |
858 | okay so uh need code practice time so in this video there are two goals the first goal is to see how we should solve this problem we find the solution and then we are going to put some code there and the second goal is to see how it should behave in a real interview so let's get started remember in the first step in th... | Mirror Reflection | masking-personal-information | There is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of the remaining corners, numbered `0`, `1`, and `2`.
The square room has walls of length `p` and a laser ray from the southwest corner first meets the east wall at a distance `q` from th... | null | String | Medium | null |
146 | day 24 lru cash it's one of the most important questions and it's asked very frequently in many programming interviews so let's see how we will implement it first let's understand the lead code problem which is problem number 146. in general the api that the client wants for is to access the keys they may not necessari... | LRU Cache | lru-cache | Design a data structure that follows the constraints of a **[Least Recently Used (LRU) cache](https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU)**.
Implement the `LRUCache` class:
* `LRUCache(int capacity)` Initialize the LRU cache with **positive** size `capacity`.
* `int get(int key)` Return the valu... | null | Hash Table,Linked List,Design,Doubly-Linked List | Medium | 460,588,604,1903 |
790 | Hello Everyone and Welcome End Limited Tiles You will get some more space, here its length will be told to you that let's man do, there are ways by which you can fill this space with these dialogues like now here's the length The length here is three, so here I have to place one tile, so I can do it like this, you are ... | Domino and Tromino Tiling | global-and-local-inversions | You have two types of tiles: a `2 x 1` domino shape and a tromino shape. You may rotate these shapes.
Given an integer n, return _the number of ways to tile an_ `2 x n` _board_. Since the answer may be very large, return it **modulo** `109 + 7`.
In a tiling, every square must be covered by a tile. Two tilings are dif... | Where can the 0 be placed in an ideal permutation? What about the 1? | Array,Math | Medium | null |
969 | hey guys welcome back to another video and today we're going to be solving the leeco question pancake sorting all right so in this question we're given an area a with integers and we need to sort it so the way we're going to sort it is by using something called they call pancake flips and in one flip what we need to do... | Pancake Sorting | number-of-recent-calls | Given an array of integers `arr`, sort the array by performing a series of **pancake flips**.
In one pancake flip we do the following steps:
* Choose an integer `k` where `1 <= k <= arr.length`.
* Reverse the sub-array `arr[0...k-1]` (**0-indexed**).
For example, if `arr = [3,2,1,4]` and we performed a pancake f... | null | Design,Queue,Data Stream | Easy | null |
1,637 | okay so we have our points and we'll sort our points um and we only care about uh the first number which would be the x-axis okay so now we have sorted points x-axis okay so now we have sorted points x-axis okay so now we have sorted points now we're going to say let um max difference I mean that's really what it is ac... | Widest Vertical Area Between Two Points Containing No Points | string-compression-ii | Given `n` `points` on a 2D plane where `points[i] = [xi, yi]`, Return _the **widest vertical area** between two points such that no points are inside the area._
A **vertical area** is an area of fixed-width extending infinitely along the y-axis (i.e., infinite height). The **widest vertical area** is the one with the ... | Use dynamic programming. The state of the DP can be the current index and the remaining characters to delete. Having a prefix sum for each character can help you determine for a certain character c in some specific range, how many characters you need to delete to merge all occurrences of c in that range. | String,Dynamic Programming | Hard | null |
1,171 | hello guys welcome back to my YouTube channel today I'm going to solve day 12 for from of this month on Le code if you guys haven't subscribed my YouTube channel yet then please go ahead and subscribe it now without any deay let's get started with today's problem so today uh we are going to solve problem number 1171 th... | Remove Zero Sum Consecutive Nodes from Linked List | shortest-path-in-binary-matrix | Given the `head` of a linked list, we repeatedly delete consecutive sequences of nodes that sum to `0` until there are no such sequences.
After doing so, return the head of the final linked list. You may return any such answer.
(Note that in the examples below, all sequences are serializations of `ListNode` objects.)... | Do a breadth first search to find the shortest path. | Array,Breadth-First Search,Matrix | Medium | null |
108 | hello everyone welcome back here is vanamsen and today we will dive into another exciting coding Adventure today we have a fascinating challenge ahead of us uh converting assorted RI into a balanced binary search tree and we will be cracking this using JavaScript but before we start hit the Subscribe button and the bel... | Convert Sorted Array to Binary Search Tree | convert-sorted-array-to-binary-search-tree | Given an integer array `nums` where the elements are sorted in **ascending order**, convert _it to a_ **_height-balanced_** _binary search tree_.
**Example 1:**
**Input:** nums = \[-10,-3,0,5,9\]
**Output:** \[0,-3,9,-10,null,5\]
**Explanation:** \[0,-10,5,null,-3,null,9\] is also accepted:
**Example 2:**
**Input... | null | Array,Divide and Conquer,Tree,Binary Search Tree,Binary Tree | Easy | 109 |
1,567 | all right so what do we got here we have an array of elements and they just want to know what's the maximum length of contiguous elements that gives us a positive product so here you know the two negatives would become a positive and that would be length four because you know all four elements uh give us a positive pro... | Maximum Length of Subarray With Positive Product | maximum-number-of-vowels-in-a-substring-of-given-length | Given an array of integers `nums`, find the maximum length of a subarray where the product of all its elements is positive.
A subarray of an array is a consecutive sequence of zero or more values taken out of that array.
Return _the maximum length of a subarray with positive product_.
**Example 1:**
**Input:** nums... | Keep a window of size k and maintain the number of vowels in it. Keep moving the window and update the number of vowels while moving. Answer is max number of vowels of any window. | String,Sliding Window | Medium | null |
334 | foreign problem increasing triplet subsequence let's try to understand the problem statement we will be given on Integer rnms and we need to return true if there is if there exists a triplet of indices such that I should be less than J which should be less than K and their values also in the same order that means I sho... | Increasing Triplet Subsequence | increasing-triplet-subsequence | Given an integer array `nums`, return `true` _if there exists a triple of indices_ `(i, j, k)` _such that_ `i < j < k` _and_ `nums[i] < nums[j] < nums[k]`. If no such indices exists, return `false`.
**Example 1:**
**Input:** nums = \[1,2,3,4,5\]
**Output:** true
**Explanation:** Any triplet where i < j < k is valid.
... | null | Array,Greedy | Medium | 300,2122,2280 |
224 | lead code practice question uh in this video there are two goals the first goal is to see how to solve this problem so we are going to find the solution and then we are going to do some coding work and the second goal is to see how it should behave in a real interview so let's get started remember in the real interview... | Basic Calculator | basic-calculator | Given a string `s` representing a valid expression, implement a basic calculator to evaluate it, and return _the result of the evaluation_.
**Note:** You are **not** allowed to use any built-in function which evaluates strings as mathematical expressions, such as `eval()`.
**Example 1:**
**Input:** s = "1 + 1 "
**O... | null | Math,String,Stack,Recursion | Hard | 150,227,241,282,785,2147,2328 |
417 | Hello friends to Jhal Ajay, once again welcome all of you to our YouTube channel teacher, I am taking this very interesting question in today's video, Pacific Atlantic water flow, one basic question before starting, if not subscribe the channel. If you have done it then please do it friend, if you don't like the video ... | Pacific Atlantic Water Flow | pacific-atlantic-water-flow | There is an `m x n` rectangular island that borders both the **Pacific Ocean** and **Atlantic Ocean**. The **Pacific Ocean** touches the island's left and top edges, and the **Atlantic Ocean** touches the island's right and bottom edges.
The island is partitioned into a grid of square cells. You are given an `m x n` i... | null | Array,Depth-First Search,Breadth-First Search,Matrix | Medium | null |
1,510 | hey everybody this is Larry this is me going over Q for stone game for after reason did coke contest so yeah so the explanation for this one is that it's game theory which is always a little bit tricky I think with this one specially if you're doing in Python or other languages it might not be as intuitive I think of y... | Stone Game IV | find-lucky-integer-in-an-array | Alice and Bob take turns playing a game, with Alice starting first.
Initially, there are `n` stones in a pile. On each player's turn, that player makes a _move_ consisting of removing **any** non-zero **square number** of stones in the pile.
Also, if a player cannot make a move, he/she loses the game.
Given a positi... | Count the frequency of each integer in the array. Get all lucky numbers and return the largest of them. | Array,Hash Table,Counting | Easy | null |
108 | so we're looking at question 108 converting a sorted area to a binary search tree so let's go over the question really quickly so given an area where elements are sorted in ascending order converted to a height balance bst so for this problem a height balance based uh bst is defined as a binary tree invested depth of t... | Convert Sorted Array to Binary Search Tree | convert-sorted-array-to-binary-search-tree | Given an integer array `nums` where the elements are sorted in **ascending order**, convert _it to a_ **_height-balanced_** _binary search tree_.
**Example 1:**
**Input:** nums = \[-10,-3,0,5,9\]
**Output:** \[0,-3,9,-10,null,5\]
**Explanation:** \[0,-10,5,null,-3,null,9\] is also accepted:
**Example 2:**
**Input... | null | Array,Divide and Conquer,Tree,Binary Search Tree,Binary Tree | Easy | 109 |
226 | I am always amazed how many different type of problems you can make with binary trees right since it is a non-linear data structure you can play non-linear data structure you can play non-linear data structure you can play around with it for much in one such problem invert a binary tree you have to mirror a binary tree... | Invert Binary Tree | invert-binary-tree | Given the `root` of a binary tree, invert the tree, and return _its root_.
**Example 1:**
**Input:** root = \[4,2,7,1,3,6,9\]
**Output:** \[4,7,2,9,6,3,1\]
**Example 2:**
**Input:** root = \[2,1,3\]
**Output:** \[2,3,1\]
**Example 3:**
**Input:** root = \[\]
**Output:** \[\]
**Constraints:**
* The number of n... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Easy | null |
427 | hey guys welcome or welcome back to my channel so today we are going to discuss another problem but before going forward if you've 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 uh problem... | Construct Quad Tree | construct-quad-tree | Given a `n * n` matrix `grid` of `0's` and `1's` only. We want to represent `grid` with a Quad-Tree.
Return _the root of the Quad-Tree representing_ `grid`.
A Quad-Tree is a tree data structure in which each internal node has exactly four children. Besides, each node has two attributes:
* `val`: True if the node r... | null | null | Medium | null |
1,615 | Hello hello everyone welcome to write and analyze so in this video you will act deal promise mixture 16 mins you need to find maximum retail pack take it medium then please do apachya video android watching and depression long tilak pisces Fruit Predictions is 551 Number of Citizens Should Deal with Roads Connecting Ra... | Maximal Network Rank | range-sum-of-sorted-subarray-sums | There is an infrastructure of `n` cities with some number of `roads` connecting these cities. Each `roads[i] = [ai, bi]` indicates that there is a bidirectional road between cities `ai` and `bi`.
The **network rank** of **two different cities** is defined as the total number of **directly** connected roads to **either... | Compute all sums and save it in array. Then just go from LEFT to RIGHT index and calculate answer modulo 1e9 + 7. | Array,Two Pointers,Binary Search,Sorting | Medium | null |
141 | foreign Loop in a linked list so let's do that so let's say we are given a linked list which might contain a loop like this you need to find if there is a loop or not so a link list might have a loop might not have a loop you need to figure out whether it has a loop or not so how does a loop work in a linked list remem... | 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 |
236 | all right let's talk about the lowest common ancestor of binary trees so you're given a binary tree and you want to find out the lowest common ancestor so uh here's the simple example so this is a tree and you are given a root and then you need to have what p and q for a full target so five and one is actually the one ... | 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 |
786 | Hi guys welcome back to my channel cpp code and today we will do the question number 786 of the code what is the smallest prime fraction given in the question you are given a sorted integer which is an array containing one and prime numbers okay let's get the integer Jars of array R are unique We are given an array We ... | K-th Smallest Prime Fraction | search-in-a-sorted-array-of-unknown-size | You are given a sorted integer array `arr` containing `1` and **prime** numbers, where all the integers of `arr` are unique. You are also given an integer `k`.
For every `i` and `j` where `0 <= i < j < arr.length`, we consider the fraction `arr[i] / arr[j]`.
Return _the_ `kth` _smallest fraction considered_. Return y... | null | Array,Binary Search,Interactive | Medium | 792,1672 |
844 | That's what guys welcome to taken to live Nivedita and this video we are going to solve back space string compare switch problem what is your friend tinde rakha SAT what do we have to do this again must have seen a tractor whenever there will be joy neither that element You have to remove that character along with it, ... | Backspace String Compare | backspace-string-compare | Given two strings `s` and `t`, return `true` _if they are equal when both are typed into empty text editors_. `'#'` means a backspace character.
Note that after backspacing an empty text, the text will continue empty.
**Example 1:**
**Input:** s = "ab#c ", t = "ad#c "
**Output:** true
**Explanation:** Both s and t... | null | null | Easy | null |
701 | good okay hey what's up guys new right here this is uh Jesus okay one more time hey what's up guys Nick white here I detect Cody stuff on twitch and YouTube check the description for all my information join the discord you know all that stuff it is in the description so this problem is called insert into a binary searc... | Insert into a Binary Search Tree | insert-into-a-binary-search-tree | You are given the `root` node of a binary search tree (BST) and a `value` to insert into the tree. Return _the root node of the BST after the insertion_. It is **guaranteed** that the new value does not exist in the original BST.
**Notice** that there may exist multiple valid ways for the insertion, as long as the tre... | null | null | Medium | null |
1,335 | solution to day 16th of October lead Cod Challenge the problem that we have in today is minimum difficulty of job schedule lead code 135 this is a hard level question on lead code and I totally feel the same the problem is based on the concept of dynamic programming but it is easier than yesterday's question so I'll be... | Minimum Difficulty of a Job Schedule | maximum-candies-allocated-to-k-children | You want to schedule a list of jobs in `d` days. Jobs are dependent (i.e To work on the `ith` job, you have to finish all the jobs `j` where `0 <= j < i`).
You have to finish **at least** one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the `d` days. The difficulty of a da... | For a fixed number of candies c, how can you check if each child can get c candies? Use binary search to find the maximum c as the answer. | Array,Binary Search | Medium | 907,1886,2000,2027,2188,2294 |
1,420 | hello and welcome to another video in this problem we're going to be doing build array where you can find the maximum exactly K comparison kind of a long one and so you're here you're given three integers N M and K and you want to consider the following algorithm to find the maximum it's going of walk through what this... | Build Array Where You Can Find The Maximum Exactly K Comparisons | find-the-start-and-end-number-of-continuous-ranges | You are given three integers `n`, `m` and `k`. Consider the following algorithm to find the maximum element of an array of positive integers:
You should build the array arr which has the following properties:
* `arr` has exactly `n` integers.
* `1 <= arr[i] <= m` where `(0 <= i < n)`.
* After applying the menti... | null | Database | Medium | 1357,1759 |
565 | hey what's up guys this is juan here again so uh let's quickly take a look at today's daily challenge problem number 565 array nesting right so you're given like integer arrays right nums where the numbers is a permutation of numbers in the range of zero to n minus one so it's a permutation so which means that no avera... | Array Nesting | array-nesting | You are given an integer array `nums` of length `n` where `nums` is a permutation of the numbers in the range `[0, n - 1]`.
You should build a set `s[k] = {nums[k], nums[nums[k]], nums[nums[nums[k]]], ... }` subjected to the following rule:
* The first element in `s[k]` starts with the selection of the element `num... | null | Array,Depth-First Search | Medium | 339,341,364 |
376 | hey everybody this is larry this is day 18 of march uh the code farm hit the like button subscribe one join me on discord let me know what you think about this prom uh i struggled a lot with this farm you could look at it by the length of this video um so and on video square i think it goes for too long i actually reco... | Wiggle Subsequence | wiggle-subsequence | A **wiggle sequence** is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with one element and a sequence with two non-equal elements are trivially wiggle sequences.
* For ... | null | Array,Dynamic Programming,Greedy | Medium | 2271 |
287 | hi guys welcome to tech grant so today's problem is find the duplicate number it says that given an area of integer of num containing n plus one integer where each integer is in range of one to n itself and we need to find the duplicate integer and it says that there is only one number in this particular array which is... | Find the Duplicate Number | find-the-duplicate-number | Given an array of integers `nums` containing `n + 1` integers where each integer is in the range `[1, n]` inclusive.
There is only **one repeated number** in `nums`, return _this repeated number_.
You must solve the problem **without** modifying the array `nums` and uses only constant extra space.
**Example 1:**
**... | null | Array,Two Pointers,Binary Search,Bit Manipulation | Medium | 41,136,142,268,645 |
1,207 | Everyone today we are solving question number van 207 unique number ok we have to return true if number of akrens of h value make it unique means every value which is given to us inside akrens ok if I find out its frequency and the frequency of every element like this So what I have to do is to return True and False. O... | Unique Number of Occurrences | delete-nodes-and-return-forest | Given an array of integers `arr`, return `true` _if the number of occurrences of each value in the array is **unique** or_ `false` _otherwise_.
**Example 1:**
**Input:** arr = \[1,2,2,1,1,3\]
**Output:** true
**Explanation:** The value 1 has 3 occurrences, 2 has 2 and 3 has 1. No two values have the same number of oc... | null | Tree,Depth-First Search,Binary Tree | Medium | 2175 |
875 | Hello Friends Today I Will Discuss The Problem Latest Find Such Problems Series We Walking On This Is The Medium Problem And Used Oil Problem Shimla To The Medium Problem Quality And Subscribe Medium Problem Solve Problems On Tuesday To Solve This Problem Name Ko Love And Subscribe The Amazing Ghr Banana Hai Tags Engli... | Koko Eating Bananas | longest-mountain-in-array | Koko loves to eat bananas. There are `n` piles of bananas, the `ith` pile has `piles[i]` bananas. The guards have gone and will come back in `h` hours.
Koko can decide her bananas-per-hour eating speed of `k`. Each hour, she chooses some pile of bananas and eats `k` bananas from that pile. If the pile has less than `k... | null | Array,Two Pointers,Dynamic Programming,Enumeration | Medium | 1766,2205 |
246 | hey YouTube Welcome Back uh today we have this problem it's called Uh through parametric number so we're given a string nums which is represent an integral written through if the number is a stop romantic number a subramanic number is a number that looks the same when we rotate it for example we have this 69 and we ret... | Strobogrammatic Number | strobogrammatic-number | Given a string `num` which represents an integer, return `true` _if_ `num` _is a **strobogrammatic number**_.
A **strobogrammatic number** is a number that looks the same when rotated `180` degrees (looked at upside down).
**Example 1:**
**Input:** num = "69 "
**Output:** true
**Example 2:**
**Input:** num = "88... | null | Hash Table,Two Pointers,String | Easy | 247,248,1069 |
867 | hey everyone welcome back and let's write some more neat code today so today let's solve the problem transpose Matrix we're given a 2d integer array and we want to return the transpose of that which if you don't remember like your linear algebra and stuff is pretty simple actually they even colorcoded it for us to make... | Transpose Matrix | new-21-game | Given a 2D integer array `matrix`, return _the **transpose** of_ `matrix`.
The **transpose** of a matrix is the matrix flipped over its main diagonal, switching the matrix's row and column indices.
**Example 1:**
**Input:** matrix = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\]
**Output:** \[\[1,4,7\],\[2,5,8\],\[3,6,9\]\]
**E... | null | Math,Dynamic Programming,Sliding Window,Probability and Statistics | Medium | null |
476 | its binary format is one zero one so how do you get the binary format I hope you guys know that so if I given a number four two plus zero is one two by three is eight okay here it should be two power two also so let me just all right this is two power three so two power two is four two power three is eight so if a numb... | Number Complement | number-complement | The **complement** of an integer is the integer you get when you flip all the `0`'s to `1`'s and all the `1`'s to `0`'s in its binary representation.
* For example, The integer `5` is `"101 "` in binary and its **complement** is `"010 "` which is the integer `2`.
Given an integer `num`, return _its complement_.
**... | null | Bit Manipulation | Easy | null |
502 | Hey hello today I'm looking at the question fire 100 Oh to IPO so the question is really long there is actually a tldr in the question so just to read this first to sum up we want to pick a list of at most k distinctive projects from the given projects trying to maximize the capital gain final capital and that we want ... | IPO | ipo | Suppose LeetCode will start its **IPO** soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the **IPO**. Since it has limited resources, it can only finish at most `k` distinct projects before the **IPO**. Help LeetCode design... | null | Array,Greedy,Sorting,Heap (Priority Queue) | Hard | null |
63 | in this video we'll be going over the memorization approach of unique paths too now let's go over the dot process the recursive approach was inefficient due to overlapping recursive calls we can avoid overlapping recursive calls using memorization which means caching so what do we need to cache in each of the recursive... | Unique Paths II | unique-paths-ii | You are given an `m x n` integer array `grid`. There is a robot initially located at the **top-left corner** (i.e., `grid[0][0]`). The robot tries to move to the **bottom-right corner** (i.e., `grid[m - 1][n - 1]`). The robot can only move either down or right at any point in time.
An obstacle and space are marked as ... | The robot can only move either down or right. Hence any cell in the first row can only be reached from the cell left to it. However, if any cell has an obstacle, you don't let that cell contribute to any path. So, for the first row, the number of ways will simply be
if obstacleGrid[i][j] is not an obstacle
... | Array,Dynamic Programming,Matrix | Medium | 62,1022 |
1,361 | hey everyone welcome back and let's write some more neat code today so today let's solve the problem validate binary tree nodes we're given n binary tree nodes numbered from 0 to n minus one but that's not necessarily their value but the value is pretty much Irrelevant in this problem cuz it's not like a binary search ... | Validate Binary Tree Nodes | tiling-a-rectangle-with-the-fewest-squares | You have `n` binary tree nodes numbered from `0` to `n - 1` where node `i` has two children `leftChild[i]` and `rightChild[i]`, return `true` if and only if **all** the given nodes form **exactly one** valid binary tree.
If node `i` has no left child then `leftChild[i]` will equal `-1`, similarly for the right child.
... | Can you use backtracking to solve this problem ?. Suppose you've placed a bunch of squares. Where is the natural spot to place the next square ?. The maximum number of squares to be placed will be ≤ max(n,m). | Dynamic Programming,Backtracking | Hard | null |
1,663 | uh hey everybody this is larry this is day 28 of the january leeco daily challenge uh hit the like button hit the subscribe button join me on discord let me know what you think about today's problem um and just you know yeah wait is it 28 yeah okay i guess i just had to hit the refresh one but yeah um hope everyone's h... | Smallest String With A Given Numeric Value | detect-cycles-in-2d-grid | The **numeric value** of a **lowercase character** is defined as its position `(1-indexed)` in the alphabet, so the numeric value of `a` is `1`, the numeric value of `b` is `2`, the numeric value of `c` is `3`, and so on.
The **numeric value** of a **string** consisting of lowercase characters is defined as the sum of... | Keep track of the parent (previous position) to avoid considering an invalid path. Use DFS or BFS and keep track of visited cells to see if there is a cycle. | Array,Depth-First Search,Breadth-First Search,Union Find,Matrix | Medium | null |
52 | hello my name is kaushik and today i'm trying to solve this problem uh this is the june late court problem and uh that is a slight modification of yes status problem that was in queen and this is a type two here the number of queen has been given and we'll have to find the number of district solution so yesterday i hav... | N-Queens II | n-queens-ii | The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other.
Given an integer `n`, return _the number of distinct solutions to the **n-queens puzzle**_.
**Example 1:**
**Input:** n = 4
**Output:** 2
**Explanation:** There are two distinct solutions ... | null | Backtracking | Hard | 51 |
767 | hello everyone welcome back uh here is Van Thompson and today we are diving into fascinating problem from Bitcoin daily challenge uh seven six seven reorganized string so you are going to enjoy this and by the end of this session uh you will become a master of character manipulation so let's get started before we dive ... | Reorganize String | prime-number-of-set-bits-in-binary-representation | Given a string `s`, rearrange the characters of `s` so that any two adjacent characters are not the same.
Return _any possible rearrangement of_ `s` _or return_ `" "` _if not possible_.
**Example 1:**
**Input:** s = "aab"
**Output:** "aba"
**Example 2:**
**Input:** s = "aaab"
**Output:** ""
**Constraints:**
* ... | Write a helper function to count the number of set bits in a number, then check whether the number of set bits is 2, 3, 5, 7, 11, 13, 17 or 19. | Math,Bit Manipulation | Easy | 191 |
920 | hello hi guys good morning welcome back to a new video and in the video Problem number of Music playlist asked by Google and Godzilla we are having n different songs with us and our goal is to listen goal number of songs so basically ultimately in the end I should be listening to gold songs although I initially have in... | 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 |
73 | oh yes now let's do this every third garlicy code that matrix 0 given an M into n matrix hip and element 0 7 and as row and column 2 0 3 in place and we must go through in this extra space just how do we do it then we are going to mark every 0 F 0 and column that we encounter which has a 0 we'll put a 0 in it first now... | 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 |
1,200 | hello guys welcome to my another video so this is this video i want to talk about how i solved a 1000 and 200 nico program uh in this video i want to talk about how and why i did that and also what i learned from that and also my suggestion for you guys uh on that if you want to destroy an interview or improve your cod... | Minimum Absolute Difference | remove-interval | Given an array of **distinct** integers `arr`, find all pairs of elements with the minimum absolute difference of any two elements.
Return a list of pairs in ascending order(with respect to pairs), each pair `[a, b]` follows
* `a, b` are from `arr`
* `a < b`
* `b - a` equals to the minimum absolute difference o... | Solve the problem for every interval alone. Divide the problem into cases according to the position of the two intervals. | Array | Medium | null |
1,337 | Hello everyone, welcome to my channel, it should be easy, it is a very good practice question, the question has been asked from Amazon, only the problem statement was different, okay, it is a matrix , the name of the question is the company, who asked, Amazon has asked two questions, very simple. What is to be said in ... | The K Weakest Rows in a Matrix | design-skiplist | You are given an `m x n` binary matrix `mat` of `1`'s (representing soldiers) and `0`'s (representing civilians). The soldiers are positioned **in front** of the civilians. That is, all the `1`'s will appear to the **left** of all the `0`'s in each row.
A row `i` is **weaker** than a row `j` if one of the following is... | null | Linked List,Design | Hard | 816,817,838 |
221 | Loot Hello Everyone Welcome Back To My Channel Suggestion Or Go Into A Personal Problem Problems Maximum Square Year So In This Problem What Were Given This Will Give The Name Cross And Tricks And Tips For Angry Matrix Means 2001 Need To Find Out The Largest Per Containing Only Wants a determination to achieve these te... | Maximal Square | maximal-square | Given an `m x n` binary `matrix` filled with `0`'s and `1`'s, _find the largest square containing only_ `1`'s _and return its area_.
**Example 1:**
**Input:** matrix = \[\[ "1 ", "0 ", "1 ", "0 ", "0 "\],\[ "1 ", "0 ", "1 ", "1 ", "1 "\],\[ "1 ", "1 ", "1 ", "1 ", "1 "\],\[ "1 ", "0 ", "0 ", "1 ", "0 "\]\]
**Output:*... | null | Array,Dynamic Programming,Matrix | Medium | 85,769,1312,2200 |
27 | hello friends welcome to coding host youtube channel in this video i will explain you a lead code problem remove element so in this question we will get integer array nums and an integer val so we have to remove all the occurrence of this val variable in the nums in place the relative order of the elements may be chang... | Remove Element | remove-element | Given an integer array `nums` and an integer `val`, remove all occurrences of `val` in `nums` [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm). The order of the elements may be changed. Then return _the number of elements in_ `nums` _which are not equal to_ `val`.
Consider the number of elements in `nu... | The problem statement clearly asks us to modify the array in-place and it also says that the element beyond the new length of the array can be anything. Given an element, we need to remove all the occurrences of it from the array. We don't technically need to remove that element per-say, right? We can move all the occu... | Array,Two Pointers | Easy | 26,203,283 |
1,200 | what's up everyone today we'll be looking at uh this question what is minimum absolute difference I should have loaded it earlier so 1 120 minimum absolute difference um yeah so let's start the timer and let's see if we can solve it solve the question okay so given an array of t distinct integer are find all pairs of e... | Minimum Absolute Difference | remove-interval | Given an array of **distinct** integers `arr`, find all pairs of elements with the minimum absolute difference of any two elements.
Return a list of pairs in ascending order(with respect to pairs), each pair `[a, b]` follows
* `a, b` are from `arr`
* `a < b`
* `b - a` equals to the minimum absolute difference o... | Solve the problem for every interval alone. Divide the problem into cases according to the position of the two intervals. | Array | Medium | null |
67 | hey everyone welcome back to another video uh i'm jotander and i do lead quote questions on youtube so be sure to check out my channel if you're into that stuff right so today we'll be looking at this problem that is called add binary so given two binary strings you have to return their sum in the form of another binar... | 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 |
380 | Hello everyone welcome to my channel so today we are going to start a new play which is question number one of playlist with data set design it is ok lead code number 380 is a medium level question madam pretty sir I will make it super like this When you reach the end of this question, okay, this is the name of the que... | Insert Delete GetRandom O(1) | insert-delete-getrandom-o1 | Implement the `RandomizedSet` class:
* `RandomizedSet()` Initializes the `RandomizedSet` object.
* `bool insert(int val)` Inserts an item `val` into the set if not present. Returns `true` if the item was not present, `false` otherwise.
* `bool remove(int val)` Removes an item `val` from the set if present. Retur... | null | Array,Hash Table,Math,Design,Randomized | Medium | 381 |
609 | Good WhatsApp Web Large Maximum Volume Unmute Welcome Back Oriental YouTube Video In Today's Video 2019 Pointed End System Deputy Minutes Silence On [ Deputy Minutes Silence On [ Deputy Minutes Silence On Governor List Of Parts Of The Train For Including Directory Papad All Files Which Contains Industry Duplicates 5757... | Find Duplicate File in System | find-duplicate-file-in-system | Given a list `paths` of directory info, including the directory path, and all the files with contents in this directory, return _all the duplicate files in the file system in terms of their paths_. You may return the answer in **any order**.
A group of duplicate files consists of at least two files that have the same ... | null | Array,Hash Table,String | Medium | 2079 |
1,444 | um hello so today we are going to do this problem which is part of lead code daily challenge number of ways of cutting a pizza so what this problem says is we get a rectangular pizza that is represented by Rose by matrix um Rose by Karma of course um and this Matrix has a which will represent an apple and it has a DOT ... | Number of Ways of Cutting a Pizza | number-of-steps-to-reduce-a-number-to-zero | Given a rectangular pizza represented as a `rows x cols` matrix containing the following characters: `'A'` (an apple) and `'.'` (empty cell) and given the integer `k`. You have to cut the pizza into `k` pieces using `k-1` cuts.
For each cut you choose the direction: vertical or horizontal, then you choose a cut positi... | Simulate the process to get the final answer. | Math,Bit Manipulation | Easy | 1303,2288 |
199 | all right welcome to this video we're gonna be solving Miko prom 199 binary tree right side view so they give you a binary tree I like what the directions say they say imagine you're a person staying to the right of this tree and you're looking sideways left what notes would you see you would see just the 1 the 3 and t... | Binary Tree Right Side View | binary-tree-right-side-view | Given the `root` of a binary tree, imagine yourself standing on the **right side** of it, return _the values of the nodes you can see ordered from top to bottom_.
**Example 1:**
**Input:** root = \[1,2,3,null,5,null,4\]
**Output:** \[1,3,4\]
**Example 2:**
**Input:** root = \[1,null,3\]
**Output:** \[1,3\]
**Examp... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Medium | 116,545 |
1,881 | hello everyone today is we're going to solve this problem maximum value after insertion on lead code so the problem statement is we have a large integer as a string let's say the integer is one as a string is let's say it's one three four 5 and we have an integer x which is let's say it is 2 in this case and after the ... | Maximum Value after Insertion | closest-subsequence-sum | You are given a very large integer `n`, represented as a string, and an integer digit `x`. The digits in `n` and the digit `x` are in the **inclusive** range `[1, 9]`, and `n` may represent a **negative** number.
You want to **maximize** `n`**'s numerical value** by inserting `x` anywhere in the decimal represen... | The naive solution is to check all possible subsequences. This works in O(2^n). Divide the array into two parts of nearly is equal size. Consider all subsets of one part and make a list of all possible subset sums and sort this list. Consider all subsets of the other part, and for each one, let its sum = x, do binary s... | Array,Two Pointers,Dynamic Programming,Bit Manipulation,Bitmask | Hard | 2108,2162 |
398 | okay so uh lead code practice time um so two goals in this video the first one is to see how to solve this problem so find the solution and then we are going to do some coding work and the second one is to see how we should behave in a real interview suppose this is something given in a real interview so let's get star... | Random Pick Index | random-pick-index | Given an integer array `nums` with possible **duplicates**, randomly output the index of a given `target` number. You can assume that the given target number must exist in the array.
Implement the `Solution` class:
* `Solution(int[] nums)` Initializes the object with the array `nums`.
* `int pick(int target)` Pic... | null | Hash Table,Math,Reservoir Sampling,Randomized | Medium | 382,894,912 |
91 | hey guys it's all five one here and today we're going to be solving the code ways in this problem we're told that we're mapping every letter to a number so for example here we have a and it's mapped to one B is an app to two and Z is map of 26. so every letter in the alphabet is mapped to its position in the alphabet s... | Decode Ways | decode-ways | A message containing letters from `A-Z` can be **encoded** into numbers using the following mapping:
'A' -> "1 "
'B' -> "2 "
...
'Z' -> "26 "
To **decode** an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For examp... | null | String,Dynamic Programming | Medium | 639,2091 |
100 | hello everyone so today we are going to solve this question so the question is to find if the given two trees are same or not so in the first example we can see that both of them are having three nodes one two and three in the same direction same order so for example if we consider the root of both of the trees so they... | Same Tree | same-tree | Given the roots of two binary trees `p` and `q`, write a function to check if they are the same or not.
Two binary trees are considered the same if they are structurally identical, and the nodes have the same value.
**Example 1:**
**Input:** p = \[1,2,3\], q = \[1,2,3\]
**Output:** true
**Example 2:**
**Input:** p... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Easy | null |
1,673 | hey so i just came back from a break which is why i didn't upload for about a week but hopefully now i can start doing that again i just did this question but i realized my mic wasn't turned on so rip um now i'm going to just do it again so find the most competitive sub sequence you're given an array nums and an intege... | 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 |
108 | in this video we'll be going over convert sorted array to binary surgery so give me an array what elements are sorted in ascending order converted to a high balance bst for this problem a high balanced binary tree is defined as a binary tree in which the depth of two sub trees of every node never differs by more than o... | Convert Sorted Array to Binary Search Tree | convert-sorted-array-to-binary-search-tree | Given an integer array `nums` where the elements are sorted in **ascending order**, convert _it to a_ **_height-balanced_** _binary search tree_.
**Example 1:**
**Input:** nums = \[-10,-3,0,5,9\]
**Output:** \[0,-3,9,-10,null,5\]
**Explanation:** \[0,-10,5,null,-3,null,9\] is also accepted:
**Example 2:**
**Input... | null | Array,Divide and Conquer,Tree,Binary Search Tree,Binary Tree | Easy | 109 |
435 | in this video we're going to take a look at a legal problem called non-overlapping intervals so given a non-overlapping intervals so given a non-overlapping intervals so given a collection of intervals find the minimum number of intervals you need to remove to make the rest of intervals non-overlapping so here you can ... | Non-overlapping Intervals | non-overlapping-intervals | Given an array of intervals `intervals` where `intervals[i] = [starti, endi]`, return _the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping_.
**Example 1:**
**Input:** intervals = \[\[1,2\],\[2,3\],\[3,4\],\[1,3\]\]
**Output:** 1
**Explanation:** \[1,3\] can be removed ... | null | Array,Dynamic Programming,Greedy,Sorting | Medium | 452 |
1,020 | hey so welcome back and this is another daily code problem so today it was called number of enclaves so let's take a look at it so this is a medium level graph question and so you're given this two-dimensional and so you're given this two-dimensional and so you're given this two-dimensional Matrix here called grid and ... | Number of Enclaves | longest-turbulent-subarray | You are given an `m x n` binary matrix `grid`, where `0` represents a sea cell and `1` represents a land cell.
A **move** consists of walking from one land cell to another adjacent (**4-directionally**) land cell or walking off the boundary of the `grid`.
Return _the number of land cells in_ `grid` _for which we cann... | null | Array,Dynamic Programming,Sliding Window | Medium | 53 |
1,441 | hello hi guys good morning welcome back to the new video so this video we're going to see the problem uh build an array with stack operations so as you can see right here uh it has been asked by Google not much frequently uh so the problem says that what we are having right here with us we are we have to build an array... | Build an Array With Stack Operations | minimum-flips-to-make-a-or-b-equal-to-c | You are given an integer array `target` and an integer `n`.
You have an empty stack with the two following operations:
* **`"Push "`**: pushes an integer to the top of the stack.
* **`"Pop "`**: removes the integer on the top of the stack.
You also have a stream of the integers in the range `[1, n]`.
Use the tw... | Check the bits one by one whether they need to be flipped. | Bit Manipulation | Medium | 2323 |
728 | Scientist Hi Ghadi Jhadu Are You Welcome To Your Friend Delivery In Images Were Completed And Lord Of Ghosts And Evil Dual Core Processor Slow Before Proceeding Is Humble Request To Avoid In The Guys In This Video Knowledge Swiss Watching This Video Please Wrong With Screaming And Is Channel Like Subscribe And Comment ... | Self Dividing Numbers | self-dividing-numbers | A **self-dividing number** is a number that is divisible by every digit it contains.
* For example, `128` is **a self-dividing number** because `128 % 1 == 0`, `128 % 2 == 0`, and `128 % 8 == 0`.
A **self-dividing number** is not allowed to contain the digit zero.
Given two integers `left` and `right`, return _a l... | For each number in the range, check whether it is self dividing by converting that number to a character array (or string in Python), then checking that each digit is nonzero and divides the original number. | Math | Easy | 507 |
112 | hello everyone today we are looking at liquid problem number 112 path sum in this problem we are given a binary tree and an integer Target sum and we should check if the binary tree contains a path which starts at the root goes all the way down to leaf such that the sum of all the values on that path equal the integer ... | Path Sum | path-sum | Given the `root` of a binary tree and an integer `targetSum`, return `true` if the tree has a **root-to-leaf** path such that adding up all the values along the path equals `targetSum`.
A **leaf** is a node with no children.
**Example 1:**
**Input:** root = \[5,4,8,11,null,13,4,7,2,null,null,null,1\], targetSum = 22... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Easy | 113,124,129,437,666 |
701 | hey everyone welcome back and let's write some more neat code today so today let's solve the problem insert into a binary search tree we're given the root of a binary search tree and a value that we want to insert into the tree and then we want to return the new root of the tree also it is guaranteed that the new value... | Insert into a Binary Search Tree | insert-into-a-binary-search-tree | You are given the `root` node of a binary search tree (BST) and a `value` to insert into the tree. Return _the root node of the BST after the insertion_. It is **guaranteed** that the new value does not exist in the original BST.
**Notice** that there may exist multiple valid ways for the insertion, as long as the tre... | null | null | Medium | null |
1,086 | hello friends we are not employed by a fan company so let's not stop lead coding till we get there today we are going to do a lead code premium problem high five and uh the though it seems like an easy problem this actually covers a pretty interesting topic that is asked by a lot of fang companies uh and the topic is m... | High Five | divisor-game | Given a list of the scores of different students, `items`, where `items[i] = [IDi, scorei]` represents one score from a student with `IDi`, calculate each student's **top five average**.
Return _the answer as an array of pairs_ `result`_, where_ `result[j] = [IDj, topFiveAveragej]` _represents the student with_ `IDj` ... | If the current number is even, we can always subtract a 1 to make it odd. If the current number is odd, we must subtract an odd number to make it even. | Math,Dynamic Programming,Brainteaser,Game Theory | Easy | null |
139 | hello and welcome to another video today we're going to be working on word break in this problem you're given a string s and a dictionary of strings we're and you want to return true if s can be segmented into a space separated sequence of one or more dictionary words note in the same word in dictionary may be reused m... | Word Break | word-break | Given a string `s` and a dictionary of strings `wordDict`, return `true` if `s` can be segmented into a space-separated sequence of one or more dictionary words.
**Note** that the same word in the dictionary may be reused multiple times in the segmentation.
**Example 1:**
**Input:** s = "leetcode ", wordDict = \[ "... | null | Hash Table,String,Dynamic Programming,Trie,Memoization | Medium | 140 |
1,973 | Hello friends welcome to my channel let's have a look at problem 1973 count nodes equal to sum of dissidents in this video we are going to share a solution based on recursion first I'll read through the statement to digest the problem requirements and then we share the idea and explain the codes so first the statement ... | Count Nodes Equal to Sum of Descendants | count-nodes-equal-to-sum-of-descendants | Given the `root` of a binary tree, return _the number of nodes where the value of the node is equal to the **sum** of the values of its descendants_.
A **descendant** of a node `x` is any node that is on the path from node `x` to some leaf node. The sum is considered to be `0` if the node has no descendants.
**Exampl... | null | null | Medium | null |
257 | hey folks welcome back to another video today we're looking at question 257 binary tree pads the way we'll be approaching this problem is by recursion um anytime you see like a binary tree question um this high probability that it can be solved by recursion and this is not a very different case we can use recursion as ... | 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 |
883 | yeah hi hello everyone I'm an independent member today I will introduce to you a math problem with the following formula: the you a math problem with the following formula: the you a math problem with the following formula: the area of the projection of a area of the projection of a area of the projection of a 3d... | Projection Area of 3D Shapes | car-fleet | You are given an `n x n` `grid` where we place some `1 x 1 x 1` cubes that are axis-aligned with the `x`, `y`, and `z` axes.
Each value `v = grid[i][j]` represents a tower of `v` cubes placed on top of the cell `(i, j)`.
We view the projection of these cubes onto the `xy`, `yz`, and `zx` planes.
A **projection** is ... | null | Array,Stack,Sorting,Monotonic Stack | Medium | 1902,2317 |
89 | Tigers Vitamin When I give you a question and absolutely okay how to define a record your A like if you have 12 2010 90 it goes from one number to two numbers just put one so liberally okay this is gravity is broken and vanshi ho this Vitamin C is there, loot that one son, change of 1 minute, change of your limits M Un... | Gray Code | gray-code | An **n-bit gray code sequence** is a sequence of `2n` integers where:
* Every integer is in the **inclusive** range `[0, 2n - 1]`,
* The first integer is `0`,
* An integer appears **no more than once** in the sequence,
* The binary representation of every pair of **adjacent** integers differs by **exactly one ... | null | Math,Backtracking,Bit Manipulation | Medium | 717 |
1,926 | Nearest Exit from Entrance is a medium level problem and trust me it is a very simple problem, there is nothing to worry about, so first of all let us write down what Pinku Given is in this question and what is this question number trying to say. If you understand the question from this example, then there is nothing s... | Nearest Exit from Entrance in Maze | products-price-for-each-store | You are given an `m x n` matrix `maze` (**0-indexed**) with empty cells (represented as `'.'`) and walls (represented as `'+'`). You are also given the `entrance` of the maze, where `entrance = [entrancerow, entrancecol]` denotes the row and column of the cell you are initially standing at.
In one step, you can move o... | null | Database | Easy | 1948 |
1,021 | side effects of getting Ajay tied photo gallery, so today we are going to remove turn off parents, what to do on this question, I have given you a basic string of bath on which opening and closing date is song A, okay, only guest. If you have such a racket then you can get it as if you got it with money, it will also b... | 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 |
1,013 | okay I should welcome to this new programming video in this we are going to solve something as partition a day just ahead okay and this we are trying to solve the partition area into three parts with equal so this was one problem I must say that I did not figure out the solution so I was thinking too much which was not... | Partition Array Into Three Parts With Equal Sum | fibonacci-number | Given an array of integers `arr`, return `true` if we can partition the array into three **non-empty** parts with equal sums.
Formally, we can partition the array if we can find indexes `i + 1 < j` with `(arr[0] + arr[1] + ... + arr[i] == arr[i + 1] + arr[i + 2] + ... + arr[j - 1] == arr[j] + arr[j + 1] + ... + arr[ar... | null | Math,Dynamic Programming,Recursion,Memoization | Easy | 70,872,905,1236 |
1,742 | all right let's talk about maximum number of balls in the box so the first favorite is redundant and you just have two uh the limit ones load them in the other one's high limit and it's inclusive so uh i'm going to summarize the whole entire question so you have a bow so you have to assign the bow to the correct box so... | Maximum Number of Balls in a Box | widest-vertical-area-between-two-points-containing-no-points | You are working in a ball factory where you have `n` balls numbered from `lowLimit` up to `highLimit` **inclusive** (i.e., `n == highLimit - lowLimit + 1`), and an infinite number of boxes numbered from `1` to `infinity`.
Your job at this factory is to put each ball in the box with a number equal to the sum of digits ... | Try sorting the points Think is the y-axis of a point relevant | Array,Sorting | Medium | null |
127 | hey everyone welcome back and let's write some more neat code today so today let's solve word ladder this is a hard problem but i don't think it's super difficult there's just one little thing that kind of makes it really annoying to get this to pass on leak code but the idea is we're given a beginning word and we're g... | Word Ladder | word-ladder | 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,Breadth-First Search | Hard | 126,433 |
134 | hi everyone welcome back to a new video today we are going to discuss a new question from Top interview 150 lead code and the question name is gas station this is a medium level question and in this question what we have been given is we have been given n gas stations okay so basically what we have to do let's say we h... | 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 |
122 | okay back to leak code again today working on best time to buy and sell stock two so in this one you're supposed to loop through an array and find uh the differences between some numbers to essentially get out of profit so the way to think about this one is that every time a number in here in this sequence increases th... | Best Time to Buy and Sell Stock II | best-time-to-buy-and-sell-stock-ii | You are given an integer array `prices` where `prices[i]` is the price of a given stock on the `ith` day.
On each day, you may decide to buy and/or sell the stock. You can only hold **at most one** share of the stock at any time. However, you can buy it then immediately sell it on the **same day**.
Find and return _t... | null | Array,Dynamic Programming,Greedy | Medium | 121,123,188,309,714 |
1,822 | how's it going guys so today we're going to solve the uh coolest question which is sine of their product of an array so this question is like saying like we have a function sine s that returns 1 if x is positive so like if this x is positive then it will return 1 if this x is negative then it will return uh minus 1 for... | Sign of the Product of an Array | longest-palindromic-subsequence-ii | There is a function `signFunc(x)` that returns:
* `1` if `x` is positive.
* `-1` if `x` is negative.
* `0` if `x` is equal to `0`.
You are given an integer array `nums`. Let `product` be the product of all values in the array `nums`.
Return `signFunc(product)`.
**Example 1:**
**Input:** nums = \[-1,-2,-3,-4,... | As with any good dp problem that uses palindromes, try building the palindrome from the edges The prime point is to check that no two adjacent characters are equal, so save the past character while building the palindrome. | String,Dynamic Programming | Medium | 516 |
365 | so hi everyone today we're going to discuss the water and jug problem it's lead code 365 problem okay so let's just get to it uh i hope you've read the question but i'll tell you in brief we are given two jugs okay this has capacity x let's say and we have another jack this has capacity y okay initially they're both em... | Water and Jug Problem | water-and-jug-problem | You are given two jugs with capacities `jug1Capacity` and `jug2Capacity` liters. There is an infinite amount of water supply available. Determine whether it is possible to measure exactly `targetCapacity` liters using these two jugs.
If `targetCapacity` liters of water are measurable, you must have `targetCapacity` li... | null | Math,Depth-First Search,Breadth-First Search | Medium | null |
1,184 | e Hello everyone, we are together again with another Lipo question, the last name of today is this pin Bus stops Zile Friends, the numbering of the bus stops are numbered from zero to minus one. This part of the question, friends, I am skipping because this part can be a bit confusing, here is the dissonance for good, ... | Distance Between Bus Stops | car-pooling | A bus has `n` stops numbered from `0` to `n - 1` that form a circle. We know the distance between all pairs of neighboring stops where `distance[i]` is the distance between the stops number `i` and `(i + 1) % n`.
The bus goes along both directions i.e. clockwise and counterclockwise.
Return the shortest distance betw... | Sort the pickup and dropoff events by location, then process them in order. | Array,Sorting,Heap (Priority Queue),Simulation,Prefix Sum | Medium | 253 |
496 | hey guys welcome back to my channel and i'm back again with another really interesting question video today guys we are going to solve question number 496 the next greater element part one before i start with the video guys i just want to request you that if you have not yet subscribed to my channel then please do subs... | Next Greater Element I | next-greater-element-i | The **next greater element** of some element `x` in an array is the **first greater** element that is **to the right** of `x` in the same array.
You are given two **distinct 0-indexed** integer arrays `nums1` and `nums2`, where `nums1` is a subset of `nums2`.
For each `0 <= i < nums1.length`, find the index `j` such ... | null | Array,Hash Table,Stack,Monotonic Stack | Easy | 503,556,739,2227 |
4 | hello everyone in this video I'm going to explain to you the solution for the lead code problem median of two sorted arrays so basically in this question we're given two sorted arrays num1 and else you having the size m n N and we have to find the median of the two sorted arrays within the time complexity of log of M p... | Median of Two Sorted Arrays | median-of-two-sorted-arrays | Given two sorted arrays `nums1` and `nums2` of size `m` and `n` respectively, return **the median** of the two sorted arrays.
The overall run time complexity should be `O(log (m+n))`.
**Example 1:**
**Input:** nums1 = \[1,3\], nums2 = \[2\]
**Output:** 2.00000
**Explanation:** merged array = \[1,2,3\] and median is ... | null | Array,Binary Search,Divide and Conquer | Hard | null |
1,877 | hey how's it going had to have this up to make sure that it was recording so ignore the cat he just wants attention or something uh okay leak code 1877 minimize maximum pair sum in Array the pair sum of a pair a is equal to a plus b the maximum pair sum is the largest pair sum in a list of pairs for example if we have ... | Minimize Maximum Pair Sum in Array | find-followers-count | The **pair sum** of a pair `(a,b)` is equal to `a + b`. The **maximum pair sum** is the largest **pair sum** in a list of pairs.
* For example, if we have pairs `(1,5)`, `(2,3)`, and `(4,4)`, the **maximum pair sum** would be `max(1+5, 2+3, 4+4) = max(6, 5, 8) = 8`.
Given an array `nums` of **even** length `n`, pai... | null | Database | Easy | null |
463 | hey guys how's everything doing this is Jason is not a good hobby in this video I'm going to take one represent LAN and 0 represent water great cells are connected horizontally vertically not diagonally the grid is completely surrounded by water there is exactly one on one or more connected on the cells the island does... | Island Perimeter | island-perimeter | You are given `row x col` `grid` representing a map where `grid[i][j] = 1` represents land and `grid[i][j] = 0` represents water.
Grid cells are connected **horizontally/vertically** (not diagonally). The `grid` is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells)... | null | Array,Depth-First Search,Breadth-First Search,Matrix | Easy | 695,733,1104 |
1,788 | hello everyone let's take a look at click code 178aa maximize the beauty of the garden so it's a log problem and it's a hard problem let's take a look at how to solve this problem so let's take a look at the problem first there's a garden of un flowers and each flower has integer beautiful value the flowers are arrange... | Maximize the Beauty of the Garden | stone-game-vi | There is a garden of `n` flowers, and each flower has an integer beauty value. The flowers are arranged in a line. You are given an integer array `flowers` of size `n` and each `flowers[i]` represents the beauty of the `ith` flower.
A garden is **valid** if it meets these conditions:
* The garden has at least two f... | When one takes the stone, they not only get the points, but they take them away from the other player too. Greedily choose the stone with the maximum aliceValues[i] + bobValues[i]. | Array,Math,Greedy,Sorting,Heap (Priority Queue),Game Theory | Medium | 909,1240,1522,1617,1685,1808,2002,2156 |
446 | all right guys welcome to our channel code with sunny and in this video i will be talking about the problem arithmetic slices its index is 446 and it is the second problem of the series of problem arithmetic slices and note that it is going to deal with the subsequences criteria okay so before moving on to discuss this... | Arithmetic Slices II - Subsequence | arithmetic-slices-ii-subsequence | Given an integer array `nums`, return _the number of all the **arithmetic subsequences** of_ `nums`.
A sequence of numbers is called arithmetic if it consists of **at least three elements** and if the difference between any two consecutive elements is the same.
* For example, `[1, 3, 5, 7, 9]`, `[7, 7, 7, 7]`, and ... | null | Array,Dynamic Programming | Hard | 413 |
911 | hello guys welcome back let's solve the fourth problem from weekly contest 103 the problem definition is that we are given to integer array person and time uh in an election the eighth vote was cast for person i and time i for each query at time t we have to find the person that was leading the election at that time uh... | Online Election | profitable-schemes | You are given two integer arrays `persons` and `times`. In an election, the `ith` vote was cast for `persons[i]` at time `times[i]`.
For each query at a time `t`, find the person that was leading the election at time `t`. Votes cast at time `t` will count towards our query. In the case of a tie, the most recent vote (... | null | Array,Dynamic Programming | Hard | null |
1,684 | hey guys peng here so today i'm going to talk about question 1684 count the number of consistent strings so what's given it's two given a string and a string array called allowed in the so let's make let's see how it works so let's see the info right here allows a b and what is this bunch of strings so what make a stri... | Count the Number of Consistent Strings | find-latest-group-of-size-m | You are given a string `allowed` consisting of **distinct** characters and an array of strings `words`. A string is **consistent** if all characters in the string appear in the string `allowed`.
Return _the number of **consistent** strings in the array_ `words`.
**Example 1:**
**Input:** allowed = "ab ", words = \[... | Since the problem asks for the latest step, can you start the searching from the end of arr? Use a map to store the current “1” groups. At each step (going backwards) you need to split one group and update the map. | Array,Binary Search,Simulation | Medium | null |
1,046 | welcome back to our Jess today's question is leak code1046 the last stone weight so you're given an array of integers Stones where Stone's eye is the weight of the ice stone we are playing a game with the stones on each turn we choose the heaviest two stones and smash them together suppose the heaviest two stones have ... | Last Stone Weight | max-consecutive-ones-iii | You are given an array of integers `stones` where `stones[i]` is the weight of the `ith` stone.
We are playing a game with the stones. On each turn, we choose the **heaviest two stones** and smash them together. Suppose the heaviest two stones have weights `x` and `y` with `x <= y`. The result of this smash is:
* I... | One thing's for sure, we will only flip a zero if it extends an existing window of 1s. Otherwise, there's no point in doing it, right? Think Sliding Window! Since we know this problem can be solved using the sliding window construct, we might as well focus in that direction for hints. Basically, in a given window, we c... | Array,Binary Search,Sliding Window,Prefix Sum | Medium | 340,424,485,487,2134 |
977 | hey everybody this is Larry this is day two of the Fe February man I'm losing months I'm losing years with years this uh March day two of the March Leo daily challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's prom I click here because sometimes there is a ... | Squares of a Sorted Array | distinct-subsequences-ii | Given an integer array `nums` sorted in **non-decreasing** order, return _an array of **the squares of each number** sorted in non-decreasing order_.
**Example 1:**
**Input:** nums = \[-4,-1,0,3,10\]
**Output:** \[0,1,9,16,100\]
**Explanation:** After squaring, the array becomes \[16,1,0,9,100\].
After sorting, it be... | null | String,Dynamic Programming | Hard | 2115 |
1,079 | so today we would be solving lead code question number 1079 and that is letter tile possibilities so uh what is the question is that we need to print all the possible arrangements for the given string and we need to print uh the count of those arrangements so okay so for this example we have a b so what is the total nu... | Letter Tile Possibilities | sum-of-root-to-leaf-binary-numbers | You have `n` `tiles`, where each tile has one letter `tiles[i]` printed on it.
Return _the number of possible non-empty sequences of letters_ you can make using the letters printed on those `tiles`.
**Example 1:**
**Input:** tiles = "AAB "
**Output:** 8
**Explanation:** The possible sequences are "A ", "B ", "AA... | Find each path, then transform that path to an integer in base 10. | Tree,Depth-First Search,Binary Tree | Easy | null |
114 | hello everyone so let's talk about latin binary tree two linked lists so you are given the root of a binary tree and you have to pattern the tree into the linked list so linked list should use the century noteplus or blah a little bit easy and so you are given the tree right and you have to return a linked list tree ok... | Flatten Binary Tree to Linked List | flatten-binary-tree-to-linked-list | Given the `root` of a binary tree, flatten the tree into a "linked list ":
* The "linked list " should use the same `TreeNode` class where the `right` child pointer points to the next node in the list and the `left` child pointer is always `null`.
* The "linked list " should be in the same order as a [**pre-order*... | If you notice carefully in the flattened tree, each node's right child points to the next node of a pre-order traversal. | Linked List,Stack,Tree,Depth-First Search,Binary Tree | Medium | 766,1796 |
52 | Al so this question is UN Queen 2 so if you didn't watch un Queen's one solution video you can watch it this question is similar we're going to return a distinct you know return a number of distinct solution for the puzzle so yeah we need to return a number right so it's going to be two there are two different solution... | N-Queens II | n-queens-ii | The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other.
Given an integer `n`, return _the number of distinct solutions to the **n-queens puzzle**_.
**Example 1:**
**Input:** n = 4
**Output:** 2
**Explanation:** There are two distinct solutions ... | null | Backtracking | Hard | 51 |
283 | hi everyone welcome today we're going to be doing leap code problem number 283 move zeros so the problem states given an integer array nums move all zeros to the end of it while maintaining the relative order of the non-zero elements of the non-zero elements of the non-zero elements now we have to do this in place with... | Move Zeroes | move-zeroes | Given an integer array `nums`, move all `0`'s to the end of it while maintaining the relative order of the non-zero elements.
**Note** that you must do this in-place without making a copy of the array.
**Example 1:**
**Input:** nums = \[0,1,0,3,12\]
**Output:** \[1,3,12,0,0\]
**Example 2:**
**Input:** nums = \[0\]... | In-place means we should not be allocating any space for extra array. But we are allowed to modify the existing array. However, as a first step, try coming up with a solution that makes use of additional space. For this problem as well, first apply the idea discussed using an additional array and the in-place solution ... | Array,Two Pointers | Easy | 27 |
88 | hello everyone elite code a day today our problem is leaked o88 merge sorted array is a very important algorithm it can be used in merge sort and finding the medium of two sorted arrays so let's get started the problem is given two sorted arrays num1 and num2 and merge them into names one has one sorted array so basica... | Merge Sorted Array | merge-sorted-array | You are given two integer arrays `nums1` and `nums2`, sorted in **non-decreasing order**, and two integers `m` and `n`, representing the number of elements in `nums1` and `nums2` respectively.
**Merge** `nums1` and `nums2` into a single array sorted in **non-decreasing order**.
The final sorted array should not be re... | You can easily solve this problem if you simply think about two elements at a time rather than two arrays. We know that each of the individual arrays is sorted. What we don't know is how they will intertwine. Can we take a local decision and arrive at an optimal solution? If you simply consider one element each at a ti... | Array,Two Pointers,Sorting | Easy | 21,1019,1028 |
435 | hey guys it's off51 here and today we're going to be solving non-overlapping going to be solving non-overlapping going to be solving non-overlapping intervals in this problem we're given an array of intervals where each interval represents a start time and an end time and they want us to return the minimum number of in... | Non-overlapping Intervals | non-overlapping-intervals | Given an array of intervals `intervals` where `intervals[i] = [starti, endi]`, return _the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping_.
**Example 1:**
**Input:** intervals = \[\[1,2\],\[2,3\],\[3,4\],\[1,3\]\]
**Output:** 1
**Explanation:** \[1,3\] can be removed ... | null | Array,Dynamic Programming,Greedy,Sorting | Medium | 452 |
4 | hello hi guys today special 10 medium to sorted rs.100 s the name suggests in vitro sorted rs.100 s the name suggests in vitro sorted rs.100 s the name suggests in vitro fertilization of different media not for example with spirit is giving this 232 mere 30 two years to come into one single are not a result there will ... | Median of Two Sorted Arrays | median-of-two-sorted-arrays | Given two sorted arrays `nums1` and `nums2` of size `m` and `n` respectively, return **the median** of the two sorted arrays.
The overall run time complexity should be `O(log (m+n))`.
**Example 1:**
**Input:** nums1 = \[1,3\], nums2 = \[2\]
**Output:** 2.00000
**Explanation:** merged array = \[1,2,3\] and median is ... | null | Array,Binary Search,Divide and Conquer | Hard | null |
969 | hey what's up guys chung here um so this time let's take a look at another uh lead called problem number 969 uh pancake sorting so you're given like an array of a you can perform a pancake flip with a number integer k what you can do with the k here is you can just reverse all the elements before k right and you can do... | Pancake Sorting | number-of-recent-calls | Given an array of integers `arr`, sort the array by performing a series of **pancake flips**.
In one pancake flip we do the following steps:
* Choose an integer `k` where `1 <= k <= arr.length`.
* Reverse the sub-array `arr[0...k-1]` (**0-indexed**).
For example, if `arr = [3,2,1,4]` and we performed a pancake f... | null | Design,Queue,Data Stream | Easy | null |
1,854 | hello everyone so in this video let us talk about an easy problem from lead code the problem name is maximum population here so you are given a 2d integer array logs where each log is a starting like the birth and end of a particular person like you can say the eighth person so you can assume there's a tongue and you h... | Maximum Population Year | maximum-population-year | You are given a 2D integer array `logs` where each `logs[i] = [birthi, deathi]` indicates the birth and death years of the `ith` person.
The **population** of some year `x` is the number of people alive during that year. The `ith` person is counted in year `x`'s population if `x` is in the **inclusive** range `[birthi... | null | null | Easy | null |
1,046 | hey everybody this is larry this is day seven of the leeco daily april challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's problem last stone rate i have a 736 days street going you can't i need to figure out how to change my camera because that's where my ... | Last Stone Weight | max-consecutive-ones-iii | You are given an array of integers `stones` where `stones[i]` is the weight of the `ith` stone.
We are playing a game with the stones. On each turn, we choose the **heaviest two stones** and smash them together. Suppose the heaviest two stones have weights `x` and `y` with `x <= y`. The result of this smash is:
* I... | One thing's for sure, we will only flip a zero if it extends an existing window of 1s. Otherwise, there's no point in doing it, right? Think Sliding Window! Since we know this problem can be solved using the sliding window construct, we might as well focus in that direction for hints. Basically, in a given window, we c... | Array,Binary Search,Sliding Window,Prefix Sum | Medium | 340,424,485,487,2134 |
1,828 | Hello guys welcome to the video me series sub heading thode bhi hamid se problem nach kudiye phone number of points inside sarkar se yagya na points ko subscribe channel ko subscribe and subscribe the Channel and subscribe the two and subscribe ka sauda first Sarkar is the green circle so let's meet on a green color yo... | Queries on Number of Points Inside a Circle | count-ways-to-distribute-candies | You are given an array `points` where `points[i] = [xi, yi]` is the coordinates of the `ith` point on a 2D plane. Multiple points can have the **same** coordinates.
You are also given an array `queries` where `queries[j] = [xj, yj, rj]` describes a circle centered at `(xj, yj)` with a radius of `rj`.
For each query `... | Try to define a recursive approach. For the ith candies, there will be one of the two following cases: If the i - 1 previous candies are already distributed into k bags for the ith candy, you can have k * dp[n - 1][k] ways to distribute the ith candy. We need then to solve the state of (n - 1, k). If the i - 1 previous... | Dynamic Programming | Hard | null |
1,560 | we have a circular track which consists of n sectors labeled from 1 to n a marathon will be held on this track and the marathon consists of M rounds so I the round starts from Stars sector rounds of I minus 1 till the sector rounds of I so for example if the round one starts at sector rounds of zero then it ends at the... | Most Visited Sector in a Circular Track | number-of-students-doing-homework-at-a-given-time | Given an integer `n` and an integer array `rounds`. We have a circular track which consists of `n` sectors labeled from `1` to `n`. A marathon will be held on this track, the marathon consists of `m` rounds. The `ith` round starts at sector `rounds[i - 1]` and ends at sector `rounds[i]`. For example, round 1 starts at ... | Imagine that startTime[i] and endTime[i] form an interval (i.e. [startTime[i], endTime[i]]). The answer is how many times the queryTime laid in those mentioned intervals. | Array | Easy | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.