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,649 | hey there everyone welcome back to lead coding in this video we'll be solving the question number four of lead code weekly contest 214 name of the problem is create sorted array through instructions the problem statement is given an integer array instructions you are asked to create a sorted array from the elements in ... | Create Sorted Array through Instructions | maximum-number-of-non-overlapping-subarrays-with-sum-equals-target | Given an integer array `instructions`, you are asked to create a sorted array from the elements in `instructions`. You start with an empty container `nums`. For each element from **left to right** in `instructions`, insert it into `nums`. The **cost** of each insertion is the **minimum** of the following:
* The numb... | Keep track of prefix sums to quickly look up what subarray that sums "target" can be formed at each step of scanning the input array. It can be proved that greedily forming valid subarrays as soon as one is found is optimal. | Array,Hash Table,Greedy,Prefix Sum | Medium | null |
84 | Half a minute Sarai's performance went restrictions, let's go ahead and see that the next one is the distraction histogram. Without tightening this question, don't go for the third tomorrow, friend Vikas, this tawa pulao is instant that you will not be able to understand what is going on in it and till now This is the ... | Largest Rectangle in Histogram | largest-rectangle-in-histogram | Given an array of integers `heights` representing the histogram's bar height where the width of each bar is `1`, return _the area of the largest rectangle in the histogram_.
**Example 1:**
**Input:** heights = \[2,1,5,6,2,3\]
**Output:** 10
**Explanation:** The above is a histogram where width of each bar is 1.
The l... | null | Array,Stack,Monotonic Stack | Hard | 85,1918 |
1,762 | all right so let's talk about the building with the ocean view so discussion is supposed to be easy so um I'm going to just follow that one so imagine this is a building ball this is building two this is building three and this is building one in the same definitely in the center for example so I'm gonna just use anoth... | Buildings With an Ocean View | furthest-building-you-can-reach | There are `n` buildings in a line. You are given an integer array `heights` of size `n` that represents the heights of the buildings in the line.
The ocean is to the right of the buildings. A building has an ocean view if the building can see the ocean without obstructions. Formally, a building has an ocean view if al... | Assume the problem is to check whether you can reach the last building or not. You'll have to do a set of jumps, and choose for each one whether to do it using a ladder or bricks. It's always optimal to use ladders in the largest jumps. Iterate on the buildings, maintaining the largest r jumps and the sum of the remain... | Array,Greedy,Heap (Priority Queue) | Medium | null |
274 | today i'm going to talk about the need code problem 274 h index this problem is rated as a medium but i believe like many people when they first look at the problem it's not very straightforward to understand uh let's us reading the description it says a scientist has index h if h of his or her end papers have at least... | H-Index | h-index | Given an array of integers `citations` where `citations[i]` is the number of citations a researcher received for their `ith` paper, return _the researcher's h-index_.
According to the [definition of h-index on Wikipedia](https://en.wikipedia.org/wiki/H-index): The h-index is defined as the maximum value of `h` such th... | An easy approach is to sort the array first. What are the possible values of h-index? A faster approach is to use extra space. | Array,Sorting,Counting Sort | Medium | 275 |
771 | hey everyone today we'll be doing another lead code problem 771 joules and Stones this is an easy one you are given a string joules representing the type of stones that are Jews and Stones representing uh Stones you have each character in stone is a type of stone you have you want to know how many stones you have are j... | Jewels and Stones | encode-n-ary-tree-to-binary-tree | You're given strings `jewels` representing the types of stones that are jewels, and `stones` representing the stones you have. Each character in `stones` is a type of stone you have. You want to know how many of the stones you have are also jewels.
Letters are case sensitive, so `"a "` is considered a different type o... | null | Tree,Depth-First Search,Breadth-First Search,Design,Binary Tree | Hard | 765 |
1,608 | hey everybody this is larry this is me going over q1 of the recently called contest uh special away with x elements greater than or equal to x all right hit the like button hit the subscribe button join me on discord and let's get started so basically the thing to notice is that uh each element can go only up to a thou... | 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,021 | 10:21 we moved out of most parentheses a 10:21 we moved out of most parentheses a 10:21 we moved out of most parentheses a weather parentheses string is either empty I don't know said like left wind wiper in and then this moment in the middle a plus B where a and B are valid parenthesis strings and plus my percent stri... | 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 |
80 | hey everybody this is larry this is day 11 of the leeco daily challenge uh hit the like button to subscribe and join me on discord let me know what you think about today's farm uh we moved duplicates from sorted away too uh so yeah so i usually solve this live and especially with the explanation as well so feel free to... | 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 |
79 | in this video we're going to take a look at a legal problem called word search so given am times in grid right and a word find if the word exists in the grid so when we do word search we can do horizontally right we have to uh construct the letters sequentially adjacent cells and we can do this horizontally or vertical... | Word Search | word-search | Given an `m x n` grid of characters `board` and a string `word`, return `true` _if_ `word` _exists in the grid_.
The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once.
**Example 1:**... | null | Array,Backtracking,Matrix | Medium | 212 |
259 | hey what's up guys this is john here so uh today uh let's take a look at this very old or classic problem the number 259 three some smaller even though it's like very old problem but i think it's i find that's kind of interesting you know okay so you're given like an array of integers right and it could be a either neg... | 3Sum Smaller | 3sum-smaller | Given an array of `n` integers `nums` and an integer `target`, find the number of index triplets `i`, `j`, `k` with `0 <= i < j < k < n` that satisfy the condition `nums[i] + nums[j] + nums[k] < target`.
**Example 1:**
**Input:** nums = \[-2,0,1,3\], target = 2
**Output:** 2
**Explanation:** Because there are two tri... | null | Array,Two Pointers,Binary Search,Sorting | Medium | 15,16,611,1083 |
144 | hello everyone in this video we'll do lead code 144 binary tree pre-order lead code 144 binary tree pre-order lead code 144 binary tree pre-order traversal this is today's daily challenge so basically we're just given a binary tree and we need to do a pre-order traversal on this tree so what pre-order traversal on this... | Binary Tree Preorder Traversal | binary-tree-preorder-traversal | Given the `root` of a binary tree, return _the preorder traversal of its nodes' values_.
**Example 1:**
**Input:** root = \[1,null,2,3\]
**Output:** \[1,2,3\]
**Example 2:**
**Input:** root = \[\]
**Output:** \[\]
**Example 3:**
**Input:** root = \[1\]
**Output:** \[1\]
**Constraints:**
* The number of nodes ... | null | Stack,Tree,Depth-First Search,Binary Tree | Easy | 94,255,775 |
78 | Buddha Problem Hindi Recording Series Suggestion Or Their Discuss Problem Sabse To In This Problem Will Be Given There Need To Find Out All Subjects Which Can Be Made From Midnight Should You Know Problem Ka Suggestion Liquid 1 Hafte Element Se Z Subscribe Different Subject Agreement To Give The Number subscribe and nu... | Subsets | subsets | Given an integer array `nums` of **unique** elements, return _all possible_ _subsets_ _(the power set)_.
The solution set **must not** contain duplicate subsets. Return the solution in **any order**.
**Example 1:**
**Input:** nums = \[1,2,3\]
**Output:** \[\[\],\[1\],\[2\],\[1,2\],\[3\],\[1,3\],\[2,3\],\[1,2,3\]\]
... | null | Array,Backtracking,Bit Manipulation | Medium | 90,320,800,2109,2170 |
1,557 | Hello everyone, welcome to my channel, I am going to do video number 26 of my graph playlist and before continuing, I am reminding you that if you have not seen my graph concept playlist, then you can watch it if you want to understand graph. In a very easy way ok it will be very easy once you go through the playlist o... | Minimum Number of Vertices to Reach All Nodes | check-if-a-string-contains-all-binary-codes-of-size-k | Given a **directed acyclic graph**, with `n` vertices numbered from `0` to `n-1`, and an array `edges` where `edges[i] = [fromi, toi]` represents a directed edge from node `fromi` to node `toi`.
Find _the smallest set of vertices from which all nodes in the graph are reachable_. It's guaranteed that a unique solution ... | We need only to check all sub-strings of length k. The number of distinct sub-strings should be exactly 2^k. | Hash Table,String,Bit Manipulation,Rolling Hash,Hash Function | Medium | null |
3 | uh hey everybody this is larry this is day seven of the january leeco dairy challenge uh yeah first week ending let me know how it goes hit the like button to subscribe and draw me discord um i usually attempt to solve and explain these problems lives so um let me know what you think about the format and if it's too sl... | Longest Substring Without Repeating Characters | longest-substring-without-repeating-characters | Given a string `s`, find the length of the **longest** **substring** without repeating characters.
**Example 1:**
**Input:** s = "abcabcbb "
**Output:** 3
**Explanation:** The answer is "abc ", with the length of 3.
**Example 2:**
**Input:** s = "bbbbb "
**Output:** 1
**Explanation:** The answer is "b ", with t... | null | Hash Table,String,Sliding Window | Medium | 159,340,1034,1813,2209 |
141 | Hello everyone Chirag this side and in today's video we will do our lead code problem number 141 which is link list cycle is a very easy question let's see what it says given head d head of English determine if d link list has a cycle in it It is said that we will be given a head of the penis lace. What do we have to d... | 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 |
1,577 | hey what's up guys chung here again so today let's take a look at one of the uh a weekly contest problem uh number 1577 a number of ways where square of number is equal to product of two numbers i think it's a pretty good problem so basically you're given like a two arrays right array a nums one and a red number two an... | Number of Ways Where Square of Number Is Equal to Product of Two Numbers | probability-of-a-two-boxes-having-the-same-number-of-distinct-balls | Given two arrays of integers `nums1` and `nums2`, return the number of triplets formed (type 1 and type 2) under the following rules:
* Type 1: Triplet (i, j, k) if `nums1[i]2 == nums2[j] * nums2[k]` where `0 <= i < nums1.length` and `0 <= j < k < nums2.length`.
* Type 2: Triplet (i, j, k) if `nums2[i]2 == nums1[j... | Check how many ways you can distribute the balls between the boxes. Consider that one way you will use (x1, x2, x3, ..., xk) where xi is the number of balls from colour i. The probability of achieving this way randomly is ( (ball1 C x1) * (ball2 C x2) * (ball3 C x3) * ... * (ballk C xk)) / (2n C n). The probability of ... | Math,Dynamic Programming,Backtracking,Combinatorics,Probability and Statistics | Hard | null |
502 | hi everyone in this video we're gonna solve a new problem the problem name is IPO and the problem number is 502 so first of all we're going to clearly understand what this problem says after that we're going to move to the logic part and after that we're going to implement our logic in C plus by Java and Python program... | 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 |
1,926 | hello everyone let's serve today's lead code problem nearest exit from entrance in maze you are given an M by n Matrix maze with empty cells and worth the red one you are here at entrance point you can move one set up left down and right in the Border you can move along the empty stairs not worse your goal is to find t... | 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,431 | Work in this field Ajay Ko Ki A [ Ki A [ Ki A Hello Everyone Welcome to New Video Hindi Video Player Going to Discuss Any Problem He Problem Solved Video Friends' Video Friends' Video Friends' Root to the Problem Statement's Problem to Dates of Reddy Festival Number Aaf mid-day ne under-19 sir its candidates in waiting... | Kids With the Greatest Number of Candies | all-ancestors-of-a-node-in-a-directed-acyclic-graph | There are `n` kids with candies. You are given an integer array `candies`, where each `candies[i]` represents the number of candies the `ith` kid has, and an integer `extraCandies`, denoting the number of extra candies that you have.
Return _a boolean array_ `result` _of length_ `n`_, where_ `result[i]` _is_ `true` _i... | Consider how reversing each edge of the graph can help us. How can performing BFS/DFS on the reversed graph help us find the ancestors of every node? | Depth-First Search,Breadth-First Search,Graph,Topological Sort | Medium | 1912 |
707 | hello and welcome back to another Lee code problem today we're going to be doing problem number 707 design length list and it's not super tricky but you definitely are going to want to know how to like design a linked list and all these operations are going to be useful for other linked list problems you're going to ha... | Design Linked List | design-linked-list | Design your implementation of the linked list. You can choose to use a singly or doubly linked list.
A node in a singly linked list should have two attributes: `val` and `next`. `val` is the value of the current node, and `next` is a pointer/reference to the next node.
If you want to use the doubly linked list, you... | null | null | Medium | null |
6 | um hello so today we are going to do this problem which is a part of Fleet code daily challenge zigzag conversion so the problem says we get a string like PayPal is hiring um and then we is written in a zigzag pattern on a given number of rows right so in this form right so you can see PayPal is hiring like this um so ... | 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 |
67 | hello everyone welcome on welcome back to coding Champs in today's video we are going to be solving the problem at binary in this problem we are given with two binary strings A and B we have to return their sums as a binary string so let us take a look at the examples we have here equal to 1 and b equal to 1 so let me ... | 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,041 | hi i am ayushi rawat and welcome to my channel today we will discuss the september lead code challenge day 17 problem robot bounded in circle now let's have a look at the problem statement on an infinite plane a robot initially stands at coordinates 0 and faces north the robot can receive one of the three instructions ... | 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 |
135 | hey what's up guys this is sean here again so today's daily challenge problem writes number 135 candy so there are like young children standing in the line each child is assigned the reading and then you're giving like candies to these children subject to the following requirements each child must have at least one can... | Candy | candy | There are `n` children standing in a line. Each child is assigned a rating value given in the integer array `ratings`.
You are giving candies to these children subjected to the following requirements:
* Each child must have at least one candy.
* Children with a higher rating get more candies than their neighbors.... | null | Array,Greedy | Hard | null |
345 | I friends, how are you all, today we are going to talk about reverse vowels of a string, so what is this question saying and what do we have to do with the vowels, we just have to reverse them and return them, so let's see through the example like in this If it is Hello, then the vowels in it have been reversed and thi... | Reverse Vowels of a String | reverse-vowels-of-a-string | Given a string `s`, reverse only all the vowels in the string and return it.
The vowels are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`, and they can appear in both lower and upper cases, more than once.
**Example 1:**
**Input:** s = "hello"
**Output:** "holle"
**Example 2:**
**Input:** s = "leetcode"
**Output:** "leotc... | null | Two Pointers,String | Easy | 344,1089 |
114 | ok welcome back to my channel today we will talk make two real best video guys today radheshyam suggestion or hour solve question great 0ffline ab to landless and different videos subscribe my channel like this subscribe must subscribe reversal list of servi subscribe two three four One two three four turn on slider ri... | 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 |
520 | all right welcome to this video we're gonna be doing miko problem 520 detect capital so return it return a true or false value right a boolean value if all letters in the word are capitals all letters in the word are not capitals like this or just the first letter of the worst capital and the rest is lowercase so there... | Detect Capital | detect-capital | We define the usage of capitals in a word to be right when one of the following cases holds:
* All letters in this word are capitals, like `"USA "`.
* All letters in this word are not capitals, like `"leetcode "`.
* Only the first letter in this word is capital, like `"Google "`.
Given a string `word`, return `... | null | String | Easy | 2235 |
120 | hey what's up guys chung here uh today let's talk about not another uh at least called the problem uh 120 triangles so you're given like a triangle and you need to find the minimum path from top to bottom and each step you can only move to the adjacent rows below it so what does that what does the adjace adjacent numbe... | Triangle | triangle | Given a `triangle` array, return _the minimum path sum from top to bottom_.
For each step, you may move to an adjacent number of the row below. More formally, if you are on index `i` on the current row, you may move to either index `i` or index `i + 1` on the next row.
**Example 1:**
**Input:** triangle = \[\[2\],\[... | null | Array,Dynamic Programming | Medium | null |
27 | so let's see how to do this lead code problem 27 remove element so what they're asking us to do is we have an array in this case we have four elements in an array then we have a Val which is three what they're asking us to do is find all the instance of this well and remove that so in our case we have three so they wan... | 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 |
389 | hello and welcome today we're doing a question from wheats co2 called find the difference it's an easy let's get started given two strings s and T which consists of only lowercase letters string T is generated by randomly shuffling string s and then adding one more letter at a random position find the letter that was a... | Find the Difference | find-the-difference | You are given two strings `s` and `t`.
String `t` is generated by random shuffling string `s` and then add one more letter at a random position.
Return the letter that was added to `t`.
**Example 1:**
**Input:** s = "abcd ", t = "abcde "
**Output:** "e "
**Explanation:** 'e' is the letter that was added.
**Exam... | null | Hash Table,String,Bit Manipulation,Sorting | Easy | 136 |
334 | all right what's up guys it's fox from code bros and we're going to talk going over top interview questions arrays and strings question number six and raising strings which is increasing triple a subsequence so given array of numbers return true if there's exist a triple of indices i j k where i is less than j is less ... | 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 |
7 | uh ladies and gentlemen uh we're gonna look at another question in the lid code problems popular problem series this is question number seven how to reverse an integer uh again this is a very popular question so we're gonna look at a solution algorithm and the approach all right so let's get started uh so if you go to ... | 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,026 | okay so lead code practice time maximum difference between node and ancestor all right so again two goals the first one is to see how to solve this problem and then we are going to put some code here and the second one is how we should behave during real interview so let's get started so remember the first thing is to ... | Maximum Difference Between Node and Ancestor | string-without-aaa-or-bbb | Given the `root` of a binary tree, find the maximum value `v` for which there exist **different** nodes `a` and `b` where `v = |a.val - b.val|` and `a` is an ancestor of `b`.
A node `a` is an ancestor of `b` if either: any child of `a` is equal to `b` or any child of `a` is an ancestor of `b`.
**Example 1:**
**Input... | null | String,Greedy | Medium | null |
1,046 | Hello everyone welcome back to me channel once again and here we are going to talk about the problem of daily challenge and today's problem is basically from the easy problem list so the name of the question is last stone weight so read the question what is the question It is saying that you have a stone, wait stone, a... | 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 |
114 | Hello friends, I am Sharad Dushman, the special convert binary to-do list that has illuminated the country at the national level. It is a very famous convert binary to-do list that has illuminated the country at the national level. It is a very famous convert binary to-do list that has illuminated the country at the na... | 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 |
1,716 | Hello One So In This Video Will Solve There Problems 1716 That's Calculate Manish Ko Time So Let's Go By The Problem Statement First House I Want To Say Money For His First Car Reports Money Dalit Vote Bank Everyday Star Spotting Aur Lavan Deputy Everyday From Today I will support and always one more 1034 on every subs... | Calculate Money in Leetcode Bank | maximum-non-negative-product-in-a-matrix | Hercy wants to save money for his first car. He puts money in the Leetcode bank **every day**.
He starts by putting in `$1` on Monday, the first day. Every day from Tuesday to Sunday, he will put in `$1` more than the day before. On every subsequent Monday, he will put in `$1` more than the **previous Monday**.
Given... | Use Dynamic programming. Keep the highest value and lowest value you can achieve up to a point. | Array,Dynamic Programming,Matrix | Medium | null |
338 | welcome back to I would just today's questions League code 338 counting bits so you're given an integer n return an array answer of length M plus one such that each I where I is greater than or equal to zero and less than or equal to n and so I is the number of ones in the binary representation of I so we have n equal ... | Counting Bits | counting-bits | Given an integer `n`, return _an array_ `ans` _of length_ `n + 1` _such that for each_ `i` (`0 <= i <= n`)_,_ `ans[i]` _is the **number of**_ `1`_**'s** in the binary representation of_ `i`.
**Example 1:**
**Input:** n = 2
**Output:** \[0,1,1\]
**Explanation:**
0 --> 0
1 --> 1
2 --> 10
**Example 2:**
**Input:** n =... | You should make use of what you have produced already. Divide the numbers in ranges like [2-3], [4-7], [8-15] and so on. And try to generate new range from previous. Or does the odd/even status of the number help you in calculating the number of 1s? | Dynamic Programming,Bit Manipulation | Easy | 191 |
87 | um hello so today we are going to do this problem which is part of Fleet code daily challenge scramble strings so what this problem says is we get a string s and we want to convert it so basically we want to check if we can scramble it to get T and the way we scramble is by a defined algorithm here which is first if th... | Scramble String | scramble-string | We can scramble a string s to get a string t using the following algorithm:
1. If the length of the string is 1, stop.
2. If the length of the string is > 1, do the following:
* Split the string into two non-empty substrings at a random index, i.e., if the string is `s`, divide it to `x` and `y` where `s = x +... | null | String,Dynamic Programming | Hard | null |
1,859 | Hello everyone, how are you, my name is Vikas Gupta and Solution Bhai also welcome all of you in this new video of the case, so gas, today's video I have picked up from the lead code, so today's video of ours is the question of write an algorithm date. Will sort the given sentence, so how do we have to write the algori... | Sorting the Sentence | change-minimum-characters-to-satisfy-one-of-three-conditions | A **sentence** is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of lowercase and uppercase English letters.
A sentence can be **shuffled** by appending the **1-indexed word position** to each word then rearranging the words in the sentence.
* For example... | Iterate on each letter in the alphabet, and check the smallest number of operations needed to make it one of the following: the largest letter in a and smaller than the smallest one in b, vice versa, or let a and b consist only of this letter. For the first 2 conditions, take care that you can only change characters to... | Hash Table,String,Counting,Prefix Sum | Medium | null |
239 | hi so this question is sliding window maximum so uh you are given a in nums array and then also integer k so uh for every single k length inside the nums array with different index you need to grab the maximum value so uh this is not really hard to understand but it's really hard to call for sure so this is the size of... | Sliding Window Maximum | sliding-window-maximum | You are given an array of integers `nums`, there is a sliding window of size `k` which is moving from the very left of the array to the very right. You can only see the `k` numbers in the window. Each time the sliding window moves right by one position.
Return _the max sliding window_.
**Example 1:**
**Input:** nums... | How about using a data structure such as deque (double-ended queue)? The queue size need not be the same as the window’s size. Remove redundant elements and the queue should store only elements that need to be considered. | Array,Queue,Sliding Window,Heap (Priority Queue),Monotonic Queue | Hard | 76,155,159,265,1814 |
114 | welcome to mazelico challenge today's problem is 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 tree node class where the right child pointer points to the next node in the list and the left child pointer is always null the link... | 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 |
283 | all right this lead code question is called move zeros it says given an array nums write a function to move all zeros to the end of it while maintaining the relative order of the non-zero elements relative order of the non-zero elements relative order of the non-zero elements so the example is the array 0 1 0 3 12 and ... | 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 |
693 | discuss a problem on lee code it's a easy problem on vietnamese regarding manipulation and this problem wants us to check whether for a given positive integer if the two adjacent bits in a binary representation always have the same value if they have the same value return true if don't return false so for the number fi... | Binary Number with Alternating Bits | binary-number-with-alternating-bits | Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values.
**Example 1:**
**Input:** n = 5
**Output:** true
**Explanation:** The binary representation of 5 is: 101
**Example 2:**
**Input:** n = 7
**Output:** false
**Explanation:** The binary repr... | null | Bit Manipulation | Easy | 191 |
896 | hey guys in this video i'm gonna be teaching how to solve lead code problem 896 monotonic array let's read the question first an array is monotonic if it is either monotone increasing or monotone decreasing an array numbs is monotone increasing if for all i less than j less than equal to j numbers of i is less than equ... | Monotonic Array | smallest-subtree-with-all-the-deepest-nodes | An array is **monotonic** if it is either monotone increasing or monotone decreasing.
An array `nums` is monotone increasing if for all `i <= j`, `nums[i] <= nums[j]`. An array `nums` is monotone decreasing if for all `i <= j`, `nums[i] >= nums[j]`.
Given an integer array `nums`, return `true` _if the given array is ... | null | Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree | Medium | null |
62 | hello everyone welcome to my channel coding together my name is vikas hoja today we will see another lead code problem that is unique paths it is a medium level question and it's also a very popular question as you can see from the likes so let's read the problem statement first there is a robot on an M into n grid so ... | Unique Paths | unique-paths | There is a robot on an `m x n` grid. The robot is initially located at the **top-left corner** (i.e., `grid[0][0]`). The robot tries to move to the **bottom-right corner** (i.e., `grid[m - 1][n - 1]`). The robot can only move either down or right at any point in time.
Given the two integers `m` and `n`, return _the nu... | null | Math,Dynamic Programming,Combinatorics | Medium | 63,64,174,2192 |
414 | hey what's up guys isn't it quite here I do tech accounting stuff I'm twitching YouTube you can check the description for all my information I have Lee code premium problem solutions on my patreon and if you want to reach out to me you can hit me up on disk or to try and get back to everyone this is a problem that I've... | Third Maximum Number | third-maximum-number | Given an integer array `nums`, return _the **third distinct maximum** number in this array. If the third maximum does not exist, return the **maximum** number_.
**Example 1:**
**Input:** nums = \[3,2,1\]
**Output:** 1
**Explanation:**
The first distinct maximum is 3.
The second distinct maximum is 2.
The third distin... | null | Array,Sorting | Easy | 215 |
349 | hello guys my name is Arsenal and welcome back to my channel and today we will be solving a new lead code question that is intersection of two arrays with the help of JavaScript so the question says given to integers array nums one nums to written and intersection of their array each element in the result must be uniqu... | Intersection of Two Arrays | intersection-of-two-arrays | Given two integer arrays `nums1` and `nums2`, return _an array of their intersection_. Each element in the result must be **unique** and you may return the result in **any order**.
**Example 1:**
**Input:** nums1 = \[1,2,2,1\], nums2 = \[2,2\]
**Output:** \[2\]
**Example 2:**
**Input:** nums1 = \[4,9,5\], nums2 = \... | null | Array,Hash Table,Two Pointers,Binary Search,Sorting | Easy | 350,1149,1392,2190,2282 |
173 | Hello Hello Everyone Today Going To Solve - Rider Hello Everyone Today Going To Solve - Rider Hello Everyone Today Going To Solve - Rider Problem Points Problem Will Have To You Have Given Now Edit Class Book And Have Implemented 251 Construction In Which Were Given You Will Be Beat Team And Root Of BSP End Have Time H... | Binary Search Tree Iterator | binary-search-tree-iterator | Implement the `BSTIterator` class that represents an iterator over the **[in-order traversal](https://en.wikipedia.org/wiki/Tree_traversal#In-order_(LNR))** of a binary search tree (BST):
* `BSTIterator(TreeNode root)` Initializes an object of the `BSTIterator` class. The `root` of the BST is given as part of the co... | null | Stack,Tree,Design,Binary Search Tree,Binary Tree,Iterator | Medium | 94,251,281,284,285,1729 |
40 | hello everyone in the previous video in the backtracking series of permutation combinations we have discussed the problem combination sum 1 that is the 39 so in this video we will discuss the problem 40 that is the combination sum 2. so the problem statement is saying given a collection of candidate numbers candidate a... | Combination Sum II | combination-sum-ii | Given a collection of candidate numbers (`candidates`) and a target number (`target`), find all unique combinations in `candidates` where the candidate numbers sum to `target`.
Each number in `candidates` may only be used **once** in the combination.
**Note:** The solution set must not contain duplicate combinations.... | null | Array,Backtracking | Medium | 39 |
235 | hey everyone welcome back and let's write some more neat code today so today we're gonna solve lowest common ancestor of a binary search tree and if you recall a while ago in a video i showed you guys this sheet of the 75 blind problems that have become pretty popular and so this is basically a spreadsheet that i showe... | Lowest Common Ancestor of a Binary Search Tree | lowest-common-ancestor-of-a-binary-search-tree | Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST.
According to the [definition of LCA on Wikipedia](https://en.wikipedia.org/wiki/Lowest_common_ancestor): "The lowest common ancestor is defined between two nodes `p` and `q` as the lowest node in `T` that has bo... | null | Tree,Depth-First Search,Binary Search Tree,Binary Tree | Easy | 236,1190,1780,1790,1816 |
513 | hi everyone welcome back to the channel and today we're going to solve it code daily challenge problem number 5133 find bottom left tree value so it's a really simple problem to solve and we'll first check out the problem statement then we'll look into the approach which you're going to use and towards end we'll see th... | Find Bottom Left Tree Value | find-bottom-left-tree-value | Given the `root` of a binary tree, return the leftmost value in the last row of the tree.
**Example 1:**
**Input:** root = \[2,1,3\]
**Output:** 1
**Example 2:**
**Input:** root = \[1,2,3,4,null,5,6,null,null,7\]
**Output:** 7
**Constraints:**
* The number of nodes in the tree is in the range `[1, 104]`.
* `-... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Medium | null |
328 | so the first node is considered R and second of this country are even and so on so note that the relative order inside both even and Earth should remain three and yeah I could say that you have questions with alternator so they're in the so you could see this link is starting with the order so ordinable with first and ... | 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 |
218 | hello friends today less of the skyline problem so we are given array of the buildings and actually this means the location and the height of all the buildings so we need to first get the outline of all the buildings and finally we output the key point and the key points means the left end point of a horizontal line se... | The Skyline Problem | the-skyline-problem | A city's **skyline** is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and heights of all the buildings, return _the **skyline** formed by these buildings collectively_.
The geometric information of each building is given in the array `buil... | null | Array,Divide and Conquer,Binary Indexed Tree,Segment Tree,Line Sweep,Heap (Priority Queue),Ordered Set | Hard | 699 |
235 | hello everyone my name is alvaro and in this video i will be covering another problem in the blind lead code 75 problem list today we will be doing problem 235 which is called lowest common ancestor of binary search tree this is one of my favorite problems i've never gotten this one asked in my interviews however i thi... | Lowest Common Ancestor of a Binary Search Tree | lowest-common-ancestor-of-a-binary-search-tree | Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST.
According to the [definition of LCA on Wikipedia](https://en.wikipedia.org/wiki/Lowest_common_ancestor): "The lowest common ancestor is defined between two nodes `p` and `q` as the lowest node in `T` that has bo... | null | Tree,Depth-First Search,Binary Search Tree,Binary Tree | Easy | 236,1190,1780,1790,1816 |
1,277 | Hello Hi Everyone Today At 2am Let's Solve All The Problem Is Account Square Samay Tricks With All We The Software Give Employment Matric 60 Have Bank Account All The Square Submit Research Form With All Once So Let's Rock Example We Trick Share Loot Of Three Crush 40 And For Columns Sworn In 2013 Loot Columns And Thro... | Count Square Submatrices with All Ones | largest-multiple-of-three | Given a `m * n` matrix of ones and zeros, return how many **square** submatrices have all ones.
**Example 1:**
**Input:** matrix =
\[
\[0,1,1,1\],
\[1,1,1,1\],
\[0,1,1,1\]
\]
**Output:** 15
**Explanation:**
There are **10** squares of side 1.
There are **4** squares of side 2.
There is **1** square of side 3.... | A number is a multiple of three if and only if its sum of digits is a multiple of three. Use dynamic programming. To find the maximum number, try to maximize the number of digits of the number. Sort the digits in descending order to find the maximum number. | Array,Dynamic Programming,Greedy | Hard | null |
509 | number so Fibonacci numbers by F of n form a sequence called the Fibonacci sequence such that each number is a sum of two preceding ones starting from 0 and 1. so that is f of 0 is 0 and F of 1 is 1. there is starting two numbers so then F of n will be equal to F of n minus 1 plus F of n minus 2 or n greater than 1. th... | Fibonacci Number | inorder-successor-in-bst-ii | The **Fibonacci numbers**, commonly denoted `F(n)` form a sequence, called the **Fibonacci sequence**, such that each number is the sum of the two preceding ones, starting from `0` and `1`. That is,
F(0) = 0, F(1) = 1
F(n) = F(n - 1) + F(n - 2), for n > 1.
Given `n`, calculate `F(n)`.
**Example 1:**
**Input:** n = ... | null | Tree,Binary Search Tree,Binary Tree | Medium | 285 |
1,383 | hi guys welcome to algorithms Made Easy my name is khushboo and in this video we are going to see the question maximum performance of a team you are given two integers n and key and two integer arrays speed and efficiency both are of length n there are an Engineers numbered from 1 to 1 wherein speed of I and efficiency... | Maximum Performance of a Team | number-of-single-divisor-triplets | You are given two integers `n` and `k` and two integer arrays `speed` and `efficiency` both of length `n`. There are `n` engineers numbered from `1` to `n`. `speed[i]` and `efficiency[i]` represent the speed and efficiency of the `ith` engineer respectively.
Choose **at most** `k` different engineers out of the `n` en... | The maximum value of nums.length is very large, but the maximum value of nums[i] is not. Count the number of times each value appears in nums. Brute force through every possible combination of values and count how many single divisor triplets can be made with that combination of values. | Math | Medium | 2301 |
354 | Loot ok hmm thank you MP3 song bhojpuri that if we have of this period is if we have of this period is if we have of this period is that if we go to the smallest line of the smallest bramble of its species then we can further check that who- Which is bigger so that I who- Which is bigger so that I who- Which is bigger ... | Russian Doll Envelopes | russian-doll-envelopes | You are given a 2D array of integers `envelopes` where `envelopes[i] = [wi, hi]` represents the width and the height of an envelope.
One envelope can fit into another if and only if both the width and height of one envelope are greater than the other envelope's width and height.
Return _the maximum number of envelope... | null | Array,Binary Search,Dynamic Programming,Sorting | Hard | 300,2123 |
404 | foreign called sum of left leaves it's easy let's get started given the root of a binary tree return the sum of all left leaves a leaf is a node with no children a left Leaf is a leaf that is the left child of another node example one we have the root node three then 9 20 15 and 7. so here our leaves are 9 15 and 7 bec... | Sum of Left Leaves | sum-of-left-leaves | Given the `root` of a binary tree, return _the sum of all left leaves._
A **leaf** is a node with no children. A **left leaf** is a leaf that is the left child of another node.
**Example 1:**
**Input:** root = \[3,9,20,null,null,15,7\]
**Output:** 24
**Explanation:** There are two left leaves in the binary tree, wit... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Easy | null |
1,377 | foreign welcome back in this video lecture we'll be solving this problem frog position after T seconds so in this problem we have an undirected tree which consists of n vertices numbered from 1 to n so we have a frog here which starts jumping from vertex one in one second a frog jumps from its current vertex to another... | Frog Position After T Seconds | number-of-comments-per-post | Given an undirected tree consisting of `n` vertices numbered from `1` to `n`. A frog starts jumping from **vertex 1**. In one second, the frog jumps from its current vertex to another **unvisited** vertex if they are directly connected. The frog can not jump back to a visited vertex. In case the frog can jump to severa... | null | Database | Easy | null |
68 | all right this is lego problem 68 text justification listed as a hard question so i'll go ahead and read the description given an array of words in a width max width format the text such that each line has exactly maxed with characters and is fully left and right justified you should pack your words in a greedy approac... | Text Justification | text-justification | Given an array of strings `words` and a width `maxWidth`, format the text such that each line has exactly `maxWidth` characters and is fully (left and right) justified.
You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces `' '` when necessary so that ea... | null | Array,String,Simulation | Hard | 1714,2260 |
1,071 | hey guys welcome to a new video in today's video we're going to look at a lead code problem and the problem's name is greatest common deviser of strings so in this question we are given two strings s and t and we can say that t divides s if and only if s is made up of multiple concatenations of T so according to the qu... | 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 |
100 | hello today we'll be working on Elite code 100 same tree our goal is to figure out if two binary trees are the same two trees are the same if they have the same values and structure any deviation means that the trees are not the same so the line of thinking for this is pretty straightforward if two trees are the same t... | 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 |
139 | Ajay Ko Hello friends welcome to my channel Library - Yoga Kiya Bina Channel Please Library - Yoga Kiya Bina Channel Please Library - Yoga Kiya Bina Channel Please subscribe and press Bell Icon Flat Tubelight Film Tubelight Problem Solve What is the question of be I am I to give another subscribe request of the diction... | 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 |
983 | hello everyone welcome to my channel i am shankar dhyan a final student of computer science and i usually make coding videos and placement related videos so that you can do good in your interviews and like without wasting any time let's get started hello everyone so this is the last video for this week that is dynamic ... | Minimum Cost For Tickets | validate-stack-sequences | You have planned some train traveling one year in advance. The days of the year in which you will travel are given as an integer array `days`. Each day is an integer from `1` to `365`.
Train tickets are sold in **three different ways**:
* a **1-day** pass is sold for `costs[0]` dollars,
* a **7-day** pass is sold... | null | Array,Stack,Simulation | Medium | null |
1,720 | Loot Hello Friends Today in this video will discuss three easy problems from its state with me I will go through all problems from Band Safar problem is this trick to dog which is 800 to 1000 which country consists of number dialed in Delhi in the middle of is equal to A good care of plus number 2573 ok to inko dare re... | Decode XORed Array | crawler-log-folder | There is a **hidden** integer array `arr` that consists of `n` non-negative integers.
It was encoded into another integer array `encoded` of length `n - 1`, such that `encoded[i] = arr[i] XOR arr[i + 1]`. For example, if `arr = [1,0,2,1]`, then `encoded = [1,2,3]`.
You are given the `encoded` array. You are also give... | Simulate the process but don’t move the pointer beyond the main folder. Simulate the process but don’t move the pointer beyond the main folder. | Array,String,Stack | Easy | 682,874 |
322 | what's up everybody today we're going to be talking about lead code problem 322 coin change so we'll start briefly with the problem description if you want to skip the problem description it will be in the description below um so we're given some set of denominational coins you know in this example we are given a one c... | Coin Change | coin-change | You are given an integer array `coins` representing coins of different denominations and an integer `amount` representing a total amount of money.
Return _the fewest number of coins that you need to make up that amount_. If that amount of money cannot be made up by any combination of the coins, return `-1`.
You may a... | null | Array,Dynamic Programming,Breadth-First Search | Medium | 1025,1393,2345 |
138 | Hua Hai How To Play List With Random Powder And That Ali Short Length Name Is Governors That Is Not Contain Some Medicinal Random Points To Point To In Node In The List And Null Constructor DP Yadav List The Subscribe Nuvve David To Subscribe Notes For The End of the road to the co subscribe to a man of the pointer fin... | 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 |
34 | hello everybody and welcome to another episode of your favorite algorithms channel my name is Ryan powers and today I'm gonna be taking you through leet code 34 find first and last position of element in sorted array now I must admit I am a little sick so hopefully I'm not going to be sniffling my way through this enti... | Find First and Last Position of Element in Sorted Array | find-first-and-last-position-of-element-in-sorted-array | Given an array of integers `nums` sorted in non-decreasing order, find the starting and ending position of a given `target` value.
If `target` is not found in the array, return `[-1, -1]`.
You must write an algorithm with `O(log n)` runtime complexity.
**Example 1:**
**Input:** nums = \[5,7,7,8,8,10\], target = 8
*... | null | Array,Binary Search | Medium | 278,2165,2210 |
238 | question 238 product of array except self given an integer array nums return an array answer such that answer i is equal to the product of all the elements of nums except nums at i the product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer is guaranteed to fit in a 32-bit integer is guaranteed... | Product of Array Except Self | product-of-array-except-self | Given an integer array `nums`, return _an array_ `answer` _such that_ `answer[i]` _is equal to the product of all the elements of_ `nums` _except_ `nums[i]`.
The product of any prefix or suffix of `nums` is **guaranteed** to fit in a **32-bit** integer.
You must write an algorithm that runs in `O(n)` time and without... | null | Array,Prefix Sum | Medium | 42,152,265,2267 |
309 | hey hello there let's talk about today's liquidity challenge question best of time to buy and sell stock with cooldown say that we have closely monitored the daily stock price change for a single stock for a number days and now we've been presented with a chance to take a time travel machine and go back to when you all... | Best Time to Buy and Sell Stock with Cooldown | best-time-to-buy-and-sell-stock-with-cooldown | You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day.
Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times) with the following restrictions:
* After you sell your stock, yo... | null | Array,Dynamic Programming | Medium | 121,122 |
1,311 | hello so today you are doing this weekly contest 117 I'm going to do right now the third problem get watching videos by your friends and the problem essentially says that we have n people each person has a unique ID that is between 0 and n minus 1 and we get to erase the list of watchit videos for each person there is ... | Get Watched Videos by Your Friends | largest-magic-square | There are `n` people, each person has a unique _id_ between `0` and `n-1`. Given the arrays `watchedVideos` and `friends`, where `watchedVideos[i]` and `friends[i]` contain the list of watched videos and the list of friends respectively for the person with `id = i`.
Level **1** of videos are all watched videos by your... | Check all squares in the matrix and find the largest one. | Array,Matrix,Prefix Sum | Medium | 870 |
213 | Tomorrow morning, friends, welcome to the new video of line 7548 and today's find our husband, ninth day of this, we are growing up and this is number two, we were number one, shot a second was difficult, this week ago, exact, a week ago, we did the house. Used to have problems and knowing this is very-very important. ... | House Robber II | house-robber-ii | You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are **arranged in a circle.** That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have a security system connected, and **it will automatical... | Since House[1] and House[n] are adjacent, they cannot be robbed together. Therefore, the problem becomes to rob either House[1]-House[n-1] or House[2]-House[n], depending on which choice offers more money. Now the problem has degenerated to the House Robber, which is already been solved. | Array,Dynamic Programming | Medium | 198,256,276,337,600,656 |
1,710 | hey everybody this is larry this is day of the first day of july leeco dairy challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's farm so yeah i think my face is blocking this uh here-ish blocking this uh here-ish blocking this uh here-ish but i have an 821 ... | 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 |
1,648 | hey everybody this is larry this is me going with q3 of the reason weekly contest 214 self-diminishing while you'd call it self-diminishing while you'd call it self-diminishing while you'd call it boss uh so this one was i think the hardest problem in the contest let me do a quick refresh to see how many people solved ... | Sell Diminishing-Valued Colored Balls | minimum-insertions-to-balance-a-parentheses-string | You have an `inventory` of different colored balls, and there is a customer that wants `orders` balls of **any** color.
The customer weirdly values the colored balls. Each colored ball's value is the number of balls **of that color** you currently have in your `inventory`. For example, if you own `6` yellow balls, the... | Use a stack to keep opening brackets. If you face single closing ')' add 1 to the answer and consider it as '))'. If you have '))' with empty stack, add 1 to the answer, If after finishing you have x opening remaining in the stack, add 2x to the answer. | String,Stack,Greedy | Medium | 2095 |
901 | Hey everyone, today we are going to start a new playlist of ours. Stack is okay, it is a very popular topic too, many questions come on it in interviews. Okay, I have an interview in the phase in which star related questions came. Okay, and I will let you know about the track. It's all about Pushpa and top right. So le... | Online Stock Span | advantage-shuffle | Design an algorithm that collects daily price quotes for some stock and returns **the span** of that stock's price for the current day.
The **span** of the stock's price in one day is the maximum number of consecutive days (starting from that day and going backward) for which the stock price was less than or equal to ... | null | Array,Greedy,Sorting | Medium | null |
1,446 | hey everybody this is larry this is day three of the november elite code daddy challenge hit the like button hit the subscribe button join me on discord make sure you go well if you're american and let's get i started on today's prom consecutive characters give the string s the power of the string is the max length of ... | Consecutive Characters | angle-between-hands-of-a-clock | The **power** of the string is the maximum length of a non-empty substring that contains only one unique character.
Given a string `s`, return _the **power** of_ `s`.
**Example 1:**
**Input:** s = "leetcode "
**Output:** 2
**Explanation:** The substring "ee " is of length 2 with the character 'e' only.
**Example ... | The tricky part is determining how the minute hand affects the position of the hour hand. Calculate the angles separately then find the difference. | Math | Medium | null |
1,263 | leet code problem memo moves to move a box is about pushing a box in a grid we're even the description of a grid with some cells being once forbidden and some are empty also there is some starting position of a player human that is in that grid box and the target location every move is pushing a box one cell to one fou... | Minimum Moves to Move a Box to Their Target Location | number-of-dice-rolls-with-target-sum | A storekeeper is a game in which the player pushes boxes around in a warehouse trying to get them to target locations.
The game is represented by an `m x n` grid of characters `grid` where each element is a wall, floor, or box.
Your task is to move the box `'B'` to the target position `'T'` under the following rules:... | Use dynamic programming. The states are how many dice are remaining, and what sum total you have rolled so far. | Dynamic Programming | Medium | 1901,2155 |
1,489 | hey everyone welcome back and let's write some more neat code today so today let's solve the problem find critical and pseudo-critical edges in a minimum and pseudo-critical edges in a minimum and pseudo-critical edges in a minimum spanning tree this problem is definitely a hard one and that's because it involves quite... | Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree | pizza-with-3n-slices | Given a weighted undirected connected graph with `n` vertices numbered from `0` to `n - 1`, and an array `edges` where `edges[i] = [ai, bi, weighti]` represents a bidirectional and weighted edge between nodes `ai` and `bi`. A minimum spanning tree (MST) is a subset of the graph's edges that connects all vertices withou... | By studying the pattern of the operations, we can find out that the problem is equivalent to: Given an integer array with size 3N, select N integers with maximum sum and any selected integers are not next to each other in the array. The first one in the array is considered next to the last one in the array. Use Dynamic... | Array,Dynamic Programming,Greedy,Heap (Priority Queue) | Hard | null |
458 | hi guys welcome to our new video where we will be discussing about one of the problem from leap code and the problem statements name is poor pegs the difficulty level for this question is hard now let's first understand the question and the problem constraints given to us then we'll try to develop an intuition and slow... | Poor Pigs | poor-pigs | There are `buckets` buckets of liquid, where **exactly one** of the buckets is poisonous. To figure out which one is poisonous, you feed some number of (poor) pigs the liquid to see whether they will die or not. Unfortunately, you only have `minutesToTest` minutes to determine which bucket is poisonous.
You can feed t... | What if you only have one shot? Eg. 4 buckets, 15 mins to die, and 15 mins to test. How many states can we generate with x pigs and T tests? Find minimum x such that (T+1)^x >= N | Math,Dynamic Programming,Combinatorics | Hard | null |
20 | hi everybody i hope you all are doing really well thank you so much for dropping by my channel today if you directly want to dive into today's topic i will leave the time stamp somewhere on the screen here but if you want to know a little bit about me my name is pratik shabacrola i am a software engineer and have been ... | Valid Parentheses | valid-parentheses | Given a string `s` containing just the characters `'('`, `')'`, `'{'`, `'}'`, `'['` and `']'`, determine if the input string is valid.
An input string is valid if:
1. Open brackets must be closed by the same type of brackets.
2. Open brackets must be closed in the correct order.
3. Every close bracket has a corres... | An interesting property about a valid parenthesis expression is that a sub-expression of a valid expression should also be a valid expression. (Not every sub-expression) e.g.
{ { } [ ] [ [ [ ] ] ] } is VALID expression
[ [ [ ] ] ] is VALID sub-expression
{ } [ ] is VALID sub-express... | String,Stack | Easy | 22,32,301,1045,2221 |
1,685 | hello guys and welcome back to lead Logics this is the sum of absolute differences in a sorted array problem and it is a lead code medium and the number for this is 1685 so in this problem you are given with an integer array nums which is already in a sorted order in a non- decreasing sorted order in a non- decreasing ... | Sum of Absolute Differences in a Sorted Array | stone-game-v | You are given an integer array `nums` sorted in **non-decreasing** order.
Build and return _an integer array_ `result` _with the same length as_ `nums` _such that_ `result[i]` _is equal to the **summation of absolute differences** between_ `nums[i]` _and all the other elements in the array._
In other words, `result[i... | We need to try all possible divisions for the current row to get the max score. As calculating all possible divisions will lead us to calculate some sub-problems more than once, we need to think of dynamic programming. | Array,Math,Dynamic Programming,Game Theory | Hard | 909,1240,1522,1617,1788,1808,2002,2156 |
352 | Hello friends welcome back to my channel the number of interval problem is 352 it comes in hand category but I think it is of medium level not so much Bihar so the problem tells that given are data stream input of non negative wait from a till n Summary D number of scene so far he is on the list of this short interval ... | Data Stream as Disjoint Intervals | data-stream-as-disjoint-intervals | Given a data stream input of non-negative integers `a1, a2, ..., an`, summarize the numbers seen so far as a list of disjoint intervals.
Implement the `SummaryRanges` class:
* `SummaryRanges()` Initializes the object with an empty stream.
* `void addNum(int value)` Adds the integer `value` to the stream.
* `int... | null | Binary Search,Design,Ordered Set | Hard | 228,436,715 |
11 | well i'll be covering question 11 container was must water in this question we want to return the maximum amount of water a container can store so what is a container if we randomly pick any um wireless i'm gonna pick this guy in the sky so container is right here right it's how much water we can fill and what is the e... | Container With Most Water | container-with-most-water | You are given an integer array `height` of length `n`. There are `n` vertical lines drawn such that the two endpoints of the `ith` line are `(i, 0)` and `(i, height[i])`.
Find two lines that together with the x-axis form a container, such that the container contains the most water.
Return _the maximum amount of water... | The aim is to maximize the area formed between the vertical lines. The area of any container is calculated using the shorter line as length and the distance between the lines as the width of the rectangle.
Area = length of shorter vertical line * distance between lines
We can definitely get the maximum width ... | Array,Two Pointers,Greedy | Medium | 42 |
1,252 | Jai Hind in this video Gyan Question Number Protein Vijay Sales with Old Values in Protein Vijay Sales with Old Values in Protein Vijay Sales with Old Values in Matrix So Let's Move to the Questions on Pure Question Sharing Eminem Mintu and Matric Zinc Slice 200 Resources Where is India Is It Is Equal to Arry Co ... | Cells with Odd Values in a Matrix | break-a-palindrome | There is an `m x n` matrix that is initialized to all `0`'s. There is also a 2D array `indices` where each `indices[i] = [ri, ci]` represents a **0-indexed location** to perform some increment operations on the matrix.
For each location `indices[i]`, do **both** of the following:
1. Increment **all** the cells on ro... | How to detect if there is impossible to perform the replacement? Only when the length = 1. Change the first non 'a' character to 'a'. What if the string has only 'a'? Change the last character to 'b'. | String,Greedy | Medium | null |
137 | hey everyone so let's do this problem from scratch this is a bit more manipulation problem single number two and we are going to do it in C plus as it has perfect uh integer storage in 32-bit actually if you do the same logic in Python it might get different answer because this is kind of python has huge capacity of in... | Single Number II | single-number-ii | Given an integer array `nums` where every element appears **three times** except for one, which appears **exactly once**. _Find the single element and return it_.
You must implement a solution with a linear runtime complexity and use only constant extra space.
**Example 1:**
**Input:** nums = \[2,2,3,2\]
**Output:**... | null | Array,Bit Manipulation | Medium | 136,260 |
1,475 | this late code question is called Final prices with a special discount in a shop so we are given an integer array called prices where the E element of prices is the price of the E item in a shop so there is a special discount for items in the shop so if you buy the I item then you will receive a discount equivalent to ... | Final Prices With a Special Discount in a Shop | maximum-sum-bst-in-binary-tree | You are given an integer array `prices` where `prices[i]` is the price of the `ith` item in a shop.
There is a special discount for items in the shop. If you buy the `ith` item, then you will receive a discount equivalent to `prices[j]` where `j` is the minimum index such that `j > i` and `prices[j] <= prices[i]`. Oth... | Create a datastructure with 4 parameters: (sum, isBST, maxLeft, minLeft). In each node compute theses parameters, following the conditions of a Binary Search Tree. | Dynamic Programming,Tree,Depth-First Search,Binary Search Tree,Binary Tree | Hard | null |
43 | I will come back and number 43 multiply strings we were given two strings which were integer numbers and output product and we are not allowed to use those big integers are great I'm not even know that anyway we have to do the old-fashioned way to do the old-fashioned way to do the old-fashioned way to do multiplicatio... | Multiply Strings | multiply-strings | Given two non-negative integers `num1` and `num2` represented as strings, return the product of `num1` and `num2`, also represented as a string.
**Note:** You must not use any built-in BigInteger library or convert the inputs to integer directly.
**Example 1:**
**Input:** num1 = "2", num2 = "3"
**Output:** "6"
**Ex... | null | Math,String,Simulation | Medium | 2,66,67,415 |
476 | Hello hello guys welcome back to years and this video will see the number complement problem system digit code for the match challenge so let's look at the problem statement in this problem giver number and you need to find the element of December and this problem number indicates that You Need To Lips Se Withra 080221... | 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 |
149 | hello friends so today in this video we're gonna discuss another problem from lead what the problem name is maximum point on a line so this problem is actually suggested by one of my subscribers so if you also have some problems you can mention on a convox i will try to solve them as soon as possible so the problem is ... | 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 |
127 | today's problem is word letter which is a hard problem in lead code basically you have to go the whole description the whole uh description states that you have to go from the word hit tell cop using the words given in the word list array and each transformation costs us one generator one unit basically the first you w... | 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 |
208 | hello hi everyone welcome back to the series so in this video lecture we'll be learning to implement this dry data structure which is the prefix tree so this problem Implement try contains the implementation of the dry data structure so it contains we have to implement a class try which contains a Constructor try which... | 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 |
554 | hello guys welcome back to the channel today we are solving another lead code problem that is 554 brick wall before jumping into the solution I would highly recommend you should read the problem statement on your own and give at least 15 to 30 minutes before jumping into the solution let's get right into it what proble... | Brick Wall | brick-wall | There is a rectangular brick wall in front of you with `n` rows of bricks. The `ith` row has some number of bricks each of the same height (i.e., one unit) but they can be of different widths. The total width of each row is the same.
Draw a vertical line from the top to the bottom and cross the least bricks. If your l... | null | Array,Hash Table | Medium | 2322 |
37 | hey um how's it going so today we're gonna do leeco 37 sudoku silver to write a program to solve sudoku puzzle by filling the empty cells of sudoku solution must satisfy all of their following rules each of the digits one to nine must exactly once appeared in each row and exactly ones in each column in exactly ones in ... | Sudoku Solver | sudoku-solver | Write a program to solve a Sudoku puzzle by filling the empty cells.
A sudoku solution must satisfy **all of the following rules**:
1. Each of the digits `1-9` must occur exactly once in each row.
2. Each of the digits `1-9` must occur exactly once in each column.
3. Each of the digits `1-9` must occur exactly onc... | null | Array,Backtracking,Matrix | Hard | 36,1022 |
442 | hey guys how's everything going this is jayster uh today let's take a look at 442 find all duplicates an array given an array of integers some of the elements appear twice n is the size of the array some elements appear twice and others appear once and all the elements appear twice in this array well i think i did some... | Find All Duplicates in an Array | find-all-duplicates-in-an-array | Given an integer array `nums` of length `n` where all the integers of `nums` are in the range `[1, n]` and each integer appears **once** or **twice**, return _an array of all the integers that appears **twice**_.
You must write an algorithm that runs in `O(n)` time and uses only constant extra space.
**Example 1:**
... | null | Array,Hash Table | Medium | 448 |
1,706 | Hello friends today I'm going to solve lit code problem number 1706 where will the ball fall it's a medium uh level difficulty and this came on daily uh challenge only code so what's the problem let's see um so we are given a grade two by two grid and we are given um n number of balls so the number of ball is equals to... | Where Will the Ball Fall | min-cost-to-connect-all-points | You have a 2-D `grid` of size `m x n` representing a box, and you have `n` balls. The box is open on the top and bottom sides.
Each cell in the box has a diagonal board spanning two corners of the cell that can redirect a ball to the right or to the left.
* A board that redirects the ball to the right spans the top... | Connect each pair of points with a weighted edge, the weight being the manhattan distance between those points. The problem is now the cost of minimum spanning tree in graph with above edges. | Array,Union Find,Minimum Spanning Tree | Medium | 2287 |
84 | guys welcome to the tech grant today we are going to solve the problem of largest rectangle in histogram do like subscribe and share the video subscribe to the channel to get further notification so the problem is given n non negative integer representing the histograms bar where we have the width of each bar is one fi... | Largest Rectangle in Histogram | largest-rectangle-in-histogram | Given an array of integers `heights` representing the histogram's bar height where the width of each bar is `1`, return _the area of the largest rectangle in the histogram_.
**Example 1:**
**Input:** heights = \[2,1,5,6,2,3\]
**Output:** 10
**Explanation:** The above is a histogram where width of each bar is 1.
The l... | null | Array,Stack,Monotonic Stack | Hard | 85,1918 |
926 | welcome to august leco challenge today's problem is flip string to monotone increasing a binary string is monotone increasing if it consists of some number of zeros possibly none followed by some number of ones also possibly none you are given a binary string s of zeros and ones you can flip each index to zero to one o... | Flip String to Monotone Increasing | find-and-replace-pattern | A binary string is monotone increasing if it consists of some number of `0`'s (possibly none), followed by some number of `1`'s (also possibly none).
You are given a binary string `s`. You can flip `s[i]` changing it from `0` to `1` or from `1` to `0`.
Return _the minimum number of flips to make_ `s` _monotone increa... | null | Array,Hash Table,String | Medium | null |
110 | yo what's up everybody how's it going so guys today we are going to solve the another coolest problem which is balance the planetary yeah you listen right we have to balance the pantry let me just open my uh this thing so i will help you to teach very easily using pen so it worked like pen paper which i really like all... | 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 |
502 | So how if you all do not want to be taught well then we will try to learn these things and whoever sees the pattern in it will absorb it and remember the pattern. If we say pattern then it means on this pattern, we will see more questions of this type and we will try. Okay. OK, you have to read carefully. OK, Projects ... | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.