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,845
hi everyone Let's uh start with the today's lead code challenge which is seat reservation manager so in this problem statement we'll just have to implement the seat manager class so as a Constructor to this class we will be given a number n which is the number of seats and we'll have to manage N seats which are numbere...
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
1,406
hi guys good morning and welcome back to the new video so basically in the last video in the last yesterday's video we saw Stone game two for sure last video also I told you that stone game one and stone game three are much easier than the stone game too although song and two was medium marked but still it is actually ...
Stone Game III
subtract-the-product-and-sum-of-digits-of-an-integer
Alice and Bob continue their games with piles of stones. There are several stones **arranged in a row**, and each stone has an associated value which is an integer given in the array `stoneValue`. Alice and Bob take turns, with Alice starting first. On each player's turn, that player can take `1`, `2`, or `3` stones f...
How to compute all digits of the number ? Use modulus operator (%) to compute the last digit. Generalise modulus operator idea to compute all digits.
Math
Easy
null
1,887
hello everyone today we will be solving the lead code daily challenge problem 1887 reduction operations to make the array elements equal so we are given an integer array and our goal is to make all the elements inside that array equal to complete one operation we have to follow the given steps we have to find the large...
Reduction Operations to Make the Array Elements Equal
minimum-degree-of-a-connected-trio-in-a-graph
Given an integer array `nums`, your goal is to make all elements in `nums` equal. To complete one operation, follow these steps: 1. Find the **largest** value in `nums`. Let its index be `i` (**0-indexed**) and its value be `largest`. If there are multiple elements with the largest value, pick the smallest `i`. 2. F...
Consider a trio with nodes u, v, and w. The degree of the trio is just degree(u) + degree(v) + degree(w) - 6. The -6 comes from subtracting the edges u-v, u-w, and v-w, which are counted twice each in the vertex degree calculation. To get the trios (u,v,w), you can iterate on u, then iterate on each w,v such that w and...
Graph
Hard
null
343
hi my name is jason we're going to be going over this problem integer break um the goal the main question of this problem is you're given an integer how can you break the integer up such that it sums to the target n and how can you maximize the product of those integers so let's say for example you have the integer six...
Integer Break
integer-break
Given an integer `n`, break it into the sum of `k` **positive integers**, where `k >= 2`, and maximize the product of those integers. Return _the maximum product you can get_. **Example 1:** **Input:** n = 2 **Output:** 1 **Explanation:** 2 = 1 + 1, 1 \* 1 = 1. **Example 2:** **Input:** n = 10 **Output:** 36 **Exp...
There is a simple O(n) solution to this problem. You may check the breaking results of n ranging from 7 to 10 to discover the regularities.
Math,Dynamic Programming
Medium
1936
946
hello everyone welcome or welcome back to my channel so today we are going to discuss another problem let's get started uh problem is validate stack sequences so we are given two integer errors pushed and popped each with distinct values we have to return true if this could have been the result of a sequence of push an...
Validate Stack Sequences
smallest-range-ii
Given two integer arrays `pushed` and `popped` each with distinct values, return `true` _if this could have been the result of a sequence of push and pop operations on an initially empty stack, or_ `false` _otherwise._ **Example 1:** **Input:** pushed = \[1,2,3,4,5\], popped = \[4,5,3,2,1\] **Output:** true **Explana...
null
Array,Math,Greedy,Sorting
Medium
null
279
alright welcome back to another discord question then now this question is perfect squares let's read the question given an integer n return the least number of perfect square numbers that sum to n a perfect square resin integer that is the square of an integer in other words it is the perfect product of some integer w...
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
490
hello so this question is the maze and basically uh you're giving a 2d array and then there's a starting and there's the ending and then you can only move four different directions and when you roll the ball and this ball will only stop at a point where it hit the wall so it will stop at this point like when you go dow...
The Maze
the-maze
There is a ball in a `maze` with empty spaces (represented as `0`) and walls (represented as `1`). The ball can go through the empty spaces by rolling **up, down, left or right**, but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction. Given the `m x n` `maze`, the ball...
null
Depth-First Search,Breadth-First Search,Graph
Medium
499,505
209
hello everyone I hope you're doing well in this video we are going to solve problem 209 minimum size sub array some in the Le code Series so let's see what's the problem wants us to solve So based on the description of the problem give us the array that has contain the list of integers and the target number and we need...
Minimum Size Subarray Sum
minimum-size-subarray-sum
Given an array of positive integers `nums` and a positive integer `target`, return _the **minimal length** of a_ _subarray_ _whose sum is greater than or equal to_ `target`. If there is no such subarray, return `0` instead. **Example 1:** **Input:** target = 7, nums = \[2,3,1,2,4,3\] **Output:** 2 **Explanation:** Th...
null
Array,Binary Search,Sliding Window,Prefix Sum
Medium
76,325,718,1776,2211,2329
303
alright guys welcome back to study plan program is the last day and the last problem it's time to get our patch so arrange some query image problem so given an integer array norms handle multiple queries of the following type calculates the sum of the elements of numbers between and these left or right inclusive where ...
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
965
hello guys welcome to code directory today the problem statement is uni valued binary tree a binary tree is univalued if every node in the tree has the same value okay return true if and only if the given tree is uni valued actually they will given the binary tree if the binary current binary tree contains all the valu...
Univalued Binary Tree
unique-email-addresses
A binary tree is **uni-valued** if every node in the tree has the same value. Given the `root` of a binary tree, return `true` _if the given tree is **uni-valued**, or_ `false` _otherwise._ **Example 1:** **Input:** root = \[1,1,1,1,1,null,1\] **Output:** true **Example 2:** **Input:** root = \[2,2,2,5,2\] **Outpu...
null
Array,Hash Table,String
Easy
null
775
Okay so hello everyone this is Akshay year today's question which we are going to discuss is global and local inversion lead co 775 this question is very famous by the name of counting inversion if you write counting instead then definitely similar to this You will get any question, let us understand the question and t...
Global and Local Inversions
n-ary-tree-preorder-traversal
You are given an integer array `nums` of length `n` which represents a permutation of all the integers in the range `[0, n - 1]`. The number of **global inversions** is the number of the different pairs `(i, j)` where: * `0 <= i < j < n` * `nums[i] > nums[j]` The number of **local inversions** is the number of i...
null
Stack,Tree,Depth-First Search
Easy
144,764,776
1,042
hey everybody this is larry this is me doing a bonus question so let's do one together i haven't done it yet uh let's see how many problems do i even need i don't even know but all right let's do a random one and hit the like button hit the subscribe button join me on discord and let me know what you think about today'...
Flower Planting With No Adjacent
minimum-cost-to-merge-stones
You have `n` gardens, labeled from `1` to `n`, and an array `paths` where `paths[i] = [xi, yi]` describes a bidirectional path between garden `xi` to garden `yi`. In each garden, you want to plant one of 4 types of flowers. All gardens have **at most 3** paths coming into or leaving it. Your task is to choose a flowe...
null
Array,Dynamic Programming
Hard
312,1126
286
everyone welcome back and let's write some more neat code today so today let's solve another graph problem walls and gates so we're given an m by n grid where each position could have three possible values a negative one which represents a wall aka an obstacle that we're not allowed to visit these walls a zero which id...
Walls and Gates
walls-and-gates
You are given an `m x n` grid `rooms` initialized with these three possible values. * `-1` A wall or an obstacle. * `0` A gate. * `INF` Infinity means an empty room. We use the value `231 - 1 = 2147483647` to represent `INF` as you may assume that the distance to a gate is less than `2147483647`. Fill each empt...
null
Array,Breadth-First Search,Matrix
Medium
130,200,317,865,1036
111
Hello everyone welcome to me channel court story with mike so today we are going to do video number 28 of our playlist of binary tree such a question is quite easy and after quite a few two a good and easy question has been given by lying down number 111 but they Bill B Solving It Using Buffs Well Ahead of Binary Quest...
Minimum Depth of Binary Tree
minimum-depth-of-binary-tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. **Note:** A leaf is a node with no children. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** 2 **Example 2:** **Input:** root = \[2...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
102,104
1,631
how's it going so let's look at leak code 1631 path with minimum effort you are a hiker preparing for an upcoming hike you're given Heights uh 2D array Road times columns where Heights row column represents a height of cell row column you're situated at the top left corner and you hope the bottom travel to the bottom r...
Path With Minimum Effort
number-of-sub-arrays-with-odd-sum
You are a hiker preparing for an upcoming hike. You are given `heights`, a 2D array of size `rows x columns`, where `heights[row][col]` represents the height of cell `(row, col)`. You are situated in the top-left cell, `(0, 0)`, and you hope to travel to the bottom-right cell, `(rows-1, columns-1)` (i.e., **0-indexed**...
Can we use the accumulative sum to keep track of all the odd-sum sub-arrays ? if the current accu sum is odd, we care only about previous even accu sums and vice versa.
Array,Math,Dynamic Programming,Prefix Sum
Medium
2242
278
Hello guys welcome back to take decision in this video you will see the first version problem system day one of the greatest problems will explain the problem in simple terms of problems in the production line producer product Thursday The Page if you liked The Video then subscribe to the Problem Hai You Can Rectify Th...
First Bad Version
first-bad-version
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose you have `n` versions `[1, 2, ..., n]` an...
null
Binary Search,Interactive
Easy
34,35,374
486
hello everyone welcome back to another episode of finance and uh coding today we are going to tackle a fascinating problem from the realm of dynamic programming uh titled predict the winner so this problem has a medium difficulty rating but it uh packed with a great concept so I will be explaining everything in Python ...
Predict the Winner
predict-the-winner
You are given an integer array `nums`. Two players are playing a game with this array: player 1 and player 2. Player 1 and player 2 take turns, with player 1 starting first. Both players start the game with a score of `0`. At each turn, the player takes one of the numbers from either end of the array (i.e., `nums[0]` ...
null
Array,Math,Dynamic Programming,Recursion,Game Theory
Medium
464
242
hey wassup guys think wider I did tacking coding stuff on Twitch in YouTube I doom the premium problem solutions on my patreon I appreciate anyone supports me if you want to reach out to me discord or patreon is a good place I try to get back to everyone this problem is called valid anagram very easy problem I can't be...
Valid Anagram
valid-anagram
Given two strings `s` and `t`, return `true` _if_ `t` _is an anagram of_ `s`_, and_ `false` _otherwise_. 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:** s = "anagram", t = "nagaram" **...
null
Hash Table,String,Sorting
Easy
49,266,438
67
hey everyone welcome to Tech Choir in this video we are going to solve problem number 67 at binary so given two binary strings A and B we need to return that sum as a binary string so basically we need to perform binary addition now we will see the logic and the code for this problem now let's dive into the solution so...
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
130
all right i'm trying on this problem called surrounded regions given an am cross and matrix board containing x and o capture all regions that are four directionally surrounded by x a region is captured by flipping all zeroes for all into x's in that surrounded region let's understand the example this example one uh fli...
Surrounded Regions
surrounded-regions
Given an `m x n` matrix `board` containing `'X'` and `'O'`, _capture all regions that are 4-directionally surrounded by_ `'X'`. A region is **captured** by flipping all `'O'`s into `'X'`s in that surrounded region. **Example 1:** **Input:** board = \[\[ "X ", "X ", "X ", "X "\],\[ "X ", "O ", "O ", "X "\],\[ "X ", "...
null
Array,Depth-First Search,Breadth-First Search,Union Find,Matrix
Medium
200,286
143
this is a singly linked list based problem and in this we have to reorder the nodes of the list and we are not allowed to change the values we are allowed to actually move those nodes so if we have let's say list like one two three so it's not that if we want to let's say we want to reverse it so in that case we are no...
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,192
A Place With Learn Today We Will Talk About Another Popular Problem List Ko Difficult Connection Network Lesson And Problem Test In Amazon As Well As Mother Big Companies And Its Very Important Problem And When You Learn How To Implement In Questions Network And Basically Is Critical Connection And A Vehicle Service Ta...
Critical Connections in a Network
divide-chocolate
There are `n` servers numbered from `0` to `n - 1` connected by undirected server-to-server `connections` forming a network where `connections[i] = [ai, bi]` represents a connection between servers `ai` and `bi`. Any server can reach other servers directly or indirectly through the network. A _critical connection_ is ...
After dividing the array into K+1 sub-arrays, you will pick the sub-array with the minimum sum. Divide the sub-array into K+1 sub-arrays such that the minimum sub-array sum is as maximum as possible. Use binary search with greedy check.
Array,Binary Search
Hard
410,1056
241
Shri Ram Doctor Saheb, it would be very good to ask a question to you, if not, I will whenever you understand how to do this, you should not understand it till the end of AB. Question is a question, my brother, if you understand this then there will be more happiness. New Recommend A Graph Open GPS settings Watched the...
Different Ways to Add Parentheses
different-ways-to-add-parentheses
Given a string `expression` of numbers and operators, return _all possible results from computing all the different possible ways to group numbers and operators_. You may return the answer in **any order**. The test cases are generated such that the output values fit in a 32-bit integer and the number of different res...
null
Math,String,Dynamic Programming,Recursion,Memoization
Medium
95,224,282,2147,2328
1,796
hello everyone so let's talk about second largest digit in the stream so you are given the alpha numeric string s and return the second largest numerical digits that appears in s or negative one if it doesn't exist so we only want number so uh what you actually need to do is you create a truth set three set and storing...
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
917
hey guys how's it going today I wanted to do another Leko problem I know we haven't done one in a while and I wanted to make sure that doing these legal problems is this kind of like training right as weight lifters they lift like heavy weights it's good for us to dive into these problems whether they be easy medium or...
Reverse Only Letters
boats-to-save-people
Given a string `s`, reverse the string according to the following rules: * All the characters that are not English letters remain in the same position. * All the English letters (lowercase or uppercase) should be reversed. Return `s` _after reversing it_. **Example 1:** **Input:** s = "ab-cd" **Output:** "dc-ba...
null
Array,Two Pointers,Greedy,Sorting
Medium
null
1,823
all right let's talk about the final winner of the circuitry game so basically this is supposed to be easy so you have friend and then use uh just for a run and then there are fun prime and then you do the clockwise order so you have an integer k so k represent um the number the person you need to remove from the group...
Find the Winner of the Circular Game
determine-if-string-halves-are-alike
There are `n` friends that are playing a game. The friends are sitting in a circle and are numbered from `1` to `n` in **clockwise order**. More formally, moving clockwise from the `ith` friend brings you to the `(i+1)th` friend for `1 <= i < n`, and moving clockwise from the `nth` friend brings you to the `1st` friend...
Create a function that checks if a character is a vowel, either uppercase or lowercase.
String,Counting
Easy
null
271
Hello, my name is Suren and this is a solution with parsing lit-code task number 271 and parsing lit-code task number 271 and parsing lit-code task number 271 and Cold Strings, you may have noticed Cold and Cold Strings, you may have noticed that there is a different task number here, all because I am on the lindcode w...
Encode and Decode Strings
encode-and-decode-strings
Design an algorithm to encode **a list of strings** to **a string**. The encoded string is then sent over the network and is decoded back to the original list of strings. Machine 1 (sender) has the function: string encode(vector strs) { // ... your code return encoded\_string; } Machine 2 (receiver) has the func...
null
Array,String,Design
Medium
38,297,443,696
239
hey everyone welcome back to the channel i hope you guys are doing extremely well so today we will be solving the problem sliding window maximum from the sd sheet so what does the problem state the problem basically states you'll be given an integer array okay and you'll be given a size k equal to 3 and you need to fig...
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
1,041
welcome back guys today we are going to solve it problem 1041 robot bounded in circle so on an infinite plane a robot initially stands at location 0 and faces north the robot can receive one of the three instructions g is go straight one unit l means turn 90 degrees to the left and r means turn 90 degrees to the right ...
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
191
so lead code problem of the day and here we bring a solution for you welcome to the runtime error the place where programming begins in this video we will be solving a lead code problem of the day that is number of one bits so this is one of the easiest question we are coming across today so I highly recommend you to w...
Number of 1 Bits
number-of-1-bits
Write a function that takes the binary representation of an unsigned integer and returns the number of '1' bits it has (also known as the [Hamming weight](http://en.wikipedia.org/wiki/Hamming_weight)). **Note:** * Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input ...
null
Bit Manipulation
Easy
190,231,338,401,461,693,767
943
hello everyone welcome to day twenty third of may decode challenge and today's question is find the shortest super string in this question we are given an array of words and we need to return the smallest string that contains each string in this array as a substring if there are multiple valid answers you need to retur...
Find the Shortest Superstring
sum-of-subarray-minimums
Given an array of strings `words`, return _the smallest string that contains each string in_ `words` _as a substring_. If there are multiple valid strings of the smallest length, return **any of them**. You may assume that no string in `words` is a substring of another string in `words`. **Example 1:** **Input:** wo...
null
Array,Dynamic Programming,Stack,Monotonic Stack
Medium
2227
207
Hello Friends Welcome to the Tag Rain Today Will Solid Court Problem Quad-Core Today Will Solid Court Problem Quad-Core Today Will Solid Court Problem Quad-Core Schedule and Problems Statements Dare and Total of Namakkhor Se Switch This Fruit and Friends Se Four Labels From Zero Two Namakkhor Se Minus One and Deserving...
Course Schedule
course-schedule
There are a total of `numCourses` courses you have to take, labeled from `0` to `numCourses - 1`. You are given an array `prerequisites` where `prerequisites[i] = [ai, bi]` indicates that you **must** take course `bi` first if you want to take course `ai`. * For example, the pair `[0, 1]`, indicates that to take cou...
This problem is equivalent to finding if a cycle exists in a directed graph. If a cycle exists, no topological ordering exists and therefore it will be impossible to take all courses. Topological Sort via DFS - A great video tutorial (21 minutes) on Coursera explaining the basic concepts of Topological Sort. Topologica...
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Medium
210,261,310,630
1,365
hello so today we are going to do this problem called how many numbers are smaller than count numbers so what we have is an array of numbers and for each number we want to find out how many numbers in the array are smaller than it so each number I you have to come the number of da Vinci inserted such that and she is di...
How Many Numbers Are Smaller Than the Current Number
how-many-numbers-are-smaller-than-the-current-number
Given the array `nums`, for each `nums[i]` find out how many numbers in the array are smaller than it. That is, for each `nums[i]` you have to count the number of valid `j's` such that `j != i` **and** `nums[j] < nums[i]`. Return the answer in an array. **Example 1:** **Input:** nums = \[8,1,2,2,3\] **Output:** \[4,...
null
null
Easy
null
1,836
and unsorted linglist giving the head of a link list find all the values that appear more than once in the list and delete the notes that have any of those values so and we should return the linked list after so what we have here is a link list that we have and it says if it's there is a duplicate value like number two...
Remove Duplicates From an Unsorted Linked List
count-ways-to-make-array-with-product
Given the `head` of a linked list, find all the values that appear **more than once** in the list and delete the nodes that have any of those values. Return _the linked list after the deletions._ **Example 1:** **Input:** head = \[1,2,3,2\] **Output:** \[1,3\] **Explanation:** 2 appears twice in the linked list, so ...
Prime-factorize ki and count how many ways you can distribute the primes among the ni positions. After prime factorizing ki, suppose there are x amount of prime factor. There are (x + n - 1) choose (n - 1) ways to distribute the x prime factors into k positions, allowing repetitions.
Array,Math,Dynamic Programming
Hard
null
1,509
Hai Haryana Roadways Question Spoon Just Follow So Question Kya Bol Rahe Naam Aalat Chus-Chus Can And Subscribe Aalat Chus-Chus Can And Subscribe Okay So Let's See Together How 532 For Example A That This Affair Question Is Okay And In This It has been told that our different size is zero at the end, so what is the say...
Minimum Difference Between Largest and Smallest Value in Three Moves
replace-employee-id-with-the-unique-identifier
You are given an integer array `nums`. In one move, you can choose one element of `nums` and change it to **any value**. Return _the minimum difference between the largest and smallest value of `nums` **after performing at most three moves**_. **Example 1:** **Input:** nums = \[5,3,2,4\] **Output:** 0 **Explanation...
null
Database
Easy
null
897
hey everybody this is larry this is day 17 of the april lego dairy challenge hit the like button to subscribe and join me on discord let me know what you think about taste bum increasing order search tree um so i only have about 20 minutes to the actual deco contest so i'm going to probably rush this a little bit um so...
Increasing Order Search Tree
prime-palindrome
Given the `root` of a binary search tree, rearrange the tree in **in-order** so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only one right child. **Example 1:** **Input:** root = \[5,3,6,2,4,null,8,1,null,null,null,7,9\] **Output:** \[1,null,2,null,3,null,4,nul...
null
Math
Medium
2202
172
A hello hi everyone today.the problem hello hi everyone today.the problem hello hi everyone today.the problem rose from his factorial lover so solidification method number 3 minutes to find type center factorial 22.10 type center factorial 22.10 type center factorial 22.10 simple subscribe this ₹1 90 lipid 15 subscribe...
Factorial Trailing Zeroes
factorial-trailing-zeroes
Given an integer `n`, return _the number of trailing zeroes in_ `n!`. Note that `n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1`. **Example 1:** **Input:** n = 3 **Output:** 0 **Explanation:** 3! = 6, no trailing zero. **Example 2:** **Input:** n = 5 **Output:** 1 **Explanation:** 5! = 120, one trailing zero. **Exa...
null
Math
Medium
233,809,2222
824
okay let's softer this coding question 824 goat Latin as you can say the question is quite long it doesn't get a lot of likes because nobody likes reading comprehension questions whether they think they are getting a coding question I guess so but the question is easy so the all we need to do is pretty much just read t...
Goat Latin
number-of-lines-to-write-string
You are given a string `sentence` that consist of words separated by spaces. Each word consists of lowercase and uppercase letters only. We would like to convert the sentence to "Goat Latin " (a made-up language similar to Pig Latin.) The rules of Goat Latin are as follows: * If a word begins with a vowel (`'a'`, `...
null
Array,String
Easy
null
787
it has been asked by Tik Tok Amazon Snapchat Bloomberg Oracle snowflake Cloud era Google Airbnb Facebook Apple Cisco cang Microsoft hi guys good morning welcome back to new video I hope that you guys are doing good in this UNC problem cheapest flight with K stops and again this is not going to be other see the separati...
Cheapest Flights Within K Stops
sliding-puzzle
There are `n` cities connected by some number of flights. You are given an array `flights` where `flights[i] = [fromi, toi, pricei]` indicates that there is a flight from city `fromi` to city `toi` with cost `pricei`. You are also given three integers `src`, `dst`, and `k`, return _**the cheapest price** from_ `src` _...
Perform a breadth-first-search, where the nodes are the puzzle boards and edges are if two puzzle boards can be transformed into one another with one move.
Array,Breadth-First Search,Matrix
Hard
null
152
hello guys I'm in this video we shall see another problem on code maximum product subarray so given integer array find a subarray that has the largest product and WR the product so let sech and it they will the answer it will fit in within the 32bit integer so we not to worry about any overflow condition here because t...
Maximum Product Subarray
maximum-product-subarray
Given an integer array `nums`, find a subarray that has the largest product, and return _the product_. The test cases are generated so that the answer will fit in a **32-bit** integer. **Example 1:** **Input:** nums = \[2,3,-2,4\] **Output:** 6 **Explanation:** \[2,3\] has the largest product 6. **Example 2:** **I...
null
Array,Dynamic Programming
Medium
53,198,238,628,713
338
hello everyone welcome back to the channel today we are going to do counting bits of lead code so let's understand the question first then we will move to the approach so given an integer n return an array answer of length n plus 1 such that for each i z i is less than 0 to n answer i is the number of ones in the binar...
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
946
so guys this is the polyglot programmer i haven't made any videos in like a week i've been really uh studying a lot um but uh i'm still doing exercise though i'm just not doing so many videos to be honest uh i make these videos because uh one i wanna try to help people that are struggling with this exercise just like i...
Validate Stack Sequences
smallest-range-ii
Given two integer arrays `pushed` and `popped` each with distinct values, return `true` _if this could have been the result of a sequence of push and pop operations on an initially empty stack, or_ `false` _otherwise._ **Example 1:** **Input:** pushed = \[1,2,3,4,5\], popped = \[4,5,3,2,1\] **Output:** true **Explana...
null
Array,Math,Greedy,Sorting
Medium
null
1,663
Person January Toilet Today Smallest Traffic taken out and clicked on the table subscribe The Video then subscribe to the Page if you liked The Video then subscribe to the Page Loot for example in this question in more All Cars subscribe and subscribe this Video plz subscribe 373 subscribe to ki system portal for autom...
Smallest String With A Given Numeric Value
detect-cycles-in-2d-grid
The **numeric value** of a **lowercase character** is defined as its position `(1-indexed)` in the alphabet, so the numeric value of `a` is `1`, the numeric value of `b` is `2`, the numeric value of `c` is `3`, and so on. The **numeric value** of a **string** consisting of lowercase characters is defined as the sum of...
Keep track of the parent (previous position) to avoid considering an invalid path. Use DFS or BFS and keep track of visited cells to see if there is a cycle.
Array,Depth-First Search,Breadth-First Search,Union Find,Matrix
Medium
null
1,970
all right let's look at this problem called last day where you can still cross that's our read so we are given a matrix a 2d Matrix and the cells values are 0 and 1. zero depends land and one represents water and we are given the rows and Columns of The Matrix initially on day 0 entire Matrix is and that means the enti...
Last Day Where You Can Still Cross
sorting-the-sentence
There is a **1-based** binary matrix where `0` represents land and `1` represents water. You are given integers `row` and `col` representing the number of rows and columns in the matrix, respectively. Initially on day `0`, the **entire** matrix is **land**. However, each day a new cell becomes flooded with **water**. ...
Divide the string into the words as an array of strings Sort the words by removing the last character from each word and sorting according to it
String,Sorting
Easy
2168
73
Jhaal Hello Everyone Welcome to Late for Office Today in this video will be discussing about matrix where the question is giving a crochet and tricks and different elements heroine set an terro and kolam to listen all elements accept this element R15 V2 row associated with 028 play Battery Saver Mode On Key Murti Fit H...
Set Matrix Zeroes
set-matrix-zeroes
Given an `m x n` integer matrix `matrix`, if an element is `0`, set its entire row and column to `0`'s. You must do it [in place](https://en.wikipedia.org/wiki/In-place_algorithm). **Example 1:** **Input:** matrix = \[\[1,1,1\],\[1,0,1\],\[1,1,1\]\] **Output:** \[\[1,0,1\],\[0,0,0\],\[1,0,1\]\] **Example 2:** **In...
If any cell of the matrix has a zero we can record its row and column number using additional memory. But if you don't want to use extra memory then you can manipulate the array instead. i.e. simulating exactly what the question says. Setting cell values to zero on the fly while iterating might lead to discrepancies. ...
Array,Hash Table,Matrix
Medium
289,2244,2259,2314
122
foreign problem and the problem's name is best time to buy and sell stock too please take a look at the previous question I'll leave a link to that video in the description box below so similar to that question inside this question we are given the integer array prices where prices of I is going to be the price of a gi...
Best Time to Buy and Sell Stock II
best-time-to-buy-and-sell-stock-ii
You are given an integer array `prices` where `prices[i]` is the price of a given stock on the `ith` day. On each day, you may decide to buy and/or sell the stock. You can only hold **at most one** share of the stock at any time. However, you can buy it then immediately sell it on the **same day**. Find and return _t...
null
Array,Dynamic Programming,Greedy
Medium
121,123,188,309,714
1,556
Looted on the handle, we do this garlic to Prabha that both problem if question ratio Allah given in teacher and not as a thousand separate attention from unknown number one should you do take 98100 a drama them this number this Vikram Samvat 1551 Front plundering 94 for 20 minutes on encroachment 12345 1.251 digit on ...
Thousand Separator
make-two-arrays-equal-by-reversing-sub-arrays
Given an integer `n`, add a dot ( ". ") as the thousands separator and return it in string format. **Example 1:** **Input:** n = 987 **Output:** "987 " **Example 2:** **Input:** n = 1234 **Output:** "1.234 " **Constraints:** * `0 <= n <= 231 - 1`
Each element of target should have a corresponding element in arr, and if it doesn't have a corresponding element, return false. To solve it easiely you can sort the two arrays and check if they are equal.
Array,Hash Table,Sorting
Easy
null
523
um hello so today we are going to do this problem which is part of lead code October daily challenge continuous sub array sum so the problem says we have an array of numbers and then integer K and we want to return true if numbers has a continuous sub array of size at least two such that the elements sum up to a multip...
Continuous Subarray Sum
continuous-subarray-sum
Given an integer array nums and an integer k, return `true` _if_ `nums` _has a **good subarray** or_ `false` _otherwise_. A **good subarray** is a subarray where: * its length is **at least two**, and * the sum of the elements of the subarray is a multiple of `k`. **Note** that: * A **subarray** is a contiguo...
null
Array,Hash Table,Math,Prefix Sum
Medium
560,2119,2240
334
hello friends welcome to joy of life so another medium problem from lead for today the problem number is 334 so it's a increasing triplet sequence given an integer array nouns return true if there exists a triple of indices i j k such that i less than j less than k and num psi less than num c less than num scheme if no...
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
1,351
hello and welcome to another daily lead code challenge let's begin our daily question uh 1 351 count negative numbers in assorted Matrix so given an M by n Matrix grid which is sorted in non-increasing order both row wise and non-increasing order both row wise and non-increasing order both row wise and column wise so d...
Count Negative Numbers in a Sorted Matrix
replace-the-substring-for-balanced-string
Given a `m x n` matrix `grid` which is sorted in non-increasing order both row-wise and column-wise, return _the number of **negative** numbers in_ `grid`. **Example 1:** **Input:** grid = \[\[4,3,2,-1\],\[3,2,1,-1\],\[1,1,-1,-2\],\[-1,-1,-2,-3\]\] **Output:** 8 **Explanation:** There are 8 negatives number in the ma...
Use 2-pointers algorithm to make sure all amount of characters outside the 2 pointers are smaller or equal to n/4. That means you need to count the amount of each letter and make sure the amount is enough.
String,Sliding Window
Medium
null
1,609
Hello Hi Everyone Welcome To My Channel It's All The Problem Even Not Tree To Avoid You Never Know What If It Means The Flying Condition Staff Nurses Subscription For All Volunteers Values ​​In Increasing Order From Left To Volunteers Values ​​In Increasing Order From Left To Volunteers Values ​​In Increasing Order Fro...
Even Odd Tree
find-all-the-lonely-nodes
A binary tree is named **Even-Odd** if it meets the following conditions: * The root of the binary tree is at level index `0`, its children are at level index `1`, their children are at level index `2`, etc. * For every **even-indexed** level, all nodes at the level have **odd** integer values in **strictly increa...
Do a simple tree traversal, try to check if the current node is lonely or not. Node is lonely if at least one of the left/right pointers is null.
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
563,1005
1,637
hey everyone today we are going to solve the r question why is the partical area between two points containing no points okay so let me explain with this example so we need to find the widest vertical area so simply we sort x coordinate in input array and find the widest area so x coordinate should be a left number so ...
Widest Vertical Area Between Two Points Containing No Points
string-compression-ii
Given `n` `points` on a 2D plane where `points[i] = [xi, yi]`, Return _the **widest vertical area** between two points such that no points are inside the area._ A **vertical area** is an area of fixed-width extending infinitely along the y-axis (i.e., infinite height). The **widest vertical area** is the one with the ...
Use dynamic programming. The state of the DP can be the current index and the remaining characters to delete. Having a prefix sum for each character can help you determine for a certain character c in some specific range, how many characters you need to delete to merge all occurrences of c in that range.
String,Dynamic Programming
Hard
null
994
this is a problem where we are given a few oranges some of them are rotten some of them are fresh and we are asked to calculate in how much time all the fresh oranges will get rotten and uh this is a question which has been very frequently asked in amazon interviews and at least 120 people have reported that they have ...
Rotting Oranges
prison-cells-after-n-days
You are given an `m x n` `grid` where each cell can have one of three values: * `0` representing an empty cell, * `1` representing a fresh orange, or * `2` representing a rotten orange. Every minute, any fresh orange that is **4-directionally adjacent** to a rotten orange becomes rotten. Return _the minimum nu...
null
Array,Hash Table,Math,Bit Manipulation
Medium
null
2
hey everyone how's it going today we're going to be solving another liquid problem and this one is called add two numbers and I think it's problem number two on the code so this problem is actually a pretty classic one it's this whole concept of being able to add two numbers there's actually a lot of variations of this...
Add Two Numbers
add-two-numbers
You are given two **non-empty** linked lists representing two non-negative integers. The digits are stored in **reverse order**, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 ...
null
Linked List,Math,Recursion
Medium
43,67,371,415,445,1031,1774
1,717
so lead code 1717 maximum score from removing substrings in this problem you're given a string s and two integers x and y and you can remove the substring a b to gain x points and the substring b a to gain white points and you need to return the maximum points that you can gain when applying these removals of substring...
Maximum Score From Removing Substrings
minimum-cost-to-connect-two-groups-of-points
You are given a string `s` and two integers `x` and `y`. You can perform two types of operations any number of times. * Remove substring `"ab "` and gain `x` points. * For example, when removing `"ab "` from `"cabxbae "` it becomes `"cxbae "`. * Remove substring `"ba "` and gain `y` points. * For examp...
Each point on the left would either be connected to exactly point already connected to some left node, or a subset of the nodes on the right which are not connected to any node Use dynamic programming with bitmasking, where the state will be (number of points assigned in first group, bitmask of points assigned in secon...
Array,Dynamic Programming,Bit Manipulation,Matrix,Bitmask
Hard
null
1,491
hey everyone welcome to Tech wide in this video we are going to solve problem number 1491 average salary excluding the minimum and maximum salary first we will see the explanation of the problem statement then the logic and the code now let's dive into the solution so here I have taken the first example from the link c...
Average Salary Excluding the Minimum and Maximum Salary
number-of-times-binary-string-is-prefix-aligned
You are given an array of **unique** integers `salary` where `salary[i]` is the salary of the `ith` employee. Return _the average salary of employees excluding the minimum and maximum salary_. Answers within `10-5` of the actual answer will be accepted. **Example 1:** **Input:** salary = \[4000,3000,1000,2000\] **Ou...
If in the step x all bulb shines then bulbs 1,2,3,..,x should shines too.
Array
Medium
319,672
629
Hello Everyone Welcome Did Not Valid Channel Pradesh Ke Par In Words Without Much Difficulty Presentation Of Platforms And Explain The Question In This Presentation On Ki Inverse Paint Coat 60 List Thyother Andhe And Subscribe Our Channel Subscribe Ki And Harm In Button Par Inverter Without this is that order against n...
K Inverse Pairs Array
k-inverse-pairs-array
For an integer array `nums`, an **inverse pair** is a pair of integers `[i, j]` where `0 <= i < j < nums.length` and `nums[i] > nums[j]`. Given two integers n and k, return the number of different arrays consist of numbers from `1` to `n` such that there are exactly `k` **inverse pairs**. Since the answer can be huge,...
null
Dynamic Programming
Hard
null
58
thank you okay let's do uh lead code 58 length of last word uh this problem just wants you to return the length the last word uh in a input string and it can get tricky because there's Extra Spaces and stuff so let's do this in JavaScript and I'm not going to use uh like split or anything like that um I'm going to use ...
Length of Last Word
length-of-last-word
Given a string `s` consisting of words and spaces, return _the length of the **last** word in the string._ A **word** is a maximal substring consisting of non-space characters only. **Example 1:** **Input:** s = "Hello World " **Output:** 5 **Explanation:** The last word is "World " with length 5. **Example 2:** ...
null
String
Easy
null
100
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 same tree so in this question we given roots of two binary trees p and Q and we have to write a function to check if they are same or not two binary trees are considered the same if they are structurall...
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
993
hey guys welcome back to my channel and i'm back again with another really interesting coding interval question video this time guys we are going to solve question number 993 cousins in binary tree before i start with the video guys just want to request you that if you have not yet subscribed to my channel then please ...
Cousins in Binary Tree
tallest-billboard
Given the `root` of a binary tree with unique values and the values of two different nodes of the tree `x` and `y`, return `true` _if the nodes corresponding to the values_ `x` _and_ `y` _in the tree are **cousins**, or_ `false` _otherwise._ Two nodes of a binary tree are **cousins** if they have the same depth with d...
null
Array,Dynamic Programming
Hard
2162
1,704
hey everybody this is larry this is day seven of the april eco daily challenge uh one weekend hope you're still hanging out sharing solving problems hit the like button hit the subscribe button join me in discord let me know what you think about today's prom determine if string halves are alike so i usually solve this ...
Determine if String Halves Are Alike
special-positions-in-a-binary-matrix
You are given a string `s` of even length. Split this string into two halves of equal lengths, and let `a` be the first half and `b` be the second half. Two strings are **alike** if they have the same number of vowels (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`, `'A'`, `'E'`, `'I'`, `'O'`, `'U'`). Notice that `s` contains uppe...
Keep track of 1s in each row and in each column. Then while iterating over matrix, if the current position is 1 and current row as well as current column contains exactly one occurrence of 1.
Array,Matrix
Easy
null
174
today we will solve a dungeon game problem it's very interesting problem here you are given a grid it's a dungeon and here in each cell either you get some reward or you get some devil waiting out for you so if you get a reward your health increases and if you face a level or some adverse situation like fire or other t...
Dungeon Game
dungeon-game
The demons had captured the princess and imprisoned her in **the bottom-right corner** of a `dungeon`. The `dungeon` consists of `m x n` rooms laid out in a 2D grid. Our valiant knight was initially positioned in **the top-left room** and must fight his way through `dungeon` to rescue the princess. The knight has an i...
null
Array,Dynamic Programming,Matrix
Hard
62,64,741,2354
118
Hello Bhai Ji gave birth to develop numbers of password triangle subscribe pass Colors channel subscribe to I will pass to friend hotspot on Russia 's hotspots of shoulder and blast 's hotspots of shoulder and blast 's hotspots of shoulder and blast box for other cities fuel's Surya film first and last boxes for Dawood...
Pascal's Triangle
pascals-triangle
Given an integer `numRows`, return the first numRows of **Pascal's triangle**. In **Pascal's triangle**, each number is the sum of the two numbers directly above it as shown: **Example 1:** **Input:** numRows = 5 **Output:** \[\[1\],\[1,1\],\[1,2,1\],\[1,3,3,1\],\[1,4,6,4,1\]\] **Example 2:** **Input:** numRows = ...
null
Array,Dynamic Programming
Easy
119
226
think we're I think we're recording so let me just check sorry about that um stop recording okay yes we're recording so how's it going guys Nick white here I do tech and live coding stuff on twitch and YouTube so if you want to check that out check the description this part of the leaked code series I'm going through e...
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
452
hello and welcome back today we have four or five to minimum number of arrows to burst balloons it says here 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 each point is the start and end of that stretched up 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,838
hello guys welcome back to the channel today we are solving another lead code problem that is one eight three eight frequency of the most frequent element 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 to this problem so let...
Frequency of the Most Frequent Element
number-of-distinct-substrings-in-a-string
The **frequency** of an element is the number of times it occurs in an array. You are given an integer array `nums` and an integer `k`. In one operation, you can choose an index of `nums` and increment the element at that index by `1`. Return _the **maximum possible frequency** of an element after performing **at mos...
Calculate the prefix hashing array for s. Use the prefix hashing array to calculate the hashing value of each substring. Compare the hashing values to determine the unique substrings. There could be collisions if you use hashing, what about double hashing.
String,Trie,Rolling Hash,Suffix Array,Hash Function
Medium
null
143
Sohe gas welcome tu code off so our next question is re order list so the question will be something like this, in this I understand you guys like we will have a link list given, a link list will be given and we They have to be re-ordered, will be given and we They have to be re-ordered, will be given and we They have ...
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
767
Hello Gas, what is told to us in today's question that we will have a given string and we have to convert and rearrange the string in such a way that two characters do not adjust, if adjacent characters get mixed, that means we cannot rearrange it in any way. Can do in which the characters are not together then we have...
Reorganize String
prime-number-of-set-bits-in-binary-representation
Given a string `s`, rearrange the characters of `s` so that any two adjacent characters are not the same. Return _any possible rearrangement of_ `s` _or return_ `" "` _if not possible_. **Example 1:** **Input:** s = "aab" **Output:** "aba" **Example 2:** **Input:** s = "aaab" **Output:** "" **Constraints:** * ...
Write a helper function to count the number of set bits in a number, then check whether the number of set bits is 2, 3, 5, 7, 11, 13, 17 or 19.
Math,Bit Manipulation
Easy
191
1,945
hi everyone welcome back for another video we are going to do analytical question the question is sum of digits after converts you are given a string as consisting of lowercase english letters and integer k first convert s into integer by replacing each letter with its position in the alphabet replace a with one b with...
Sum of Digits of String After Convert
finding-the-users-active-minutes
You are given a string `s` consisting of lowercase English letters, and an integer `k`. First, **convert** `s` into an integer by replacing each letter with its position in the alphabet (i.e., replace `'a'` with `1`, `'b'` with `2`, ..., `'z'` with `26`). Then, **transform** the integer by replacing it with the **sum ...
Try to find the number of different minutes when action happened for each user. For each user increase the value of the answer array index which matches the UAM for this user.
Array,Hash Table
Medium
null
1,171
alright welcome back to another discord question the question of today is a medium difficulty remove there are some consecutive notes from linked list given the head of a link at least we repeatedly delete consecutive sequences of nodes that sum to zero until there are no match sequence after doing so return the head o...
Remove Zero Sum Consecutive Nodes from Linked List
shortest-path-in-binary-matrix
Given the `head` of a linked list, we repeatedly delete consecutive sequences of nodes that sum to `0` until there are no such sequences. After doing so, return the head of the final linked list. You may return any such answer. (Note that in the examples below, all sequences are serializations of `ListNode` objects.)...
Do a breadth first search to find the shortest path.
Array,Breadth-First Search,Matrix
Medium
null
895
That's guys welcome back to my channel and this video we are going to solve maximum frequency stack so what is wheat statement hair design astek like data structure tips elements to this track and poverty most frequent elements from distic implement difficult figure stock class friction trucks and Empty Frequency Stag ...
Maximum Frequency Stack
shortest-path-to-get-all-keys
Design a stack-like data structure to push elements to the stack and pop the most frequent element from the stack. Implement the `FreqStack` class: * `FreqStack()` constructs an empty frequency stack. * `void push(int val)` pushes an integer `val` onto the top of the stack. * `int pop()` removes and returns the...
null
Bit Manipulation,Breadth-First Search
Hard
null
210
so hello everyone welcome back to our graph playlist and today's topic is topological sorting pass let's say a graph is zero one and two guys right we have jobs where it is saying that one cannot be executed before one before zero right otherwise right so we have jobs dependencies of the jobs we have to let's say finis...
Course Schedule II
course-schedule-ii
There are a total of `numCourses` courses you have to take, labeled from `0` to `numCourses - 1`. You are given an array `prerequisites` where `prerequisites[i] = [ai, bi]` indicates that you **must** take course `bi` first if you want to take course `ai`. * For example, the pair `[0, 1]`, indicates that to take cou...
This problem is equivalent to finding the topological order in a directed graph. If a cycle exists, no topological ordering exists and therefore it will be impossible to take all courses. Topological Sort via DFS - A great video tutorial (21 minutes) on Coursera explaining the basic concepts of Topological Sort. Topolo...
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Medium
207,269,310,444,630,1101,2220
564
hey everybody this is larry this is me doing a bonus question for the day an extra question hit the like button hit the subscribe on drama and discord especially like if especially if you'd like to see more of this um it's me trying to random one that haven't done before so i do it to do but some of these are as you ca...
Find the Closest Palindrome
find-the-closest-palindrome
Given a string `n` representing an integer, return _the closest integer (not including itself), which is a palindrome_. If there is a tie, return _**the smaller one**_. The closest is defined as the absolute difference minimized between two integers. **Example 1:** **Input:** n = "123 " **Output:** "121 " **Examp...
Will brute force work for this problem? Think of something else. Take some examples like 1234, 999,1000, etc and check their closest palindromes. How many different cases are possible? Do we have to consider only left half or right half of the string or both? Try to find the closest palindrome of these numbers- 12932, ...
Math,String
Hard
1375,1997
1,487
hey everybody there's a slurry you're watching me solve this problem live during a contest I'm gonna stop the explanation and then it's going to go into some code review some times and then just me working on a palm let me know what you think about this format hit like button to subscribe one join me on a discord link ...
Making File Names Unique
cinema-seat-allocation
Given an array of strings `names` of size `n`. You will create `n` folders in your file system **such that**, at the `ith` minute, you will create a folder with the name `names[i]`. Since two files **cannot** have the same name, if you enter a folder name that was previously used, the system will have a suffix additio...
Note you can allocate at most two families in one row. Greedily check if you can allocate seats for two families, one family or none. Process only rows that appear in the input, for other rows you can always allocate seats for two families.
Array,Hash Table,Greedy,Bit Manipulation
Medium
null
191
hi guys welcome to algorithms made easy today we will see the question number of one bits write a function that takes an unsigned integer and return the number of one bits it has this problem or this particular thing is also known as hamming weight the follow-up given with this question follow-up given with this questi...
Number of 1 Bits
number-of-1-bits
Write a function that takes the binary representation of an unsigned integer and returns the number of '1' bits it has (also known as the [Hamming weight](http://en.wikipedia.org/wiki/Hamming_weight)). **Note:** * Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input ...
null
Bit Manipulation
Easy
190,231,338,401,461,693,767
226
Google ninety percent of our Engineers use the software you wrote but you can invert a binary tree on a whiteboard so off well Max how well got rejected because he didn't know how to invert binary trees in this video you will learn how to invert binary sheets so you can get into Google during the interview we know that...
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
518
today we are solving coin change problem we are given an integer array coins representing coins of different denominations and an integer amount representing total amount of money we are supposed to make and we are expected to return the number of combinations that make up the amount it is important to note that we are...
Coin Change II
coin-change-2
You are given an integer array `coins` representing coins of different denominations and an integer `amount` representing a total amount of money. Return _the number of combinations that make up that amount_. If that amount of money cannot be made up by any combination of the coins, return `0`. You may assume that yo...
null
Array,Dynamic Programming
Medium
1393
108
Jhal Ki Hey Guys Welcome To Versions Myth TV Serials Is Related To Subscribe My Channel And Tried To Solve Problem From List Code You Can Find Land Acquisition In Description Problem Statement Balance Oil Olive Oil Property Video Zara Tonight And Liked My And Sales And Come Back The Way Request All The Route Of The Day...
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
59
hello guys welcome to algorithms made easy today we will be discussing the question spiral matrix part two in this question we are given a positive integer and we need to generate an n cross n matrix filled with the elements from one to n square in spiral order in the first example we can see the pattern in which we ne...
Spiral Matrix II
spiral-matrix-ii
Given a positive integer `n`, generate an `n x n` `matrix` filled with elements from `1` to `n2` in spiral order. **Example 1:** **Input:** n = 3 **Output:** \[\[1,2,3\],\[8,9,4\],\[7,6,5\]\] **Example 2:** **Input:** n = 1 **Output:** \[\[1\]\] **Constraints:** * `1 <= n <= 20`
null
Array,Matrix,Simulation
Medium
54,921
1,061
hi everyone welcome back to the channel and today we're going to solved code TV challenge problem number 1061 lexographically smallest equivalent string so in the given problem we have to basically find out so smallest equivalent string lexically and we have been given two strings S1 and S2 and you can say that like a ...
Lexicographically Smallest Equivalent String
number-of-valid-subarrays
You are given two strings of the same length `s1` and `s2` and a string `baseStr`. We say `s1[i]` and `s2[i]` are equivalent characters. * For example, if `s1 = "abc "` and `s2 = "cde "`, then we have `'a' == 'c'`, `'b' == 'd'`, and `'c' == 'e'`. Equivalent characters follow the usual rules of any equivalence rela...
Given a data structure that answers queries of the type to find the minimum in a range of an array (Range minimum query (RMQ) sparse table) in O(1) time. How can you solve this problem? For each starting index do a binary search with an RMQ to find the ending possible position.
Array,Stack,Monotonic Stack
Hard
2233
24
hey everyone welcome back let's solve another problem today let's look at swap nodes in pairs so we're given one linked list and we want to swap every two adjacent nodes and then return the output and they tell us we cannot modify the values it would be really easy if we could just take the values and then swap them bu...
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,615
hello everyone welcome back here's van Thompson so uh today we are going to tackle a liquor daily challenge uh Maxima Network run so I assure you this problem has some very insightful concept to grasp so uh let's start by understanding the problem at hand so we have been given a set of comprising of any cities uh inter...
Maximal Network Rank
range-sum-of-sorted-subarray-sums
There is an infrastructure of `n` cities with some number of `roads` connecting these cities. Each `roads[i] = [ai, bi]` indicates that there is a bidirectional road between cities `ai` and `bi`. The **network rank** of **two different cities** is defined as the total number of **directly** connected roads to **either...
Compute all sums and save it in array. Then just go from LEFT to RIGHT index and calculate answer modulo 1e9 + 7.
Array,Two Pointers,Binary Search,Sorting
Medium
null
1,905
uh hi friends uh welcome to my channel let's have a look at problem 1905 count sub islands so in this video we're going to follow our line of traversal algorithms to present a solution based on breadth first search here and we shall present a iterative format so this problem asks us to return the number of islands in g...
Count Sub Islands
design-authentication-manager
You are given two `m x n` binary matrices `grid1` and `grid2` containing only `0`'s (representing water) and `1`'s (representing land). An **island** is a group of `1`'s connected **4-directionally** (horizontal or vertical). Any cells outside of the grid are considered water cells. An island in `grid2` is considered ...
Using a map, track the expiry times of the tokens. When generating a new token, add it to the map with its expiry time. When renewing a token, check if it's on the map and has not expired yet. If so, update its expiry time. To count unexpired tokens, iterate on the map and check for each token if it's not expired yet.
Hash Table,Design
Medium
null
153
hello everyone in this video we will be solving the problem 153 find minimum in a rotated sorted array in the rotated sorted array we need to return the minimum element in this array if you look at example number one the variable nums contains three four five one and two if you just skim through all the elements the mi...
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
1,012
hello everyone welcome to quartus cam and today we are going to cover another hard problem from delete code that is numbers with repeated digits so the input given here is an integer and we have to return how many positive numbers that has repeated digit in that so the first input given here is 20 and the only number w...
Numbers With Repeated Digits
equal-rational-numbers
Given an integer `n`, return _the number of positive integers in the range_ `[1, n]` _that have **at least one** repeated digit_. **Example 1:** **Input:** n = 20 **Output:** 1 **Explanation:** The only positive number (<= 20) with at least 1 repeated digit is 11. **Example 2:** **Input:** n = 100 **Output:** 10 **...
null
Math,String
Hard
null
1,432
Hello viewers welcome back to my channel I hope you are doing all the problem the time uploading now become history subscribe my channel and pleased to hide and subscribe and also share with your friends to date problem is max different skin get from changing anti a Fiber should give in the Journal of Butterflies Farfa...
Max Difference You Can Get From Changing an Integer
check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree
You are given an integer `num`. You will apply the following steps exactly **two** times: * Pick a digit `x (0 <= x <= 9)`. * Pick another digit `y (0 <= y <= 9)`. The digit `y` can be equal to `x`. * Replace all the occurrences of `x` in the decimal representation of `num` by `y`. * The new integer **cannot**...
Depth-first search (DFS) with the parameters: current node in the binary tree and current position in the array of integers. When reaching at final position check if it is a leaf node.
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
3
hi everyone welcome to my channel let's solve the problem longest sub string without repeating characters so given a string as find the length of longest sub string without remitting characters so in this example one we have string abc a cbb so if we see this is a unique no character so far is repeating but when we rea...
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
500
hey everyone welcome back and today we'll be doing another Lead Core 500 Keyboard PRO and easy one given an array of string words return the word that can be typed by using the letter of alphabet on only one row of American keyboard like the image below the American keyboard the first row consists of character the firs...
Keyboard Row
keyboard-row
Given an array of strings `words`, return _the words that can be typed using letters of the alphabet on only one row of American keyboard like the image below_. In the **American keyboard**: * the first row consists of the characters `"qwertyuiop "`, * the second row consists of the characters `"asdfghjkl "`, and...
null
Array,Hash Table,String
Easy
null
58
in this problem we have a sentence of different words so there will be word one then space word two space and so on and there may be spaces in the end also so we have to find the length of last word in this sentence so you can think of multiple ways so you can start traversing from left and you can tokenize this either...
Length of Last Word
length-of-last-word
Given a string `s` consisting of words and spaces, return _the length of the **last** word in the string._ A **word** is a maximal substring consisting of non-space characters only. **Example 1:** **Input:** s = "Hello World " **Output:** 5 **Explanation:** The last word is "World " with length 5. **Example 2:** ...
null
String
Easy
null
778
welcome to june's lego challenge today's problem is swim in rising water on an n times n grid each square represents an elevation at that point i and j now rain starts to fall at time t the depth of the water everywhere is t so you can swim from a square to another four directionally adjacent square if and only if the ...
Swim in Rising Water
reorganize-string
You are given an `n x n` integer matrix `grid` where each value `grid[i][j]` represents the elevation at that point `(i, j)`. The rain starts to fall. At time `t`, the depth of the water everywhere is `t`. You can swim from a square to another 4-directionally adjacent square if and only if the elevation of both square...
Alternate placing the most common letters.
Hash Table,String,Greedy,Sorting,Heap (Priority Queue),Counting
Medium
358,621,1304
1,834
and here I present solution to day 29th of December lead quod Challenge and I hope all of you guys are following along the question is a medium level question on lead code and I totally feel the same it is one of the hot topics of Google and the concept that we will use to solve this question would be sorting and heaps...
Single-Threaded CPU
minimum-number-of-people-to-teach
You are given `n`​​​​​​ tasks labeled from `0` to `n - 1` represented by a 2D integer array `tasks`, where `tasks[i] = [enqueueTimei, processingTimei]` means that the `i​​​​​​th`​​​​ task will be available to process at `enqueueTimei` and will take `processingTimei` to finish processing. You have a single-threaded CPU...
You can just use brute force and find out for each language the number of users you need to teach Note that a user can appear in multiple friendships but you need to teach that user only once
Array,Greedy
Medium
null
1,170
hi everyone let's discuss about weekly contest under 51 second question compare string by frequency of the smallest character so frequency of smallest character determine value of a string so for example here set a set the smallest character is a with the frequency of 3 so the value of this string is 3 and CBD the smal...
Compare Strings by Frequency of the Smallest Character
shortest-common-supersequence
Let the function `f(s)` be the **frequency of the lexicographically smallest character** in a non-empty string `s`. For example, if `s = "dcce "` then `f(s) = 2` because the lexicographically smallest character is `'c'`, which has a frequency of 2. You are given an array of strings `words` and another array of query s...
We can find the length of the longest common subsequence between str1[i:] and str2[j:] (for all (i, j)) by using dynamic programming. We can use this information to recover the longest common supersequence.
String,Dynamic Programming
Hard
1250
1,099
when this is Fisher coder here today is Thanksgiving holiday of 2019 so happy Thanksgiving to everybody out there still watching lead code still practicing lead coding the muse happy holiday Happy Thanksgiving and also I really would encourage you to hit that like button on this video and also don't forget to subscribe...
Two Sum Less Than K
path-with-maximum-minimum-value
Given an array `nums` of integers and integer `k`, return the maximum `sum` such that there exists `i < j` with `nums[i] + nums[j] = sum` and `sum < k`. If no `i`, `j` exist satisfying this equation, return `-1`. **Example 1:** **Input:** nums = \[34,23,1,24,75,33,54,8\], k = 60 **Output:** 58 **Explanation:** We can...
What if we sort each cell of the matrix by the value? Don't include small values in your path if you can only include large values. Let's keep adding a possible cell to use in the path incrementally with decreasing values. If the start and end cells are connected then we don't need to add more cells. Use union-find dat...
Array,Depth-First Search,Breadth-First Search,Union Find,Heap (Priority Queue),Matrix
Medium
1753
1,704
hi everyone welcome back to the channel and today we solve e code daily challenge problem number 174 determine if strings halves are alike so we'll check out the problem statement and then we'll uh check out the approach which we're going to use it's a really simple problem to solve and yeah let's check out the problem...
Determine if String Halves Are Alike
special-positions-in-a-binary-matrix
You are given a string `s` of even length. Split this string into two halves of equal lengths, and let `a` be the first half and `b` be the second half. Two strings are **alike** if they have the same number of vowels (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`, `'A'`, `'E'`, `'I'`, `'O'`, `'U'`). Notice that `s` contains uppe...
Keep track of 1s in each row and in each column. Then while iterating over matrix, if the current position is 1 and current row as well as current column contains exactly one occurrence of 1.
Array,Matrix
Easy
null
1,802
hi guys welcome to algorithms Made Easy my name is khushboo and in this video we are going to see the question maximum value at a given index in a bounded array so let's go through the question you are given three positive integers in index and maximum and you want to construct an array nums which is 0 indexed which sa...
Maximum Value at a Given Index in a Bounded Array
number-of-students-unable-to-eat-lunch
You are given three positive integers: `n`, `index`, and `maxSum`. You want to construct an array `nums` (**0-indexed**) that satisfies the following conditions: * `nums.length == n` * `nums[i]` is a **positive** integer where `0 <= i < n`. * `abs(nums[i] - nums[i+1]) <= 1` where `0 <= i < n-1`. * The sum of a...
Simulate the given in the statement Calculate those who will eat instead of those who will not.
Array,Stack,Queue,Simulation
Easy
2195
258
hey everyone today we are going to service a little question how to digits giving my integer named repeatedly at all its digits until the result has only one digit and return it so let's see the example so you are given 38 output is 2 because so we can separate 38 so numbers like three and eight so this calculation res...
Add Digits
add-digits
Given an integer `num`, repeatedly add all its digits until the result has only one digit, and return it. **Example 1:** **Input:** num = 38 **Output:** 2 **Explanation:** The process is 38 --> 3 + 8 --> 11 11 --> 1 + 1 --> 2 Since 2 has only one digit, return it. **Example 2:** **Input:** num = 0 **Output:** 0 *...
A naive implementation of the above process is trivial. Could you come up with other methods? What are all the possible results? How do they occur, periodically or randomly? You may find this Wikipedia article useful.
Math,Simulation,Number Theory
Easy
202,1082,2076,2264
746
going over the Java solution for lead code 746 Min cost climbing stairs you are given an integer array cost where cost I is the cost of the I'd step on a staircase once you pay the cost you can either jump one or two steps you can either start from the step with index 0 or the step with index 1 return the minimum cost ...
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
916
hello everyone welcome to my channel it's all the problem whatsapp send sauvir awal distic of this letter no say davy in subscribe birthday is every letter in vehicles including multiplicity between slide all characters of world vs wave and for example you are subscribe w8 sexual behavior inner World This Week Busy Sub...
Word Subsets
decoded-string-at-index
You are given two string arrays `words1` and `words2`. A string `b` is a **subset** of string `a` if every letter in `b` occurs in `a` including multiplicity. * For example, `"wrr "` is a subset of `"warrior "` but is not a subset of `"world "`. A string `a` from `words1` is **universal** if for every string `b` i...
null
String,Stack
Medium
null
713
Jhaal Hello Hi Guys Welcome to Questions Today's Question is the Weight Lose Bank's In This Question Beer Drinking Are Positive Integers Personality Account and Friends in Number of Morning Swift of All Elements in Directions Amazing's Intermediate Hindi Pimple Wear Dresses Only You All the subscribe this Video in this...
Subarray Product Less Than K
subarray-product-less-than-k
Given an array of integers `nums` and an integer `k`, return _the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than_ `k`. **Example 1:** **Input:** nums = \[10,5,2,6\], k = 100 **Output:** 8 **Explanation:** The 8 subarrays that have product less than 100 are: ...
For each j, let opt(j) be the smallest i so that nums[i] * nums[i+1] * ... * nums[j] is less than k. opt is an increasing function.
Array,Sliding Window
Medium
152,325,560,1083,2233
448
hi everyone today we are going to solve the readable question find all numbers disappeared in Array so you are given already enough of any integers where NSI is in the range from 1 to n return array of all integers in the range one from 1 to n that do not appear in numbers so let's see the example so you are given 4 3 ...
Find All Numbers Disappeared in an Array
find-all-numbers-disappeared-in-an-array
Given an array `nums` of `n` integers where `nums[i]` is in the range `[1, n]`, return _an array of all the integers in the range_ `[1, n]` _that do not appear in_ `nums`. **Example 1:** **Input:** nums = \[4,3,2,7,8,2,3,1\] **Output:** \[5,6\] **Example 2:** **Input:** nums = \[1,1\] **Output:** \[2\] **Constrain...
This is a really easy problem if you decide to use additional memory. For those trying to write an initial solution using additional memory, think counters! However, the trick really is to not use any additional space than what is already available to use. Sometimes, multiple passes over the input array help find the s...
Array,Hash Table
Easy
41,442,2107,2305