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
143
today i'm gonna show you how to solve legal question 143 reorder list it's another linked list issue you are giving the head of our singly linked list basically like one two three four the list can be represented like this we order this list to l0 ln basically the first one is the first value and the second one is the ...
Reorder List
reorder-list
You are given the head of a singly linked-list. The list can be represented as: L0 -> L1 -> ... -> Ln - 1 -> Ln _Reorder the list to be on the following form:_ L0 -> Ln -> L1 -> Ln - 1 -> L2 -> Ln - 2 -> ... You may not modify the values in the list's nodes. Only nodes themselves may be changed. **Example 1:** **...
null
Linked List,Two Pointers,Stack,Recursion
Medium
2216
1,647
hi there this side viewing so welcome again we are solving one more question and this is questions from lead code daily practice question and the question name is uh minimum deletion to make the character frequency unique so the question name is already uh explaining what we are going to do we have to just uh unique we...
Minimum Deletions to Make Character Frequencies Unique
can-convert-string-in-k-moves
A string `s` is called **good** if there are no two different characters in `s` that have the same **frequency**. Given a string `s`, return _the **minimum** number of characters you need to delete to make_ `s` _**good**._ The **frequency** of a character in a string is the number of times it appears in the string. F...
Observe that shifting a letter x times has the same effect of shifting the letter x + 26 times. You need to check whether k is large enough to cover all shifts with the same remainder after modulo 26.
Hash Table,String
Medium
null
838
hey everyone welcome back and let's write some more neat code today so today let's solve the problem push dominoes there are n dominoes in a line and they're placed vertically but some of them could be either leaning to the left or leaning to the right and after each second passes each domino that is you know leaning i...
Push Dominoes
design-linked-list
There are `n` dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to the left or to the right. After each second, each domino that is falling to the left pushes the adjacent domino on the left. Similarly, the dominoes falling to the righ...
null
Linked List,Design
Medium
1337
948
welcome to october's leco challenge today's problem is bag of tokens you have an initial power p an initial score of zero and a bag of tokens where tokens i is the value of the i token so we have these tokens and they have some sort of value now our goal is to maximize our total score by potentially playing each token ...
Bag of Tokens
sort-an-array
You have an initial **power** of `power`, an initial **score** of `0`, and a bag of `tokens` where `tokens[i]` is the value of the `ith` token (0-indexed). Your goal is to maximize your total **score** by potentially playing each token in one of two ways: * If your current **power** is at least `tokens[i]`, you may...
null
Array,Divide and Conquer,Sorting,Heap (Priority Queue),Merge Sort,Bucket Sort,Radix Sort,Counting Sort
Medium
null
1,845
Hi Everyone Welcome Back to a New Video Today Lead Code Daily Challenge Seat Reservation Manager This is a medium level question so in this question we will be assigned n seeds and two seeds will be numbered starting from one and it will continue till a Now we Will be having a seat manager class in that class we will h...
Seat Reservation Manager
largest-submatrix-with-rearrangements
Design a system that manages the reservation state of `n` seats that are numbered from `1` to `n`. Implement the `SeatManager` class: * `SeatManager(int n)` Initializes a `SeatManager` object that will manage `n` seats numbered from `1` to `n`. All seats are initially available. * `int reserve()` Fetches the **sm...
For each column, find the number of consecutive ones ending at each position. For each row, sort the cumulative ones in non-increasing order and "fit" the largest submatrix.
Array,Greedy,Sorting,Matrix
Medium
695
138
Loot ke guys welcome back to my channel in this video we are going to solve copy list with random point so what is given statement year erring list of plant and is given subsidize food content additional random point meaning which put point to android hindi list and tap Constructed a copy of delete deep copy should con...
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
1,029
Hello guys welcome to our interesting video in this series according to this call to cities safe during this time and let's get started 21 A company planning to interview two and people give and request and school staff is equal to two vectors sized together for its elements representing the The Cost of Flying Upstairs...
Two City Scheduling
vertical-order-traversal-of-a-binary-tree
A company is planning to interview `2n` people. Given the array `costs` where `costs[i] = [aCosti, bCosti]`, the cost of flying the `ith` person to city `a` is `aCosti`, and the cost of flying the `ith` person to city `b` is `bCosti`. Return _the minimum cost to fly every person to a city_ such that exactly `n` people...
null
Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Hard
null
389
hey everybody this is Larry this is day 25th of the weekly what month is this September daily challenge uh hit the like button hit the Subscribe button drop me on Discord let me know what you think about today's farm so I just finished oh excuse me I just finished a 48 hour fast just a quick one uh and during that I ju...
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
374
hey everyone welcome back to our late code study plan let's tackle next problem 374 guess number higher or lower consider we have two players player one and player two hides a number called pick and we need to guess as a player one in certain number of attempts what the pick is in this example n is equal to 10 meaning ...
Guess Number Higher or Lower
guess-number-higher-or-lower
We are playing the Guess Game. The game is as follows: I pick a number from `1` to `n`. You have to guess which number I picked. Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess. You call a pre-defined API `int guess(int num)`, which returns three possible re...
null
Binary Search,Interactive
Easy
278,375,658
208
foreign level question and it's a very popular question as you can see from the likes so let's read the problem statement a try pronoun just try or a prefix tree is a tree data structure used to efficiently store and retrieve keys in a data set of strings so there are various applications of this data structure such as...
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
153
hey hello there uh let's talk about this liquidity challenge question find minimum in a rotated sorted array too suppose that we have an array that's sorted in the ascending order and now this array has been rotated around some pivot point that's unknown to us uh looking at the concrete example array this is the origin...
Find Minimum in Rotated Sorted Array
find-minimum-in-rotated-sorted-array
Suppose an array of length `n` sorted in ascending order is **rotated** between `1` and `n` times. For example, the array `nums = [0,1,2,4,5,6,7]` might become: * `[4,5,6,7,0,1,2]` if it was rotated `4` times. * `[0,1,2,4,5,6,7]` if it was rotated `7` times. Notice that **rotating** an array `[a[0], a[1], a[2], ....
Array was originally in ascending order. Now that the array is rotated, there would be a point in the array where there is a small deflection from the increasing sequence. eg. The array would be something like [4, 5, 6, 7, 0, 1, 2]. You can divide the search space into two and see which direction to go. Can you think ...
Array,Binary Search
Medium
33,154
430
hey what's up guys babybear4812 coming at you one more time today we're doing another cool problem well i think it's cool uh i think most of them are cool not all of them but most of them uh problem 430 flatten a multi-level multi-level multi-level doubly linked list so in this problem we're given a doubly linked list ...
Flatten a Multilevel Doubly Linked List
flatten-a-multilevel-doubly-linked-list
You are given a doubly linked list, which contains nodes that have a next pointer, a previous pointer, and an additional **child pointer**. This child pointer may or may not point to a separate doubly linked list, also containing these special nodes. These child lists may have one or more children of their own, and so ...
null
null
Medium
null
834
Ajay Ko Torch Light Welcome Back Pade Hai This Problem List Code 84 Some of Distance in This Problem and Decision Related to Graph Problem Statement Notes of Loop 007 Connect Note Se Zara Play List and Subscribe Small Distance Between Noida and Rest of the Distances Subscribe Now to 9 I show you some confided with exam...
Sum of Distances in Tree
ambiguous-coordinates
There is an undirected connected tree with `n` nodes labeled from `0` to `n - 1` and `n - 1` edges. You are given the integer `n` and the array `edges` where `edges[i] = [ai, bi]` indicates that there is an edge between nodes `ai` and `bi` in the tree. Return an array `answer` of length `n` where `answer[i]` is the s...
null
String,Backtracking
Medium
null
735
hello friends today last of the astronaut collision problem they first see the statement we are given array astronauts of integers representing estrin asteroids in a row for each astral road the absolute value represents his size and the site represents its direction party means meaning writing negative meaning left th...
Asteroid Collision
asteroid-collision
We are given an array `asteroids` of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed. Find out the state of the asteroids after all collisio...
Say a row of asteroids is stable. What happens when a new asteroid is added on the right?
Array,Stack
Medium
605,2245,2317
303
foreign immutable let's read the question given an integer array Norms it handles multiple queries of the following type calculate the sum of the elements of nums between indices left and right in laser where left equal to less than or equal to right so implement the array norms they are given an integer and we are giv...
Range Sum Query - Immutable
range-sum-query-immutable
Given an integer array `nums`, handle multiple queries of the following type: 1. Calculate the **sum** of the elements of `nums` between indices `left` and `right` **inclusive** where `left <= right`. Implement the `NumArray` class: * `NumArray(int[] nums)` Initializes the object with the integer array `nums`. * ...
null
Array,Design,Prefix Sum
Easy
304,307,325
980
Hello hello everyone welcome to the second aapne bilkul channel subscribe ko maximum number of world channel ko subscribe Video then subscribe to the Video then voice mail solution intermediate let's move with oo are unique pass veer lead 98100 grams paneer wave subscribe trident subscribe our Subscribe What is the Mea...
Unique Paths III
find-the-shortest-superstring
You are given an `m x n` integer array `grid` where `grid[i][j]` could be: * `1` representing the starting square. There is exactly one starting square. * `2` representing the ending square. There is exactly one ending square. * `0` representing empty squares we can walk over. * `-1` representing obstacles tha...
null
Array,String,Dynamic Programming,Bit Manipulation,Bitmask
Hard
null
144
so today i want to talk about create reversal and as you know trade reversal is basically moving on a tree between nodes through different edges and if any of this terminologies does not make sense to let me know in the comment section and be happy to explain them in more detail in an interview setting there are three ...
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
312
hey everyone welcome back and let's write some more neat code today so today let's solve burst balloons and this problem has really earned that category of being a hard problem so this is going to be another dynamic programming problem and we're going to solve it with the optimal solution which is going to be big o of ...
Burst Balloons
burst-balloons
You are given `n` balloons, indexed from `0` to `n - 1`. Each balloon is painted with a number on it represented by an array `nums`. You are asked to burst all the balloons. If you burst the `ith` balloon, you will get `nums[i - 1] * nums[i] * nums[i + 1]` coins. If `i - 1` or `i + 1` goes out of bounds of the array, ...
null
Array,Dynamic Programming
Hard
1042
74
hey what's up guys this is chung here again so actually i want to briefly talk about today's daily challenge problem which is number 74 search or 2d matrix you know so i think it's a okay it's a medium problem right so basically you're given like uh examples of m times n matrix right a 2d matrix and this matrix has the...
Search a 2D Matrix
search-a-2d-matrix
You are given an `m x n` integer matrix `matrix` with the following two properties: * Each row is sorted in non-decreasing order. * The first integer of each row is greater than the last integer of the previous row. Given an integer `target`, return `true` _if_ `target` _is in_ `matrix` _or_ `false` _otherwise_. ...
null
Array,Binary Search,Matrix
Medium
240
1,002
of string made only from lower lowercase letters return a list of all characters that shows up in all strings within the list including duplicates for example if a character occurs three times you know all strings but not four times you need to include the character three times in the final answer you may return the an...
Find Common Characters
maximum-width-ramp
Given a string array `words`, return _an array of all characters that show up in all strings within the_ `words` _(including duplicates)_. You may return the answer in **any order**. **Example 1:** **Input:** words = \["bella","label","roller"\] **Output:** \["e","l","l"\] **Example 2:** **Input:** words = \["cool"...
null
Array,Stack,Monotonic Stack
Medium
null
252
what's gonna buddy welcome to leak a passing solution 252 many rooms so if a new here will come be sure to check my personal website nanny Plata calm there are a lot of coding projects you know so articles that might be helpful to you alright so my first of all my poetry since I do not have a premium account so I have ...
Meeting Rooms
meeting-rooms
Given an array of meeting time `intervals` where `intervals[i] = [starti, endi]`, determine if a person could attend all meetings. **Example 1:** **Input:** intervals = \[\[0,30\],\[5,10\],\[15,20\]\] **Output:** false **Example 2:** **Input:** intervals = \[\[7,10\],\[2,4\]\] **Output:** true **Constraints:** * ...
null
Array,Sorting
Easy
56,253
103
all right what's up guys we're doing binary zigzag level traversal top interview questions medium set binary tree question number two so given the root binary tree return the zigzag level or traversal with nodes values so for the first level you want to go left to right then right to left and left to right all right an...
Binary Tree Zigzag Level Order Traversal
binary-tree-zigzag-level-order-traversal
Given the `root` of a binary tree, return _the zigzag level order traversal of its nodes' values_. (i.e., from left to right, then right to left for the next level and alternate between). **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[\[3\],\[20,9\],\[15,7\]\] **Example 2:** **Input:** roo...
null
Tree,Breadth-First Search,Binary Tree
Medium
102
746
hey everyone welcome back and today I'll be doing another lead code problem seven four six minimum cost climbing stair this is an easy one and a very similar problem or exactly the same problem you can say uh to the 70 climbing stair but in this problem we are just only going to return the minimum cost of the climbing ...
Min Cost Climbing Stairs
prefix-and-suffix-search
You are given an integer array `cost` where `cost[i]` is the cost of `ith` step on a staircase. Once you pay the cost, you can either climb one or two steps. You can either start from the step with index `0`, or the step with index `1`. Return _the minimum cost to reach the top of the floor_. **Example 1:** **Input...
For a word like "test", consider "#test", "t#test", "st#test", "est#test", "test#test". Then if we have a query like prefix = "te", suffix = "t", we can find it by searching for something we've inserted starting with "t#te".
String,Design,Trie
Hard
211
31
in this video we're going to take a look at a legal problem called nest permutation so implement the nest permutation function which rearranges numbers into the lexicographically nest greater permutation of numbers so if such an arrangement is not possible where let's say we have a situation where we have the maximum p...
Next Permutation
next-permutation
A **permutation** of an array of integers is an arrangement of its members into a sequence or linear order. * For example, for `arr = [1,2,3]`, the following are all the permutations of `arr`: `[1,2,3], [1,3,2], [2, 1, 3], [2, 3, 1], [3,1,2], [3,2,1]`. The **next permutation** of an array of integers is the next le...
null
Array,Two Pointers
Medium
46,47,60,267,1978
96
hello everyone i'm young first welcome to my channel this is the series about the self mocha technical interview in english today in this episode we will to solve any problem of little code so let's start today the difficulty is a medium so i think we should resolve this problem within 20 minutes in a interview so let'...
Unique Binary Search Trees
unique-binary-search-trees
Given an integer `n`, return _the number of structurally unique **BST'**s (binary search trees) which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`. **Example 1:** **Input:** n = 3 **Output:** 5 **Example 2:** **Input:** n = 1 **Output:** 1 **Constraints:** * `1 <= n <= 19`
null
Math,Dynamic Programming,Tree,Binary Search Tree,Binary Tree
Medium
95
1,657
hello and welcome to another video in this video we're going to be working on determine if two strings are Clos and in the problem two strings are considered close if you can attain one from the other using the following operations one swap any two existing characters so swap their location and two transform every occu...
Determine if Two Strings Are Close
find-the-winner-of-an-array-game
Two strings are considered **close** if you can attain one from the other using the following operations: * Operation 1: Swap any two **existing** characters. * For example, `abcde -> aecdb` * Operation 2: Transform **every** occurrence of one **existing** character into another **existing** character, and d...
If k ≥ arr.length return the max element of the array. If k < arr.length simulate the game until a number wins k consecutive games.
Array,Simulation
Medium
null
35
one so today I'm here to solve this search insert position problem it's a lead code daily um and we have been given a sorted array of distinct integers and a Target value we have to return the index if the target is found if not return the index where it would be if it were inserted in order you must write an algorithm...
Search Insert Position
search-insert-position
Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with `O(log n)` runtime complexity. **Example 1:** **Input:** nums = \[1,3,5,6\], target = 5 **Output:** 2 **Exa...
null
Array,Binary Search
Easy
278
329
hey everyone in this video let's take a look at question 329 longest increasing path in a matrix this is part of our blind 75 list of questions so let's begin in this question you are given M by n integers Matrix so Matrix array which is M by n and you want to return the length of the longest increasing path in Matrix ...
Longest Increasing Path in a Matrix
longest-increasing-path-in-a-matrix
Given an `m x n` integers `matrix`, return _the length of the longest increasing path in_ `matrix`. From each cell, you can either move in four directions: left, right, up, or down. You **may not** move **diagonally** or move **outside the boundary** (i.e., wrap-around is not allowed). **Example 1:** **Input:** matr...
null
Dynamic Programming,Depth-First Search,Breadth-First Search,Graph,Topological Sort,Memoization
Hard
null
236
hey guys how's everything going this is Jay sir he's not good at algorithms I'm making this video to prepare my interview in this video where I'm going to take a look at 2/3 sex lowest to take a look at 2/3 sex lowest to take a look at 2/3 sex lowest common ancestor of a binary tree we're coming a man in a tree we need...
Lowest Common Ancestor of a Binary Tree
lowest-common-ancestor-of-a-binary-tree
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the [definition of LCA on Wikipedia](https://en.wikipedia.org/wiki/Lowest_common_ancestor): "The lowest common ancestor is defined between two nodes `p` and `q` as the lowest node in `T` that has both `p` and `q` as...
null
Tree,Depth-First Search,Binary Tree
Medium
235,1190,1354,1780,1790,1816,2217
1,846
hey everyone welcome back and let's write some more neat code today so today let's solve the problem maximum element after decreasing and rearranging so we have a pretty fair problem today and that's good because I'm a bit Rusty we are given an array of positive integers and we can perform some or none operations on th...
Maximum Element After Decreasing and Rearranging
maximum-element-after-decreasing-and-rearranging
You are given an array of positive integers `arr`. Perform some operations (possibly none) on `arr` so that it satisfies these conditions: * The value of the **first** element in `arr` must be `1`. * The absolute difference between any 2 adjacent elements must be **less than or equal to** `1`. In other words, `abs...
null
null
Medium
null
1,675
hey what's up guys this is chung here so let's take a look at last problem of this week's weekly contest which is number 1675 minimize deviation in array it's very interesting i would say it's a math related problem basically you're given like an array numbers of n positive integers right and then for each of the integ...
Minimize Deviation in Array
magnetic-force-between-two-balls
You are given an array `nums` of `n` positive integers. You can perform two types of operations on any element of the array any number of times: * If the element is **even**, **divide** it by `2`. * For example, if the array is `[1,2,3,4]`, then you can do this operation on the last element, and the array wil...
If you can place balls such that the answer is x then you can do it for y where y < x. Similarly if you cannot place balls such that the answer is x then you can do it for y where y > x. Binary search on the answer and greedily see if it is possible.
Array,Binary Search,Sorting
Medium
2188
664
hey what's up guys this is jung so today uh let's take a look at lead code problem number 664 stringed printer so this one is a very interesting problem so you're given like a stringed printer and the printer follows following two special requirements so the first one is that printer can only print a sequence of the sa...
Strange Printer
strange-printer
There is a strange printer with the following two special properties: * The printer can only print a sequence of **the same character** each time. * At each turn, the printer can print new characters starting from and ending at any place and will cover the original existing characters. Given a string `s`, return ...
null
String,Dynamic Programming
Hard
546,1696
907
That Lakshya Khan Today's List Problem Admit Card Number 90 700 Savre Minimum The Latest Word Problems But Most Minimal Is The Minimum Element Of Savre The History Contact Us Given Here For All Facts About Animals And Wonders From Which It Is To Find All The Service Of Governor Andrew Strauss Thoughts In Every Element ...
Sum of Subarray Minimums
koko-eating-bananas
Given an array of integers arr, find the sum of `min(b)`, where `b` ranges over every (contiguous) subarray of `arr`. Since the answer may be large, return the answer **modulo** `109 + 7`. **Example 1:** **Input:** arr = \[3,1,2,4\] **Output:** 17 **Explanation:** Subarrays are \[3\], \[1\], \[2\], \[4\], \[3,1\], \...
null
Array,Binary Search
Medium
788,1335,2188
1,353
hey what's up guys this is chung here uh so this time uh let's take a look at another lead code problem 1353 maximum number of events that can be attended right so basically you're given an array of events with the start and end the time and you can attend an event i at any day where the start time i basically if this ...
Maximum Number of Events That Can Be Attended
maximum-number-of-events-that-can-be-attended
You are given an array of `events` where `events[i] = [startDayi, endDayi]`. Every event `i` starts at `startDayi` and ends at `endDayi`. You can attend an event `i` at any day `d` where `startTimei <= d <= endTimei`. You can only attend one event at any time `d`. Return _the maximum number of events you can attend_....
null
null
Medium
null
1,669
foreign let's read out the question quickly try to resolve it okay and put list two in their place the blue edge and notes in the following figure indicate the result okay what they do is zeros to five okay is 3 B is 4 list 2 is this okay output is 0 1 2 fine okay I got this 26 seconds okay so what it said it will ther...
Merge In Between Linked Lists
minimum-cost-to-cut-a-stick
You are given two linked lists: `list1` and `list2` of sizes `n` and `m` respectively. Remove `list1`'s nodes from the `ath` node to the `bth` node, and put `list2` in their place. The blue edges and nodes in the following figure indicate the result: _Build the result list and return its head._ **Example 1:** **In...
Build a dp array where dp[i][j] is the minimum cost to achieve all the cuts between i and j. When you try to get the minimum cost between i and j, try all possible cuts k between them, dp[i][j] = min(dp[i][k] + dp[k][j]) + (j - i) for all possible cuts k between them.
Array,Dynamic Programming
Hard
2251
222
Hello friends today I am solving liquid problem number 222 count complete three notes Here we are given root of a complete binary tree and we need to return the number of nodes in that tree a complete binary tree is a tree where um the tree has a two children except the last level and the second last level where the la...
Count Complete Tree Nodes
count-complete-tree-nodes
Given the `root` of a **complete** binary tree, return the number of the nodes in the tree. According to **[Wikipedia](http://en.wikipedia.org/wiki/Binary_tree#Types_of_binary_trees)**, every level, except possibly the last, is completely filled in a complete binary tree, and all nodes in the last level are as far lef...
null
Binary Search,Tree,Depth-First Search,Binary Tree
Medium
270
226
everyone welcome back and let's write some more neat code today so today let's solve a pretty easy and popular question invert binary search tree so all they tell us to do is invert a binary tree and what exactly does that mean so let's say that this is our initial tree to invert it is basically what you can tell in th...
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
287
yo Chuck what the Chuck is up YouTube in this video we're going to be going over leak code 287 find the duplicate number the thing that stands out to me about this problem is the constraints are pretty intense so we start with an array of integers containing n+ one integers of integers containing n+ one integers of int...
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
417
hello everyone welcome to my youtube channel and the question for today is pacific implanting water flow all right so what we have over here is the question where in which given a matrix m cross n of non negative integers representing the height of the each unit in the continent like pacific ocean what touches the left...
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
878
Hello All Activities Problem Darkness to Conscience Bill to Ignore Actually a Problem Number to Take Down I'm Forever 125 Given Magical Number What is the Magical Number Magical Numbers of Positive Anti-Aging Effects Divisible by Positive Anti-Aging Effects Divisible by Positive Anti-Aging Effects Divisible by Either A...
Nth Magical Number
shifting-letters
A positive integer is _magical_ if it is divisible by either `a` or `b`. Given the three integers `n`, `a`, and `b`, return the `nth` magical number. Since the answer may be very large, **return it modulo** `109 + 7`. **Example 1:** **Input:** n = 1, a = 2, b = 3 **Output:** 2 **Example 2:** **Input:** n = 4, a = ...
null
Array,String
Medium
1954
37
good morning everyone welcome to my YouTube channel and for this video let's talk about the subsequent problem to the Sudoku problem so for this problem we have to actually come up with our own like Sudoku server so we will look at two approaches for doing this problem here is the problem statement and as usual I want ...
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
434
The Festival My name is Adarsh ​​Mishra This is what The Festival My name is Adarsh ​​Mishra This is what The Festival My name is Adarsh ​​Mishra This is what you are watching Dress this mark Today we are going to talk about number of Tintin's problem not Gheerat Dahi video on the list You can watch the video that you ...
Number of Segments in a String
number-of-segments-in-a-string
Given a string `s`, return _the number of segments in the string_. A **segment** is defined to be a contiguous sequence of **non-space characters**. **Example 1:** **Input:** s = "Hello, my name is John " **Output:** 5 **Explanation:** The five segments are \[ "Hello, ", "my ", "name ", "is ", "John "\] **Exam...
null
String
Easy
null
54
in this video we're going to take a look at a legal problem called spiral matrix so given an m times n matrix so return all elements of the matrix in a spiral order so here you can see that we have a 2d array and we're basically given a 2d array of matrix and we want to return a spiral order of the um 2d array in a one...
Spiral Matrix
spiral-matrix
Given an `m x n` `matrix`, return _all elements of the_ `matrix` _in spiral order_. **Example 1:** **Input:** matrix = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\] **Output:** \[1,2,3,6,9,8,7,4,5\] **Example 2:** **Input:** matrix = \[\[1,2,3,4\],\[5,6,7,8\],\[9,10,11,12\]\] **Output:** \[1,2,3,4,8,12,11,10,9,5,6,7\] **Const...
Well for some problems, the best way really is to come up with some algorithms for simulation. Basically, you need to simulate what the problem asks us to do. We go boundary by boundary and move inwards. That is the essential operation. First row, last column, last row, first column and then we move inwards by 1 and th...
Array,Matrix,Simulation
Medium
59,921
1,599
Had happened Hello friends welcome to my channel today appointed S tax problem list contest 1000 maximum profit of operating officer appointed 100 gram center subscribe channel 1234 more compartment subscribe Indian elections will rotate soft operation degree and torn Sudhir rotation it means running Cost ok to liquid ...
Maximum Profit of Operating a Centennial Wheel
maximum-profit-of-operating-a-centennial-wheel
You are the operator of a Centennial Wheel that has **four gondolas**, and each gondola has room for **up** **to** **four people**. You have the ability to rotate the gondolas **counterclockwise**, which costs you `runningCost` dollars. You are given an array `customers` of length `n` where `customers[i]` is the numbe...
null
null
Medium
null
82
Toilet And Asked Questions Remove Duplicate Mandsaur District In This Question In Given Or Started List And You Need To Remove Dost Element From The Reader Kissi Inverter Defeated Indra Leaves Means Frequency August Month In The Intellect Subscribe 1233 65 Subscribe Element Completely Liquid subscribe The Channel Pleas...
Remove Duplicates from Sorted List II
remove-duplicates-from-sorted-list-ii
Given the `head` of a sorted linked list, _delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list_. Return _the linked list **sorted** as well_. **Example 1:** **Input:** head = \[1,2,3,3,4,4,5\] **Output:** \[1,2,5\] **Example 2:** **Input:** head = \[1,1,1,2,3\] **Outpu...
null
Linked List,Two Pointers
Medium
83,1982
19
given that link twist removed the eighth note from the end of the linked list and returned his hat how would you do this is today's video let's get into it hi everyone my name is Steve today we are going through a little problem 19 a very classic interview question regarding a link to list remove ant node from the end ...
Remove Nth Node From End of List
remove-nth-node-from-end-of-list
Given the `head` of a linked list, remove the `nth` node from the end of the list and return its head. **Example 1:** **Input:** head = \[1,2,3,4,5\], n = 2 **Output:** \[1,2,3,5\] **Example 2:** **Input:** head = \[1\], n = 1 **Output:** \[\] **Example 3:** **Input:** head = \[1,2\], n = 1 **Output:** \[1\] **C...
Maintain two pointers and update one with a delay of n steps.
Linked List,Two Pointers
Medium
528,1618,2216
438
good evening everyone today we are going to do the daily record challenge of 5 February 2023 that is question number 438 find all anagrams in a string so anagrams are basically permutations of a string and we have done this question yesterday so please check out that video there will be a minor change in that code beca...
Find All Anagrams in a String
find-all-anagrams-in-a-string
Given two strings `s` and `p`, return _an array of all the start indices of_ `p`_'s anagrams in_ `s`. You may return the answer in **any order**. An **Anagram** is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. **Example 1:** *...
null
Hash Table,String,Sliding Window
Medium
242,567
872
hello hi guys good morning welcome back to a new video and this we a problem Leaf similar tree and we're going to see two variations of it as an first standard solution which everyone would know but then a one optimized one which you may or might not know or might you might get asked in an interview let's see what the ...
Leaf-Similar Trees
split-array-into-fibonacci-sequence
Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a **leaf value sequence**_._ For example, in the given tree above, the leaf value sequence is `(6, 7, 4, 9, 8)`. Two binary trees are considered _leaf-similar_ if their leaf value sequence is the same. Return `true` i...
null
String,Backtracking
Medium
306,1013
953
hey everybody this is larry this is day nine of the leco april daily challenge hit the like button hit the subscriber and join me on discord let me know what you think about today's forum uh vertifying an alien dictionary um yeah some another classes there uh but yeah i'm gonna find an alien dictionary so i you should ...
Verifying an Alien Dictionary
reverse-only-letters
In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different `order`. The `order` of the alphabet is some permutation of lowercase letters. Given a sequence of `words` written in the alien language, and the `order` of the alphabet, return `true` if and only if the given `wor...
This problem is exactly like reversing a normal string except that there are certain characters that we have to simply skip. That should be easy enough to do if you know how to reverse a string using the two-pointer approach.
Two Pointers,String
Easy
null
114
everyone welcome back and let's write some more neat code today so today let's solve the problem flatten binary tree into a linked list we are given the root of a binary tree and we want to flatten it so that it turns into a linked list not necessarily a true linked list because you know this data structure obviously i...
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
16
Hello Hi Everyone One Second Welcome To My Channel And Were Solving Another Important Problem 30 Followers Have Already Like A Dasham Related Problems Like Subscribe My Channel Problem World Tour Of Declaration Page Numbers From Subscribe And All The Number Selected List Number 151 Target What We Can Do Inform All the ...
3Sum Closest
3sum-closest
Given an integer array `nums` of length `n` and an integer `target`, find three integers in `nums` such that the sum is closest to `target`. Return _the sum of the three integers_. You may assume that each input would have exactly one solution. **Example 1:** **Input:** nums = \[-1,2,1,-4\], target = 1 **Output:** ...
null
Array,Two Pointers,Sorting
Medium
15,259
24
hello everyone welcome to clash encoder so in this video we will see the question that is swap nodes in pairs so this is a linked list based question and it has been asking a lot of interviews for many companies for the fang also and for other companies as well so this is a medium level question so let's see the proble...
Swap Nodes in Pairs
swap-nodes-in-pairs
Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.) **Example 1:** **Input:** head = \[1,2,3,4\] **Output:** \[2,1,4,3\] **Example 2:** **Input:** head = \[\] **Output:** \[\...
null
Linked List,Recursion
Medium
25,528
1,361
hello and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem 1361 validate binary tree nodes you have n binary tree nodes numbered from 0 to n minus 1 where node of i has two children left child of eye and right child of i return true if and only if the given nodes form ...
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
407
try again 47 traveling where he wanted to given an m-by-n matrix are positive to given an m-by-n matrix are positive to given an m-by-n matrix are positive and girls representing the height of each units now in a 2d elevation map compute the volume of water it is able to trap after waning bottom M and n are less than 1...
Trapping Rain Water II
trapping-rain-water-ii
Given an `m x n` integer matrix `heightMap` representing the height of each unit cell in a 2D elevation map, return _the volume of water it can trap after raining_. **Example 1:** **Input:** heightMap = \[\[1,4,3,1,3,2\],\[3,2,1,3,2,4\],\[2,3,3,2,3,1\]\] **Output:** 4 **Explanation:** After the rain, water is trapped...
null
Array,Breadth-First Search,Heap (Priority Queue),Matrix
Hard
42
452
So today we will do the problem of minimum number of burst balloons. It is a medium level problem. Once you read it, people will understand. So we have made some starting point, so this is the diagram, so this diagram of points is correct, so it is 10:16, you and the correct, so it is 10:16, you and the correct, so it ...
Minimum Number of Arrows to Burst Balloons
minimum-number-of-arrows-to-burst-balloons
There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array `points` where `points[i] = [xstart, xend]` denotes a balloon whose **horizontal diameter** stretches between `xstart` and `xend`. You do not know the exact y-coordinates of the ball...
null
Array,Greedy,Sorting
Medium
253,435
452
hey what's up guys John here and today let's take a look at another difficult problem yeah let's continue our little journey here number 452 minimum number of arrows to burst balloons okay so you're given like a range of up along so for each belong it's a 1d one demand dimensional like coordinates basically the balloon...
Minimum Number of Arrows to Burst Balloons
minimum-number-of-arrows-to-burst-balloons
There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array `points` where `points[i] = [xstart, xend]` denotes a balloon whose **horizontal diameter** stretches between `xstart` and `xend`. You do not know the exact y-coordinates of the ball...
null
Array,Greedy,Sorting
Medium
253,435
1,770
hey everybody this is larry this is day 16 of the september leeco daily challenge hit the like button the subscribe button join me on discord let me know what you think about today's problem uh i am still in dublin or at least i'm back in dublin uh i just drove for a long time from belfast uh you've this is where the i...
Maximum Score from Performing Multiplication Operations
minimum-deletions-to-make-character-frequencies-unique
You are given two **0-indexed** integer arrays `nums` and `multipliers` of size `n` and `m` respectively, where `n >= m`. You begin with a score of `0`. You want to perform **exactly** `m` operations. On the `ith` operation (**0-indexed**) you will: * Choose one integer `x` from **either the start or the end** of t...
As we can only delete characters, if we have multiple characters having the same frequency, we must decrease all the frequencies of them, except one. Sort the alphabet characters by their frequencies non-increasingly. Iterate on the alphabet characters, keep decreasing the frequency of the current character until it re...
String,Greedy,Sorting
Medium
1355,2212
868
find and return the longest distance between two arches and once in the binary representation of n if there are no two adjacent points in the by the representation given integer then just written zero so two ones are adjacent if there are only zeros separating them so the distance between two ones is the absolute diffe...
Binary Gap
push-dominoes
Given a positive integer `n`, find and return _the **longest distance** between any two **adjacent**_ `1`_'s in the binary representation of_ `n`_. If there are no two adjacent_ `1`_'s, return_ `0`_._ Two `1`'s are **adjacent** if there are only `0`'s separating them (possibly no `0`'s). The **distance** between two `...
null
Two Pointers,String,Dynamic Programming
Medium
null
881
What happened was guys welcome back to my channel and this video we are going to solve ODD to say paper solve tips knowledge statement here you are given in a rich people where people is divided of highest position and infinite number of votes where is vote can carry The maximum age limit is boot carrier set most peopl...
Boats to Save People
loud-and-rich
You are given an array `people` where `people[i]` is the weight of the `ith` person, and an **infinite number of boats** where each boat can carry a maximum weight of `limit`. Each boat carries at most two people at the same time, provided the sum of the weight of those people is at most `limit`. Return _the minimum n...
null
Array,Depth-First Search,Graph,Topological Sort
Medium
null
1,796
hey everybody this is larry just me going with q1 of the buy weekly contest 48 and i made a silly mistake which is why i'm showing you here uh that i also make mistakes sometimes i think i got too clever and tried to do everything in one line and then i don't know got a little bit quite lucky on the examples but um but...
Second Largest Digit in a String
correct-a-binary-tree
Given an alphanumeric string `s`, return _the **second largest** numerical digit that appears in_ `s`_, or_ `-1` _if it does not exist_. An **alphanumeric** string is a string consisting of lowercase English letters and digits. **Example 1:** **Input:** s = "dfa12321afd " **Output:** 2 **Explanation:** The digits t...
If you traverse the tree from right to left, the invalid node will point to a node that has already been visited.
Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
114,766
123
Hello viewers welcome to your sons media today with all the sixteen problems against killing challenge best time to buy and sell stock three please like this video fuel forget to subscribe our Channel mist update now you have every form is the rectangle element is the price Of The Given Stock Monday Came Designer Lever...
Best Time to Buy and Sell Stock III
best-time-to-buy-and-sell-stock-iii
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 **at most two transactions**. **Note:** You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again). **Exampl...
null
Array,Dynamic Programming
Hard
121,122,188,689
105
hi everyone today we are going to solve the recalled question construct binary tree from pre-order and in another tree from pre-order and in another tree from pre-order and in another traversal so you are given two integer arrays pre-order and in order where arrays pre-order and in order where arrays pre-order and in o...
Construct Binary Tree from Preorder and Inorder Traversal
construct-binary-tree-from-preorder-and-inorder-traversal
Given two integer arrays `preorder` and `inorder` where `preorder` is the preorder traversal of a binary tree and `inorder` is the inorder traversal of the same tree, construct and return _the binary tree_. **Example 1:** **Input:** preorder = \[3,9,20,15,7\], inorder = \[9,3,15,20,7\] **Output:** \[3,9,20,null,null,...
null
Array,Hash Table,Divide and Conquer,Tree,Binary Tree
Medium
106
21
hey guys welcome and welcome back to my channel so today we are going to discuss another problem is merge to sorted link list so in the question we will be given two sorted link list so if you see this is the first sorted link list it's sorted in ascending order and the second link is this is which is also sorted in as...
Merge Two Sorted Lists
merge-two-sorted-lists
You are given the heads of two sorted linked lists `list1` and `list2`. Merge the two lists in a one **sorted** list. The list should be made by splicing together the nodes of the first two lists. Return _the head of the merged linked list_. **Example 1:** **Input:** list1 = \[1,2,4\], list2 = \[1,3,4\] **Output:**...
null
Linked List,Recursion
Easy
23,88,148,244,1774,2071
347
hello everyone welcome back to my channel this is jess so today we'll be looking at a problem called top k frequent elements so first let's take a look at the question statement you're given an integer array noms and an integer k and you're asked to return the k most frequent elements you may return the answer in any o...
Top K Frequent Elements
top-k-frequent-elements
Given an integer array `nums` and an integer `k`, return _the_ `k` _most frequent elements_. You may return the answer in **any order**. **Example 1:** **Input:** nums = \[1,1,1,2,2,3\], k = 2 **Output:** \[1,2\] **Example 2:** **Input:** nums = \[1\], k = 1 **Output:** \[1\] **Constraints:** * `1 <= nums.lengt...
null
Array,Hash Table,Divide and Conquer,Sorting,Heap (Priority Queue),Bucket Sort,Counting,Quickselect
Medium
192,215,451,659,692,1014,1919
983
hey guys welcome back to another video and today we're going to be solving the lead code question minimum cost for tickets all right so in this question we're so in a country popular for train travel you have planned some train traveling one year in advance so the days of the year that you will travel is given is in an...
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
109
hey everybody this is Larry this is day 11th of the deco day challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about this Farm yay one that doesn't have the solution in the memory all right let's take a look is it seems like it's gonna link this from 109 convert sorted...
Convert Sorted List to Binary Search Tree
convert-sorted-list-to-binary-search-tree
Given the `head` of a singly linked list where elements are sorted in **ascending order**, convert _it to a_ **_height-balanced_** _binary search tree_. **Example 1:** **Input:** head = \[-10,-3,0,5,9\] **Output:** \[0,-3,9,-10,null,5\] **Explanation:** One possible answer is \[0,-3,9,-10,null,5\], which represents t...
null
Linked List,Divide and Conquer,Tree,Binary Search Tree,Binary Tree
Medium
108,2306
961
okay let's talk about unrepeated element in size two an array so you are given the array integer nums with the following properties so note that the integral of two times n numbers contain plus one unique elements exactly one element of unrepeated end times so um there's a element that is occur more than once and you c...
N-Repeated Element in Size 2N Array
long-pressed-name
You are given an integer array `nums` with the following properties: * `nums.length == 2 * n`. * `nums` contains `n + 1` **unique** elements. * Exactly one element of `nums` is repeated `n` times. Return _the element that is repeated_ `n` _times_. **Example 1:** **Input:** nums = \[1,2,3,3\] **Output:** 3 **...
null
Two Pointers,String
Easy
null
1,721
hey everyone welcome back and let's write some more neat code today so today I'll solve the problems swapping nodes in a linked list we're given the head of a linked list and an integer K and we want to swap the values of two nodes how do we know which nodes they are well that's what our integer K tells us so the first...
Swapping Nodes in a Linked List
maximum-profit-of-operating-a-centennial-wheel
You are given the `head` of a linked list, and an integer `k`. Return _the head of the linked list after **swapping** the values of the_ `kth` _node from the beginning and the_ `kth` _node from the end (the list is **1-indexed**)._ **Example 1:** **Input:** head = \[1,2,3,4,5\], k = 2 **Output:** \[1,4,3,2,5\] **Ex...
Think simulation Note that the number of turns will never be more than 50 / 4 * n
Array,Simulation
Medium
null
382
hello everyone today let us solve the problem linked list random node given a single linked list return a random nodes value from the linked list each node must have the same probability of being chosen implement the solution class solution list node head initializes the object with the head of the single linked list a...
Linked List Random Node
linked-list-random-node
Given a singly linked list, return a random node's value from the linked list. Each node must have the **same probability** of being chosen. Implement the `Solution` class: * `Solution(ListNode head)` Initializes the object with the head of the singly-linked list `head`. * `int getRandom()` Chooses a node randoml...
null
Linked List,Math,Reservoir Sampling,Randomized
Medium
398
1
Hello guys my Sampantha welcome back to my channel text message send a video they want to discuss list problem number one but its problems let's get started problem states and enters the return of two numbers subscribe now to the number 90 number this particular 100000000 Inter Referral Vacancy That And In Its Numerous...
Two Sum
two-sum
Given an array of integers `nums` and an integer `target`, return _indices of the two numbers such that they add up to `target`_. You may assume that each input would have **_exactly_ one solution**, and you may not use the _same_ element twice. You can return the answer in any order. **Example 1:** **Input:** nums...
A really brute force way would be to search for all possible pairs of numbers but that would be too slow. Again, it's best to try out brute force solutions for just for completeness. It is from these brute force solutions that you can come up with optimizations. So, if we fix one of the numbers, say x, we have to scan ...
Array,Hash Table
Easy
15,18,167,170,560,653,1083,1798,1830,2116,2133,2320
1,621
good morning my audiences how are you doing today we are going to study lead code 1621 together 1621 um you can search up in a little website for this description of this problem basically it talks about if there are any elements in points and you want to draw k lines with those elements with this points and those line...
Number of Sets of K Non-Overlapping Line Segments
number-of-subsequences-that-satisfy-the-given-sum-condition
Given `n` points on a 1-D plane, where the `ith` point (from `0` to `n-1`) is at `x = i`, find the number of ways we can draw **exactly** `k` **non-overlapping** line segments such that each segment covers two or more points. The endpoints of each segment must have **integral coordinates**. The `k` line segments **do n...
Sort the array nums. Use two pointers approach: Given an index i (choose it as the minimum in a subsequence) find the maximum j where j ≥ i and nums[i] +nums[j] ≤ target. Count the number of subsequences.
Array,Two Pointers,Binary Search,Sorting
Medium
null
49
hello boys and girls and welcome to another episode of your favorite algorithm channel my name is Ryan powers and today I'm gonna be taking you through leet code 49 group anagrams so let's introduce the problem give it an array of strings group anagrams together okay awesome so what exactly is an anagram well if we loo...
Group Anagrams
group-anagrams
Given an array of strings `strs`, group **the anagrams** together. You can return the answer in **any order**. An **Anagram** is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. **Example 1:** **Input:** strs = \["eat","tea","tan...
null
Hash Table,String,Sorting
Medium
242,249
18
look at number 18 for some we finished the threesome and here is the foursome so we're giving array target to zero we need to find out all the solutions that 4 with 4 which has four elements which sums up to zero so actually we're already finish the threesome so I'd like so please refer that first I'll just write the s...
4Sum
4sum
Given an array `nums` of `n` integers, return _an array of all the **unique** quadruplets_ `[nums[a], nums[b], nums[c], nums[d]]` such that: * `0 <= a, b, c, d < n` * `a`, `b`, `c`, and `d` are **distinct**. * `nums[a] + nums[b] + nums[c] + nums[d] == target` You may return the answer in **any order**. **Examp...
null
Array,Two Pointers,Sorting
Medium
1,15,454,2122
477
A Slow Gas Today We Are Going To Discuss Very Interesting Problem No Problem You Still Having Distance Which Elite Code Medium Problem Of But White Manipulation Solved Problems As Word Problems Statement This You Will Give And We Are Of These Teachers Black Spots Give Energy Office Hand To Such person element of The Am...
Total Hamming Distance
total-hamming-distance
The [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) between two integers is the number of positions at which the corresponding bits are different. Given an integer array `nums`, return _the sum of **Hamming distances** between all the pairs of the integers in_ `nums`. **Example 1:** **Input:** num...
null
Array,Math,Bit Manipulation
Medium
461
633
hello everyone and welcome back to another video so today we're going to be solving the lego question sum of square numbers all right so in this question we're going to be given a non-negative we're going to be given a non-negative we're going to be given a non-negative integer c and our goal is to decide whether there...
Sum of Square Numbers
sum-of-square-numbers
Given a non-negative integer `c`, decide whether there're two integers `a` and `b` such that `a2 + b2 = c`. **Example 1:** **Input:** c = 5 **Output:** true **Explanation:** 1 \* 1 + 2 \* 2 = 5 **Example 2:** **Input:** c = 3 **Output:** false **Constraints:** * `0 <= c <= 231 - 1`
null
Math,Two Pointers,Binary Search
Medium
367
44
hello let's try to solve another lead code problem number 44 wildcard battery and we are giving a straight s and a pattern P so implement the wildcard pattern matching with the support for question mark yes and the star so for the question mark it means any single character yeah for example this is a b and this is the ...
Wildcard Matching
wildcard-matching
Given an input string (`s`) and a pattern (`p`), implement wildcard pattern matching with support for `'?'` and `'*'` where: * `'?'` Matches any single character. * `'*'` Matches any sequence of characters (including the empty sequence). The matching should cover the **entire** input string (not partial). **Exam...
null
String,Dynamic Programming,Greedy,Recursion
Hard
10
732
That them guys welcome back to my channel vriddhi dutta and in this video is not discuss about this thought was not mycalendar posted by cbi on 20 presented out because this video has gone definition of the series right gold behavior discuss spoon hardware problem just quantum of previous Approach August 1 Hour Approac...
My Calendar III
my-calendar-iii
A `k`\-booking happens when `k` events have some non-empty intersection (i.e., there is some time that is common to all `k` events.) You are given some events `[startTime, endTime)`, after each given event, return an integer `k` representing the maximum `k`\-booking between all the previous events. Implement the `MyC...
Treat each interval [start, end) as two events "start" and "end", and process them in sorted order.
Design,Segment Tree,Ordered Set
Hard
729,731
223
Hello Gas, the daily problem of Azamgarh is rectangle area, so this is a medium question and also easy and first of all we will look at this question, two big rectangles are given and we have to find their total area, so I think it is very easy. You take the area of ​​two easy. You take the area of ​​two easy. You take...
Rectangle Area
rectangle-area
Given the coordinates of two **rectilinear** rectangles in a 2D plane, return _the total area covered by the two rectangles_. The first rectangle is defined by its **bottom-left** corner `(ax1, ay1)` and its **top-right** corner `(ax2, ay2)`. The second rectangle is defined by its **bottom-left** corner `(bx1, by1)` ...
null
Math,Geometry
Medium
866
1,339
welcome to august leco challenge today's problem is maximum product of splitted binary tree given the root of a binary tree split the binary tree into two sub-trees by the binary tree into two sub-trees by the binary tree into two sub-trees by removing one edge such that the product of the sums of the sub-trees is of t...
Maximum Product of Splitted Binary Tree
team-scores-in-football-tournament
Given the `root` of a binary tree, split the binary tree into two subtrees by removing one edge such that the product of the sums of the subtrees is maximized. Return _the maximum product of the sums of the two subtrees_. Since the answer may be too large, return it **modulo** `109 + 7`. **Note** that you need to max...
null
Database
Medium
null
1,678
let's do problem 1678 gold parcel interpretation so the question says that you own a go parser that can interpret a string command the command consists of an alphabet of G open and close brackets and open and close brackets with Al in between in same order in some order the goal passer will interpret G as the string G ...
Goal Parser Interpretation
number-of-ways-to-split-a-string
You own a **Goal Parser** that can interpret a string `command`. The `command` consists of an alphabet of `"G "`, `"() "` and/or `"(al) "` in some order. The Goal Parser will interpret `"G "` as the string `"G "`, `"() "` as the string `"o "`, and `"(al) "` as the string `"al "`. The interpreted strings are then concat...
There is no way if the sum (number of '1's) is not divisible by the number of splits. So sum%3 should be 0. Preffix s1 , and suffix s3 should have sum/3 characters '1'. Follow up: Can you generalize the problem with numbers between [-10^9, 10^9] such the sum between subarrays s1, s2, s3 are the same?
Math,String
Medium
548
473
hello everyone today's daily code challenge is matchsticks to square here it's a medium level question uh the question given is we have given an integer array which is named as matchsticks here every i of a matchsticks will represent a length of a matchstick and we need to use all the nastics to make one square and we ...
Matchsticks to Square
matchsticks-to-square
You are given an integer array `matchsticks` where `matchsticks[i]` is the length of the `ith` matchstick. You want to use **all the matchsticks** to make one square. You **should not break** any stick, but you can link them up, and each matchstick must be used **exactly one time**. Return `true` if you can make this ...
Treat the matchsticks as an array. Can we split the array into 4 equal halves? Every matchstick can belong to either of the 4 sides. We don't know which one. Maybe try out all options! For every matchstick, we have to try out each of the 4 options i.e. which side it can belong to. We can make use of recursion for this....
Array,Dynamic Programming,Backtracking,Bit Manipulation,Bitmask
Medium
null
1,630
okay let's try to solve today's L code problem 1630 arithmetic subes now what this question says a sequence of number is called arithmetic if it consists of at least two elements and the difference between every two elements or consecutive elements is the same just like here 13579 is arithmetic sequence because 1 and t...
Arithmetic Subarrays
count-odd-numbers-in-an-interval-range
A sequence of numbers is called **arithmetic** if it consists of at least two elements, and the difference between every two consecutive elements is the same. More formally, a sequence `s` is arithmetic if and only if `s[i+1] - s[i] == s[1] - s[0]` for all valid `i`. For example, these are **arithmetic** sequences: 1...
If the range (high - low + 1) is even, the number of even and odd numbers in this range will be the same. If the range (high - low + 1) is odd, the solution will depend on the parity of high and low.
Math
Easy
null
49
Hello how can you identify the graphene gives strength and Polytechnic is right at least to two to eight samples were tested in A plus B square feet profit Tank Stratfor faced this problem Bike collided with the driver killed Problem Hair Straight Forward Use K Nire Do Something That To Group The Exam Together For Litt...
Group Anagrams
group-anagrams
Given an array of strings `strs`, group **the anagrams** together. You can return the answer in **any order**. An **Anagram** is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. **Example 1:** **Input:** strs = \["eat","tea","tan...
null
Hash Table,String,Sorting
Medium
242,249
255
welcome to interview Pro in this video Let's solve another lead code problem to verify pre-order sequence in a binary verify pre-order sequence in a binary verify pre-order sequence in a binary search trick as per the problem statement we will be given a array of unique integers and in the pre-order the pre-order the p...
Verify Preorder Sequence in Binary Search Tree
verify-preorder-sequence-in-binary-search-tree
Given an array of **unique** integers `preorder`, return `true` _if it is the correct preorder traversal sequence of a binary search tree_. **Example 1:** **Input:** preorder = \[5,2,1,3,6\] **Output:** true **Example 2:** **Input:** preorder = \[5,2,6,1,3\] **Output:** false **Constraints:** * `1 <= preorder.l...
null
Stack,Tree,Binary Search Tree,Recursion,Monotonic Stack,Binary Tree
Medium
144
48
hey guys today we are going to solve 48 rooted image from lead code so it's a 2d Matrix question and has been asked like a lot from many multiple companies so let's get started with this one let's set the timer we'll try to solve it in 10 or less than that if not then we'll jump to the solution okay so if you are given...
Rotate Image
rotate-image
You are given an `n x n` 2D `matrix` representing an image, rotate the image by **90** degrees (clockwise). You have to rotate the image [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm), which means you have to modify the input 2D matrix directly. **DO NOT** allocate another 2D matrix and do the rotati...
null
Array,Math,Matrix
Medium
2015
1,679
Jhal Ajay Ko Hello Friends Welcome to my YouTube Channel Tier-3 Today Khayal Mintu Solid Problem Tier-3 Today Khayal Mintu Solid Problem Tier-3 Today Khayal Mintu Solid Problem Se Zauq Ne Smack Number for Example You are One and Jerry in Interior's In One Operation You Can Take Two Numbers from Tere Ko Sham Ko Remove f...
Max Number of K-Sum Pairs
shortest-subarray-to-be-removed-to-make-array-sorted
You are given an integer array `nums` and an integer `k`. In one operation, you can pick two numbers from the array whose sum equals `k` and remove them from the array. Return _the maximum number of operations you can perform on the array_. **Example 1:** **Input:** nums = \[1,2,3,4\], k = 5 **Output:** 2 **Explana...
The key is to find the longest non-decreasing subarray starting with the first element or ending with the last element, respectively. After removing some subarray, the result is the concatenation of a sorted prefix and a sorted suffix, where the last element of the prefix is smaller than the first element of the suffix...
Array,Two Pointers,Binary Search,Stack,Monotonic Stack
Medium
null
108
hey everybody this is larry this is me going over day 26 of july's leco daily challenge hit the like button and subscribe and join me on discord let me know what you think about today's film so i'm in sunny san diego today and for this week i suppose uh so yes i'm excited uh hopefully the sound is quieter because i'm n...
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
202
all right welcome back to day two everyone this is happy number so in this question we are given an input 19 and we want to split up its digits and then square them so 1 squared plus 9 squared 82 and then what we want to see is if we continue doing this if we end up hitting the number 1 so if we hit number 1 it'll just...
Happy Number
happy-number
Write an algorithm to determine if a number `n` is happy. A **happy number** is a number defined by the following process: * Starting with any positive integer, replace the number by the sum of the squares of its digits. * Repeat the process until the number equals 1 (where it will stay), or it **loops endlessly ...
null
Hash Table,Math,Two Pointers
Easy
141,258,263,2076
300
everyone welcome back let's solve another problem today longest increasing subsequence and this is another tricky dynamic programming problem and i'm going to show you how to go from the recursive solution to the dynamic programming solution so we're given an array of numbers and we just want to return the length of th...
Longest Increasing Subsequence
longest-increasing-subsequence
Given an integer array `nums`, return _the length of the longest **strictly increasing**_ _**subsequence**_. **Example 1:** **Input:** nums = \[10,9,2,5,3,7,101,18\] **Output:** 4 **Explanation:** The longest increasing subsequence is \[2,3,7,101\], therefore the length is 4. **Example 2:** **Input:** nums = \[0,1,...
null
Array,Binary Search,Dynamic Programming
Medium
334,354,646,673,712,1766,2096,2234
279
hi everyone good morning today we are going to discuss one dynamic programming questions like perfect square so this is the problem that given integer n return the least number of perfect square the number that sum to n so if you consider 12 like it's like 2 square plus 2 the minimum is 3 so it would be also like if yo...
Perfect Squares
perfect-squares
Given an integer `n`, return _the least number of perfect square numbers that sum to_ `n`. A **perfect square** is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, `1`, `4`, `9`, and `16` are perfect squares while `3` and `11` are not. **Example ...
null
Math,Dynamic Programming,Breadth-First Search
Medium
204,264
71
hey everyone welcome to Tech wide in this video we are going to solve problem number 71 simplified path first we will see the explanation of the problem statement then the logic on the code now let's dive into the solution so here I have taken an example which covers all the conditions for the problem that is required ...
Simplify Path
simplify-path
Given a string `path`, which is an **absolute path** (starting with a slash `'/'`) to a file or directory in a Unix-style file system, convert it to the simplified **canonical path**. In a Unix-style file system, a period `'.'` refers to the current directory, a double period `'..'` refers to the directory up a level,...
null
String,Stack
Medium
null
703
okay let's talk about okay largest element in the stream so you'll be assigned a class to find the k largest element in the stream and look like this is okay large cell meaning sorting order another k distinct element so you have to implement the k largest class so this is constructor and this is add method so for the ...
Kth Largest Element in a Stream
kth-largest-element-in-a-stream
Design a class to find the `kth` largest element in a stream. Note that it is the `kth` largest element in the sorted order, not the `kth` distinct element. Implement `KthLargest` class: * `KthLargest(int k, int[] nums)` Initializes the object with the integer `k` and the stream of integers `nums`. * `int add(int...
null
null
Easy
null
792
Ajay Ko Hello Everyone Welcome 2016 Find On Chalu Notification Number Of The Thing Subsequent Inspiration Which Giveth Now School Video Like Solution Subscribe To Loot Number Matching Subsequent To 0.4 Subscribe Over All Subscribe Video Subscribe subscribe and subscribe the Channel subscribe to the Page The report in t...
Number of Matching Subsequences
binary-search
Given a string `s` and an array of strings `words`, return _the number of_ `words[i]` _that is a subsequence of_ `s`. A **subsequence** of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters. * For exa...
null
Array,Binary Search
Easy
786
1,886
all right guys day 56 the 100 days elite code um we're doing another matrix problem today it's determine whether matrix can be obtained by rotation let's get right to it so given two n by n matrices binary matrices uh matte matrix i'm just going to call it and target return true if it is possible to make matte matrix e...
Determine Whether Matrix Can Be Obtained By Rotation
minimum-limit-of-balls-in-a-bag
Given two `n x n` binary matrices `mat` and `target`, return `true` _if it is possible to make_ `mat` _equal to_ `target` _by **rotating**_ `mat` _in **90-degree increments**, or_ `false` _otherwise._ **Example 1:** **Input:** mat = \[\[0,1\],\[1,0\]\], target = \[\[1,0\],\[0,1\]\] **Output:** true **Explanation:** W...
Let's change the question if we know the maximum size of a bag what is the minimum number of bags you can make note that as the maximum size increases the minimum number of bags decreases so we can binary search the maximum size
Array,Binary Search
Medium
1335,2188
1,727
hey everybody this is larry this is q3 of the weekly contest 224 largest matrix or just sub matrix of a rearrangement uh i found this one really hard it might have been the hardest one for me um i think it's just because i don't know i just had issues with it and i found cute for a little bit easier but yeah hit the li...
Largest Submatrix With Rearrangements
cat-and-mouse-ii
You are given a binary matrix `matrix` of size `m x n`, and you are allowed to rearrange the **columns** of the `matrix` in any order. Return _the area of the largest submatrix within_ `matrix` _where **every** element of the submatrix is_ `1` _after reordering the columns optimally._ **Example 1:** **Input:** matri...
Try working backward: consider all trivial states you know to be winning or losing, and work backward to determine which other states can be labeled as winning or losing.
Math,Dynamic Programming,Breadth-First Search,Graph,Memoization,Game Theory
Hard
805,949
566
hey everyone welcome back and today we will be doing another lead code problem five sixes reshape The Matrix in the Matlab and easy one this is an easy problem in the Matlab there is a handy function called reshape which can reshape MXN Matrix into a new one with the different size or XC keeping its original data you a...
Reshape the Matrix
reshape-the-matrix
In MATLAB, there is a handy function called `reshape` which can reshape an `m x n` matrix into a new one with a different size `r x c` keeping its original data. You are given an `m x n` matrix `mat` and two integers `r` and `c` representing the number of rows and the number of columns of the wanted reshaped matrix. ...
Do you know how 2d matrix is stored in 1d memory? Try to map 2-dimensions into one. M[i][j]=M[n*i+j] , where n is the number of cols. This is the one way of converting 2-d indices into one 1-d index. Now, how will you convert 1-d index into 2-d indices? Try to use division and modulus to convert 1-d index into 2-d...
Array,Matrix,Simulation
Easy
2132
1,288
hey what's up guys this is john here again so uh so this time i want to talk about today's uh daily challenge which is number 1288 remove covered intervals so this is a this is like another interval problems where you of course you know every time when you see interval problems you know you need to sort it in some way ...
Remove Covered Intervals
maximum-subarray-sum-with-one-deletion
Given an array `intervals` where `intervals[i] = [li, ri]` represent the interval `[li, ri)`, remove all intervals that are covered by another interval in the list. The interval `[a, b)` is covered by the interval `[c, d)` if and only if `c <= a` and `b <= d`. Return _the number of remaining intervals_. **Example 1:...
How to solve this problem if no deletions are allowed ? Try deleting each element and find the maximum subarray sum to both sides of that element. To do that efficiently, use the idea of Kadane's algorithm.
Array,Dynamic Programming
Medium
null
414
hello guys my name is Ursula and welcome back to my channel and today we are going to solve a new lead code question that is third maximum number with the help of python so just before starting solving this question guys do subscribe to the channel hit the like button press the Bell icon button and book Marti playlist ...
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
128
welcome back to code Meets World today we're looking at leak code problem 128 longest consecutive sequence so we're given an unsorted array of integers and we need to return the length of the longest consecutive sequence of elements and this must run an O of n time so what that means is given an input array we need to ...
Longest Consecutive Sequence
longest-consecutive-sequence
Given an unsorted array of integers `nums`, return _the length of the longest consecutive elements sequence._ You must write an algorithm that runs in `O(n)` time. **Example 1:** **Input:** nums = \[100,4,200,1,3,2\] **Output:** 4 **Explanation:** The longest consecutive elements sequence is `[1, 2, 3, 4]`. Therefor...
null
Array,Hash Table,Union Find
Medium
298,2278
706
Hey guys welcome and welcome back to my channel in this video will go into song design is in snap swift problem we are design people are going to solve time problem your gift statement is here what is what you have to do here is that Today I have to do a design for you and also here you do not have to use any built-in ...
Design HashMap
design-hashmap
Design a HashMap without using any built-in hash table libraries. Implement the `MyHashMap` class: * `MyHashMap()` initializes the object with an empty map. * `void put(int key, int value)` inserts a `(key, value)` pair into the HashMap. If the `key` already exists in the map, update the corresponding `value`. * ...
null
null
Easy
null