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
505
all right so this question is the maze too and this question is pretty similar to maze one and pretty uh the concept is pretty similar basically you just have to roll the ball so uh you just keep rolling and go until you hit the wall and you change your direction and then basically you want to reach the destination and...
The Maze II
the-maze-ii
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,Heap (Priority Queue),Shortest Path
Medium
490,499
1,367
how's it going everyone michael here so today i'm going to go over yet again another algorithm problem called linked list in binary tree this problem is really useful to learn because it involves so many different topics obviously linked lists and binary trees but then there's also depth first search breadth first sear...
Linked List in Binary Tree
maximum-height-by-stacking-cuboids
Given a binary tree `root` and a linked list with `head` as the first node. Return True if all the elements in the linked list starting from the `head` correspond to some _downward path_ connected in the binary tree otherwise return False. In this context downward path means a path that starts at some node and goes d...
Does the dynamic programming sound like the right algorithm after sorting? Let's say box1 can be placed on top of box2. No matter what orientation box2 is in, we can rotate box1 so that it can be placed on top. Why don't we orient everything such that height is the biggest?
Array,Dynamic Programming,Sorting
Hard
2123
134
hi i am ayushi rawat and welcome to my channel today we will discuss the september lead code challenge week 4 problem day 23 gas station now let's have a look at the problem statement there are n gas stations along a circular route where the amount of gas at each station i is gas of i you have a car with an unlimited g...
Gas Station
gas-station
There are `n` gas stations along a circular route, where the amount of gas at the `ith` station is `gas[i]`. You have a car with an unlimited gas tank and it costs `cost[i]` of gas to travel from the `ith` station to its next `(i + 1)th` station. You begin the journey with an empty tank at one of the gas stations. Gi...
null
Array,Greedy
Medium
1346
201
hey everyone today we are going to solve the equation bitwise and of numbers range okay so look at this so left side is decimal and the right side is binary and the a trick of bitwise operation is that so bitwise operation with any two numbers will always produce a number less than or equal to smaller number so let's t...
Bitwise AND of Numbers Range
bitwise-and-of-numbers-range
Given two integers `left` and `right` that represent the range `[left, right]`, return _the bitwise AND of all numbers in this range, inclusive_. **Example 1:** **Input:** left = 5, right = 7 **Output:** 4 **Example 2:** **Input:** left = 0, right = 0 **Output:** 0 **Example 3:** **Input:** left = 1, right = 2147...
null
Bit Manipulation
Medium
null
767
hello guys this is interview prep hello at this site today we are going to discuss the lead code problem reorganize the string so let's discuss about the problem is given a string s check if the letters can be arranged so that two characters that are adjacent to each other are not same if possible output any possible r...
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
287
hey so welcome back and here's another daily code problem so today we're doing the question called find the duplicate number and so all that we're given here is an array where it's essentially just a list of integers such that there's always going to be uh one and only one duplicate now that duplicate number could repe...
Find the Duplicate Number
find-the-duplicate-number
Given an array of integers `nums` containing `n + 1` integers where each integer is in the range `[1, n]` inclusive. There is only **one repeated number** in `nums`, return _this repeated number_. You must solve the problem **without** modifying the array `nums` and uses only constant extra space. **Example 1:** **...
null
Array,Two Pointers,Binary Search,Bit Manipulation
Medium
41,136,142,268,645
1,835
hey everybody this is larry this is me going over week four of the weekly contest 237 fine exhaust sum of all pairs bit wise and so this one actually a lot of people end up getting it uh maybe uh so hit the like button hit the subscribe button join me on discord let me see uh so now we're about when i'm recording this ...
Find XOR Sum of All Pairs Bitwise AND
decode-xored-permutation
The **XOR sum** of a list is the bitwise `XOR` of all its elements. If the list only contains one element, then its **XOR sum** will be equal to this element. * For example, the **XOR sum** of `[1,2,3,4]` is equal to `1 XOR 2 XOR 3 XOR 4 = 4`, and the **XOR sum** of `[3]` is equal to `3`. You are given two **0-inde...
Compute the XOR of the numbers between 1 and n, and think about how it can be used. Let it be x. Think why n is odd. perm[0] = x XOR encoded[1] XOR encoded[3] XOR encoded[5] ... perm[i] = perm[i-1] XOR encoded[i-1]
Array,Bit Manipulation
Medium
null
27
so Hello everyone, Let's solve the next problem from the lead code, this is the removal element, respectively, here is its number and this joke So let's have three and have already solved, which means let's move on to the solution in ideas, we need to decorate the method, the second method means What is the task worth,...
Remove Element
remove-element
Given an integer array `nums` and an integer `val`, remove all occurrences of `val` in `nums` [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm). The order of the elements may be changed. Then return _the number of elements in_ `nums` _which are not equal to_ `val`. Consider the number of elements in `nu...
The problem statement clearly asks us to modify the array in-place and it also says that the element beyond the new length of the array can be anything. Given an element, we need to remove all the occurrences of it from the array. We don't technically need to remove that element per-say, right? We can move all the occu...
Array,Two Pointers
Easy
26,203,283
1,845
Hello everyone welcome to my channel quote story with mike so today we are going to do video number 13 of our data structure design playlist lead code number 845 is a very simple question ok and we will make it in three ways ok and time complexity of all You will understand well. The name of the question with OK Intu i...
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,417
welcome back everyone we're gonna be solving link code 1417 reformat the string so we're given an alphanumeric string called s where alphanumeric is just a string consisting of lowercase English letters and digits and they want us to find a permutation of the string where no letter is followed by another letter and no ...
Reformat The String
reformat-the-string
You are given an alphanumeric string `s`. (**Alphanumeric string** is a string consisting of lowercase English letters and digits). You have to find a permutation of the string where no letter is followed by another letter and no digit is followed by another digit. That is, no two adjacent characters have the same typ...
null
null
Easy
null
1,827
hey everybody this is larry this is me going with q1 of the buy weekly contest 50 minimum operations to make the array increasing so this one was kind of straightforward in that because as everything has to be strictly increasing you just do it in a greedy way which is that for each number you make it the pre you eithe...
Minimum Operations to Make the Array Increasing
invalid-tweets
You are given an integer array `nums` (**0-indexed**). In one operation, you can choose an element of the array and increment it by `1`. * For example, if `nums = [1,2,3]`, you can choose to increment `nums[1]` to make `nums = [1,**3**,3]`. Return _the **minimum** number of operations needed to make_ `nums` _**stri...
null
Database
Easy
null
338
hey guys welcome back to a new video in today's video we're looking at a lead code question and the problem's name is counting bits in this question we're given an integer n we have to written an array called ans of length n plus 1 such that for every element present inside answer phi 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
206
hey friends welcome back to the channel if you're new here my name is anar and i'm a self-taught software developer i'm a self-taught software developer i'm a self-taught software developer today i thought we could look at a very popular coding interview question reverse a linked list so we start off with a linked list...
Reverse Linked List
reverse-linked-list
Given the `head` of a singly linked list, reverse the list, and return _the reversed list_. **Example 1:** **Input:** head = \[1,2,3,4,5\] **Output:** \[5,4,3,2,1\] **Example 2:** **Input:** head = \[1,2\] **Output:** \[2,1\] **Example 3:** **Input:** head = \[\] **Output:** \[\] **Constraints:** * The number...
null
Linked List,Recursion
Easy
92,156,234,2196,2236
149
hey everyone welcome back and let's write some more neat code today so today let's solve the problem Max points on a line The Prompt is pretty simple we're given an array of points that exist on some two-dimensional grid with an x-axis some two-dimensional grid with an x-axis some two-dimensional grid with an x-axis an...
Max Points on a Line
max-points-on-a-line
Given an array of `points` where `points[i] = [xi, yi]` represents a point on the **X-Y** plane, return _the maximum number of points that lie on the same straight line_. **Example 1:** **Input:** points = \[\[1,1\],\[2,2\],\[3,3\]\] **Output:** 3 **Example 2:** **Input:** points = \[\[1,1\],\[3,2\],\[5,3\],\[4,1\]...
null
Array,Hash Table,Math,Geometry
Hard
356,2287
1,930
In this problem, we are given a string. We have to return a unique palindrome of length three from it, which is the sequence of the string. What is your palindrome? Read the same forward and backward like A B A. This is your palindrome B A B. This is your palindrome. What happens to your subsequence? You can delete som...
Unique Length-3 Palindromic Subsequences
maximum-number-of-consecutive-values-you-can-make
Given a string `s`, return _the number of **unique palindromes of length three** that are a **subsequence** of_ `s`. Note that even if there are multiple ways to obtain the same subsequence, it is still only counted **once**. A **palindrome** is a string that reads the same forwards and backwards. A **subsequence** ...
If you can make the first x values and you have a value v, then you can make all the values ≤ v + x Sort the array of coins. You can always make the value 0 so you can start with x = 0. Process the values starting from the smallest and stop when there is a value that cannot be achieved with the current x.
Array,Greedy
Medium
330
137
hello there so today I'm talking about the second a single number question 137 which is full upper to 136 single number so just gonna spend like two minutes one minute I quickly refresh the approach to 136 the question is as follows we have array of integers at the element appear twice except for one number that appear...
Single Number II
single-number-ii
Given an integer array `nums` where every element appears **three times** except for one, which appears **exactly once**. _Find the single element and return it_. You must implement a solution with a linear runtime complexity and use only constant extra space. **Example 1:** **Input:** nums = \[2,2,3,2\] **Output:**...
null
Array,Bit Manipulation
Medium
136,260
878
Hello friends, in today's video we are going to discuss about this product, the land is nickel, number problem is a very good problem, the video will remain cancer, subscribe to it, knowledge is any number, it is either from someone, subscribe and now three letters and subscribe. Do subscribe, it's loot, what will we d...
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
215
hello everyone welcome to learn overflow if you haven't subscribed to this channel make sure you subscribe to this for regular latecode videos so in this video we will look into this problem the kth largest element in an era in the last video i have already discussed two approaches to do this uh but solve this particul...
Kth Largest Element in an Array
kth-largest-element-in-an-array
Given an integer array `nums` and an integer `k`, return _the_ `kth` _largest element in the array_. Note that it is the `kth` largest element in the sorted order, not the `kth` distinct element. You must solve it in `O(n)` time complexity. **Example 1:** **Input:** nums = \[3,2,1,5,6,4\], k = 2 **Output:** 5 **Ex...
null
Array,Divide and Conquer,Sorting,Heap (Priority Queue),Quickselect
Medium
324,347,414,789,1014,2113,2204,2250
243
and this is shoulders over distance so you're giving an array of string and also two words and so you want to find out the shortest distance between these two worms you know this all right so it's pretty straightforward so uh for coding uh it's in here and then for the practice it's over here so you want to find out th...
Shortest Word Distance
shortest-word-distance
Given an array of strings `wordsDict` and two different strings that already exist in the array `word1` and `word2`, return _the shortest distance between these two words in the list_. **Example 1:** **Input:** wordsDict = \[ "practice ", "makes ", "perfect ", "coding ", "makes "\], word1 = "coding ", word2 = "...
null
Array,String
Easy
244,245,2320
73
in this video we'll be going over set matrix zero so given m times n matrix if an element is zero set its entire row and column to zero do it in place so my first example we have a zero in this cell then we fail as rho to zero then we fill this column to zero so let's go over the follow up a straightforward solution us...
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
107
looking at lead code number 107 binary tree level order traversal 2. this is very similar to binary tree level order traversal 1 which is also a solution in this playlist highly recommend checking that out if you haven't already we're going to use a very similar pattern and just do a slight modification to solve this p...
Binary Tree Level Order Traversal II
binary-tree-level-order-traversal-ii
Given the `root` of a binary tree, return _the bottom-up level order traversal of its nodes' values_. (i.e., from left to right, level by level from leaf to root). **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[\[15,7\],\[9,20\],\[3\]\] **Example 2:** **Input:** root = \[1\] **Output:** \[...
null
Tree,Breadth-First Search,Binary Tree
Medium
102,637
81
Jai Shri Ram Friends, today we are going to solve the problem, this problem is given to you in the late code under the medium category and it means whatever good company you have like Google Microsoft Adobe, all these things are ahead in the company when at the time of phone interview like this This problem can be aske...
Search in Rotated Sorted Array II
search-in-rotated-sorted-array-ii
There is an integer array `nums` sorted in non-decreasing order (not necessarily with **distinct** values). Before being passed to your function, `nums` is **rotated** at an unknown pivot index `k` (`0 <= k < nums.length`) such that the resulting array is `[nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nu...
null
Array,Binary Search
Medium
33
201
hey everybody this is Larry this is day 21st of the Leo daily challenge hit the like button hit the Subscribe button when my computer loads uh and yeah leave me a comment what you think about this uh problem and this video and all loading and stuff today's problem is to a one bitwise end of numers range given two integ...
Bitwise AND of Numbers Range
bitwise-and-of-numbers-range
Given two integers `left` and `right` that represent the range `[left, right]`, return _the bitwise AND of all numbers in this range, inclusive_. **Example 1:** **Input:** left = 5, right = 7 **Output:** 4 **Example 2:** **Input:** left = 0, right = 0 **Output:** 0 **Example 3:** **Input:** left = 1, right = 2147...
null
Bit Manipulation
Medium
null
326
so the problem is very simple there they are given an integer let's say it may be 27 or 45 or 54. you have to find whether it's a power of 3 or not so what the initial approach we ends on the problem is uh let's start with the value we have the value n equal to 27. and we start from 1. okay we have our Equalization the...
Power of Three
power-of-three
Given an integer `n`, return _`true` if it is a power of three. Otherwise, return `false`_. An integer `n` is a power of three, if there exists an integer `x` such that `n == 3x`. **Example 1:** **Input:** n = 27 **Output:** true **Explanation:** 27 = 33 **Example 2:** **Input:** n = 0 **Output:** false **Explanat...
null
Math,Recursion
Easy
231,342,1889
817
we are giving the head of a linked list containing unique integer values and integer array nums so we are having the head of a linked list and we also having an integer re nums we want to return the number of connected component in nums where two values are connected if they appear consecutive consecutively in the link...
Linked List Components
design-hashmap
You are given the `head` of a linked list containing unique integer values and an integer array `nums` that is a subset of the linked list values. Return _the number of connected components in_ `nums` _where two values are connected if they appear **consecutively** in the linked list_. **Example 1:** **Input:** head...
null
Array,Hash Table,Linked List,Design,Hash Function
Easy
816,1337
329
hey what's up guys uh this is juan here so today let's take a look at today's daily challenge problem number 329 longest increasing path in the matrix so you're given like m times an integers matrix and you need to return the length of the longest increasing path in the matrix and so the path only happens in uh in four...
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
767
okay so today's second question is 767 reorganise a string given a string s check if the letters can be rearranged so that the two characters are adjacent to each other are not the same so meaning that we have two savage the two brands insert some fillings into the two brands if possible we return any possible read aud...
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
383
hey guys welcome back to my channel and i'm back again with another really interesting coding interview question video this time guys we are going to solve question number 383 of lead code called ransom note before i start with the problem statement guys if you have not yet subscribed to my channel then please do subsc...
Ransom Note
ransom-note
Given two strings `ransomNote` and `magazine`, return `true` _if_ `ransomNote` _can be constructed by using the letters from_ `magazine` _and_ `false` _otherwise_. Each letter in `magazine` can only be used once in `ransomNote`. **Example 1:** **Input:** ransomNote = "a", magazine = "b" **Output:** false **Example ...
null
Hash Table,String,Counting
Easy
691
407
hey welcome back and today we're going to talk about this trapping ring water number two we actually talked about the trapping ring water number one before by using either stack or two pointers and let's go ahead and read the question for this one given eight m times n matrix of the positive integers representing the h...
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
72
of another lyrical problem 72 added distance so we are giving two words word one and the word two we first need to use the insert delete on replace to make the word 1 equals to where the two we need to calculate the minimum calculations so for example this example one the minimum calculation is three we just need to re...
Edit Distance
edit-distance
Given two strings `word1` and `word2`, return _the minimum number of operations required to convert `word1` to `word2`_. You have the following three operations permitted on a word: * Insert a character * Delete a character * Replace a character **Example 1:** **Input:** word1 = "horse ", word2 = "ros " **O...
null
String,Dynamic Programming
Hard
161,583,712,1105,2311
1,353
Everyone, today we are going to discuss, this is the problem of G, the problem will be found, the quarter number was that there are benefits, we will follow the maximum number of events and cancer, okay, so what is it that we live in NDA, okay, that is, whatever it is. It means that the first one who is favorite was av...
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,847
hello everyone let's take a look at the code on 1847 closest rooms it's a hard problem okay so uh if you haven't raised the problem you can give some time to read about this problem so basically um there are like some rooms this is a room index and this is a set of rooms and we have a bunch of progress for each car we ...
Closest Room
largest-subarray-length-k
There is a hotel with `n` rooms. The rooms are represented by a 2D integer array `rooms` where `rooms[i] = [roomIdi, sizei]` denotes that there is a room with room number `roomIdi` and size equal to `sizei`. Each `roomIdi` is guaranteed to be **unique**. You are also given `k` queries in a 2D array `queries` where `qu...
Search for the largest integer in the range [0, n - k] This integer is the first element in the subarray. You should take it with the k - 1 elements after it.
Array,Greedy
Easy
null
7
how's it going guys today we're gonna be going over a problem called reverse integer is a leak code problem that's commonly asked by Google Adobe Bloomberg Microsoft Alibaba uber Airbnb lyft Facebook and Nettie's our problem description says given a 32-bit problem description says given a 32-bit problem description say...
Reverse Integer
reverse-integer
Given a signed 32-bit integer `x`, return `x` _with its digits reversed_. If reversing `x` causes the value to go outside the signed 32-bit integer range `[-231, 231 - 1]`, then return `0`. **Assume the environment does not allow you to store 64-bit integers (signed or unsigned).** **Example 1:** **Input:** x = 123 ...
null
Math
Medium
8,190,2238
258
what's up guys so let's sell in it's a 258 added digits and i hope you guys subscribe to my channel so all these problems are number three eight and you'll need to change it to two reasons that three plus one is eleven and either one plus divides two so you keep doing this stupid thing until there is only one digit oka...
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
948
hello everyone so today's lead code challenge is back of talk tokens right so we have given a list of tokens and power and our goal is to maximize the score by playing this game uh so how we gonna play the token of i represent the i power of token right what we have to do like let's take an example uh we have a token w...
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,850
hello everyone let's take a look at the code on 1850 it's the third problem in the weekly context it's not a very hard problem but it's also not a very hard very easy problem um so for permutations there's a very similar question lead code 31 next permutation so if you are not very familiar with permutation stuff you c...
Minimum Adjacent Swaps to Reach the Kth Smallest Number
minimum-length-of-string-after-deleting-similar-ends
You are given a string `num`, representing a large integer, and an integer `k`. We call some integer **wonderful** if it is a **permutation** of the digits in `num` and is **greater in value** than `num`. There can be many wonderful integers. However, we only care about the **smallest-valued** ones. * For example, ...
If both ends have distinct characters, no more operations can be made. Otherwise, the only operation is to remove all of the same characters from both ends. We will do this as many times as we can. Note that if the length is equal 1 the answer is 1
Two Pointers,String
Medium
null
416
hello everyone welcome back to my channel so today we are going to solve another problem is partition equal subset sum so in this problem we'll be given an array only positive integers find if the array can be partitioned into two subsets such that some of the elements in both subsets is equal so basically we are given...
Partition Equal Subset Sum
partition-equal-subset-sum
Given an integer array `nums`, return `true` _if you can partition the array into two subsets such that the sum of the elements in both subsets is equal or_ `false` _otherwise_. **Example 1:** **Input:** nums = \[1,5,11,5\] **Output:** true **Explanation:** The array can be partitioned as \[1, 5, 5\] and \[11\]. **E...
null
Array,Dynamic Programming
Medium
698,2108,2135,2162
77
hey guys how's everything going let's take a look at number 77 combinations given two integers and anake returned all possible combinations of K numbers on up 1 from 1 to n example we're given in the 4 and 2 just means to pick two numbers from 1 2 3 4 we will get 1 2 1 3 1 4 2 3 2 4 &amp; 3 4 get 1 2 1 3 1 4 2 3 2 4 &a...
Combinations
combinations
Given two integers `n` and `k`, return _all possible combinations of_ `k` _numbers chosen from the range_ `[1, n]`. You may return the answer in **any order**. **Example 1:** **Input:** n = 4, k = 2 **Output:** \[\[1,2\],\[1,3\],\[1,4\],\[2,3\],\[2,4\],\[3,4\]\] **Explanation:** There are 4 choose 2 = 6 total combin...
null
Backtracking
Medium
39,46
146
hey everyone welcome back and today we'll be doing another lead code problem 146 lru cash this is the medium one designer data structures that follow the constraint of a lease recently used lru cache implement the lru cash class lrq cash Constructor we are going to have which will have the capacity it will be a positiv...
LRU Cache
lru-cache
Design a data structure that follows the constraints of a **[Least Recently Used (LRU) cache](https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU)**. Implement the `LRUCache` class: * `LRUCache(int capacity)` Initialize the LRU cache with **positive** size `capacity`. * `int get(int key)` Return the valu...
null
Hash Table,Linked List,Design,Doubly-Linked List
Medium
460,588,604,1903
135
um hello so today we are doing this problem called candy solid called heart so the problem says that we have in children um that are kind of standing in a line and each child is assigned a rating um given the integer array ratings so basically this ratings contains the rating of each child and we are giving candies bas...
Candy
candy
There are `n` children standing in a line. Each child is assigned a rating value given in the integer array `ratings`. You are giving candies to these children subjected to the following requirements: * Each child must have at least one candy. * Children with a higher rating get more candies than their neighbors....
null
Array,Greedy
Hard
null
785
hello uh before starting off my health is a bit down so that energy and stuff might not be as like previous videos but I'll try to keep it intact so yeah without further Ado let's start with the problem itself uh the problem is pretty standard and simple we have to tell if the graph is bipartite or not cool uh firstly ...
Is Graph Bipartite?
basic-calculator-iii
There is an **undirected** graph with `n` nodes, where each node is numbered between `0` and `n - 1`. You are given a 2D array `graph`, where `graph[u]` is an array of nodes that node `u` is adjacent to. More formally, for each `v` in `graph[u]`, there is an undirected edge between node `u` and node `v`. The graph has ...
null
Math,String,Stack,Recursion
Hard
224,227,781,1736
341
he everyone today we are going to solve theal question forist iterator okay so first of all there are two key points to solve this question first key point is how can we deal with area indices first and the second key point is how can we deal with nested list so let me explain one by one okay so before I start my expla...
Flatten Nested List Iterator
flatten-nested-list-iterator
You are given a nested list of integers `nestedList`. Each element is either an integer or a list whose elements may also be integers or other lists. Implement an iterator to flatten it. Implement the `NestedIterator` class: * `NestedIterator(List nestedList)` Initializes the iterator with the nested list `nestedLi...
null
Stack,Tree,Depth-First Search,Design,Queue,Iterator
Medium
251,281,385,565
452
Hello friends, today's question is of medium level. In this question, we will be given the We have a balloon, its name is its starting point, If after that we have another balloon which is this here, this will also come in a straight line, give where you make X, if I run it here, then my If I run the intersection of th...
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
309
Watch Welcome to my channel today Zee problem is back time to buy and sell is talk with golden period for this is the problem of best time to buy and sell one should no problem tried to solve this problem in this problem British Governor of Tears Were The Amazing spider-man Transaction Were The Amazing spider-man Trans...
Best Time to Buy and Sell Stock with Cooldown
best-time-to-buy-and-sell-stock-with-cooldown
You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day. Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times) with the following restrictions: * After you sell your stock, yo...
null
Array,Dynamic Programming
Medium
121,122
907
Hey Riven, welcome to my channel, so today we are going to do question number four of our track playlist, okay, it is a little above the medium level, okay, but you can make it very easy, that is, if you understand it then it will become very easy, people. Okay, people have made this question easy, so let's see who ask...
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
49
hey guys welcome back to the channel in today's video we're going to look at the lead code problem and the problem's name is group anagrams so in this question we're given an array of strings called strs and we need to group The anagrams present together and we can return the answer in any order so this is the definiti...
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
1,262
video we will be discussing a problem from lead code which is greatest sum divisible by 3 so basically problem says that given an array of numbers of integers basically we are given an array of integers where each index has some value signed to it and we need to find the maximum possible sum of elements of the array su...
Greatest Sum Divisible by Three
online-majority-element-in-subarray
Given an integer array `nums`, return _the **maximum possible sum** of elements of the array such that it is divisible by three_. **Example 1:** **Input:** nums = \[3,6,5,1,8\] **Output:** 18 **Explanation:** Pick numbers 3, 6, 1 and 8 their sum is 18 (maximum sum divisible by 3). **Example 2:** **Input:** nums = \...
What's special about a majority element ? A majority element appears more than half the length of the array number of times. If we tried a random index of the array, what's the probability that this index has a majority element ? It's more than 50% if that array has a majority element. Try a random index for a proper n...
Array,Binary Search,Design,Binary Indexed Tree,Segment Tree
Hard
null
91
Hello everyone welcome to my channel Quote Sorry with Mike So today we are going to do video number 75 of the playlist of Dyam Programming. Yes, there has been a mistake in the numbering of a question. This is just the first video of this playlist, right, I have marked it as 75. But that is 74th video ok and the one be...
Decode Ways
decode-ways
A message containing letters from `A-Z` can be **encoded** into numbers using the following mapping: 'A' -> "1 " 'B' -> "2 " ... 'Z' -> "26 " To **decode** an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For examp...
null
String,Dynamic Programming
Medium
639,2091
72
in this video we'll be going over edit distance so given two strings word one and where to return the minimum number of operations required to convert word one to word two give the following three operations permitted on a word so insert a character delete a character and replace the character now for exa first example...
Edit Distance
edit-distance
Given two strings `word1` and `word2`, return _the minimum number of operations required to convert `word1` to `word2`_. You have the following three operations permitted on a word: * Insert a character * Delete a character * Replace a character **Example 1:** **Input:** word1 = "horse ", word2 = "ros " **O...
null
String,Dynamic Programming
Hard
161,583,712,1105,2311
54
hello hi everyone welcome back to the channel so in today's video we are going to talk about next question of Aries which is spiral Traverse so as we saw the previous question it was also related to understanding how to move or how to change indices of the array and get the resultant values right so here this is the si...
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
164
hey what's up guys uh this is chung here again so this time uh today's daily challenge problem number 164 maximum gap um this one is pretty a classic problem okay so you're given like integer array of nums right so you just need to return the maximum difference between two successive elements in its sorted form right a...
Maximum Gap
maximum-gap
Given an integer array `nums`, return _the maximum difference between two successive elements in its sorted form_. If the array contains less than two elements, return `0`. You must write an algorithm that runs in linear time and uses linear extra space. **Example 1:** **Input:** nums = \[3,6,9,1\] **Output:** 3 **E...
null
Array,Sorting,Bucket Sort,Radix Sort
Hard
null
139
okay the second question for today is question 213 I would break we have a number string s and dictionary word dick containing a list of non empty words so both the words and the in frustration and we don't need to worry about those as edge cases which is good we need to determine whether s can be segmented into space ...
Word Break
word-break
Given a string `s` and a dictionary of strings `wordDict`, return `true` if `s` can be segmented into a space-separated sequence of one or more dictionary words. **Note** that the same word in the dictionary may be reused multiple times in the segmentation. **Example 1:** **Input:** s = "leetcode ", wordDict = \[ "...
null
Hash Table,String,Dynamic Programming,Trie,Memoization
Medium
140
307
hello everyone welcome to my channel in this video i would like to share the question wrench some query and with the segment train data structure first of all let's take a look on the description in this question we are required to implement the numeric class with update and the sum range from example we can say if we ...
Range Sum Query - Mutable
range-sum-query-mutable
Given an integer array `nums`, handle multiple queries of the following types: 1. **Update** the value of an element in `nums`. 2. Calculate the **sum** of the elements of `nums` between indices `left` and `right` **inclusive** where `left <= right`. Implement the `NumArray` class: * `NumArray(int[] nums)` Initi...
null
Array,Design,Binary Indexed Tree,Segment Tree
Medium
303,308
1,649
hi everyone once again welcome to my channel and we are solving slowest key lit code problem so in this problem we are given two things in the method call one is key phrase a string character string and another is a release time a integral array so let me explain what is the what so here we are given a key price so we ...
Create Sorted Array through Instructions
maximum-number-of-non-overlapping-subarrays-with-sum-equals-target
Given an integer array `instructions`, you are asked to create a sorted array from the elements in `instructions`. You start with an empty container `nums`. For each element from **left to right** in `instructions`, insert it into `nums`. The **cost** of each insertion is the **minimum** of the following: * The numb...
Keep track of prefix sums to quickly look up what subarray that sums "target" can be formed at each step of scanning the input array. It can be proved that greedily forming valid subarrays as soon as one is found is optimal.
Array,Hash Table,Greedy,Prefix Sum
Medium
null
32
hello and welcome to another Le code solution video this is problem number 32 longest valid parenthesis for this problem we're given a string containing just the characters open parenthesis and closed parenthesis return the length of the longest valid well formed parentheses substring for example one we're given an inp...
Longest Valid Parentheses
longest-valid-parentheses
Given a string containing just the characters `'('` and `')'`, return _the length of the longest valid (well-formed) parentheses_ _substring_. **Example 1:** **Input:** s = "(() " **Output:** 2 **Explanation:** The longest valid parentheses substring is "() ". **Example 2:** **Input:** s = ")()()) " **Output:** ...
null
String,Dynamic Programming,Stack
Hard
20
70
another day another problem so let's Solve IT hello beautiful people I hope you all are doing very well so today we're gonna solve the problem climbing stairs so let's get started by reading the problem you are climbing a staircase it stakes and steps to reach the top and each time you can either claim one or two steps...
Climbing Stairs
climbing-stairs
You are climbing a staircase. It takes `n` steps to reach the top. Each time you can either climb `1` or `2` steps. In how many distinct ways can you climb to the top? **Example 1:** **Input:** n = 2 **Output:** 2 **Explanation:** There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps **Example 2:** ...
To reach nth step, what could have been your previous steps? (Think about the step sizes)
Math,Dynamic Programming,Memoization
Easy
747,1013,1236
160
hey guys today we're taking a look at intersection of two linked lists which is an easy problem but it's uh it's on the higher end of easy problems and it goes uh through linked list traversal so given the heads of two singly linked lists you have head a and head b you wanna see return the node at which the two is inte...
Intersection of Two Linked Lists
intersection-of-two-linked-lists
Given the heads of two singly linked-lists `headA` and `headB`, return _the node at which the two lists intersect_. If the two linked lists have no intersection at all, return `null`. For example, the following two linked lists begin to intersect at node `c1`: The test cases are generated such that there are no cycle...
null
Hash Table,Linked List,Two Pointers
Easy
599
872
hey everyone welcome back and let's write some more neat code today so today let's solve the problem Leaf similar trees we're given the root of two binary trees and we want to know if they are Leaf similar to each other which really just means if you take every leaf node which by the way a leaf node in a tree is just a...
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
66
hello everyone and welcome to python programming practice in this lesson we're going to be covering lead code number 66 it's called plus one this is classified as an easy problem so the solution shouldn't take too long to do i'll start by reading the problem description given a non-empty array of decimal given a non-em...
Plus One
plus-one
You are given a **large integer** represented as an integer array `digits`, where each `digits[i]` is the `ith` digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading `0`'s. Increment the large integer by one and re...
null
Array,Math
Easy
43,67,369,1031
1,763
uh so this question is longer nice subring so given the sh so s contain your p is both in uh uppercase and lower case letter so you have to return the longest substring of s such that I mean it's a nice subring so just for example a sorry AB a BB right so a the capital A and Lowe a appear in the sub and capital b lower...
Longest Nice Substring
all-valid-triplets-that-can-represent-a-country
A string `s` is **nice** if, for every letter of the alphabet that `s` contains, it appears **both** in uppercase and lowercase. For example, `"abABB "` is nice because `'A'` and `'a'` appear, and `'B'` and `'b'` appear. However, `"abA "` is not because `'b'` appears, but `'B'` does not. Given a string `s`, return _th...
null
Database
Easy
null
9
Hello everyone, Evgeniy Sulima nakh, and today we are looking at solving problems or code number nine, the number is a palindrome, according to the conditions of this problem, we are given an integer and we must determine whether this number is a palindrome or not a palindrome by analogy with the word palindrome, this ...
Palindrome Number
palindrome-number
Given an integer `x`, return `true` _if_ `x` _is a_ _**palindrome**__, and_ `false` _otherwise_. **Example 1:** **Input:** x = 121 **Output:** true **Explanation:** 121 reads as 121 from left to right and from right to left. **Example 2:** **Input:** x = -121 **Output:** false **Explanation:** From left to right, i...
Beware of overflow when you reverse the integer.
Math
Easy
234,1375
463
hello everyone so today in this video we go over another problem from lead code the problem name is iceland parameter so the problem is explaining that you are having a grid of n cross m or whatever dimensions which are given to you as a grid now there are different blocks in this grid some are water and some are land ...
Island Perimeter
island-perimeter
You are given `row x col` `grid` representing a map where `grid[i][j] = 1` represents land and `grid[i][j] = 0` represents water. Grid cells are connected **horizontally/vertically** (not diagonally). The `grid` is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells)...
null
Array,Depth-First Search,Breadth-First Search,Matrix
Easy
695,733,1104
234
all right so today we will be solving uh lead code question 234 which is known as the panondrome link list problem so given the head of a single linked list we will return true given that the linked list is a parent job so what is a pendulum so we can see from this example when we try to read the original uh link list ...
Palindrome Linked List
palindrome-linked-list
Given the `head` of a singly linked list, return `true` _if it is a_ _palindrome_ _or_ `false` _otherwise_. **Example 1:** **Input:** head = \[1,2,2,1\] **Output:** true **Example 2:** **Input:** head = \[1,2\] **Output:** false **Constraints:** * The number of nodes in the list is in the range `[1, 105]`. * ...
null
Linked List,Two Pointers,Stack,Recursion
Easy
9,125,206,2236
1,706
That I am Raghavendra the volume two day box top and bottom and okay means every cell channel bond is okay which goes from one to the other director means but can be authorized by putting boil on that board, this chapter can Now in Delhi, the one which is on every cell, which is close to each other for a minute, if it ...
Where Will the Ball Fall
min-cost-to-connect-all-points
You have a 2-D `grid` of size `m x n` representing a box, and you have `n` balls. The box is open on the top and bottom sides. Each cell in the box has a diagonal board spanning two corners of the cell that can redirect a ball to the right or to the left. * A board that redirects the ball to the right spans the top...
Connect each pair of points with a weighted edge, the weight being the manhattan distance between those points. The problem is now the cost of minimum spanning tree in graph with above edges.
Array,Union Find,Minimum Spanning Tree
Medium
2287
12
hello my friends this is next episode of my YouTube show lead code with me where we solve coding challenges I am Alexander bmin you're on my channel and we begins so what's in the agenda for today we will convert integers to Romans let's get started and go ahead okay let's get started Roman numerals are represented by ...
Integer to Roman
integer-to-roman
Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`. **Symbol** **Value** I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, `2` is written as `II` in Roman numeral, just two one's adde...
null
Hash Table,Math,String
Medium
13,273
778
hey everybody this is larry this is day 20 of the june decode daily challenge hit the like button hit the subscribe button join me in discord let me know what you think about today's farm swim in rising water happy father's day to y'all fathers out there uh yeah that's all i have for that one i guess i don't know stay ...
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
799
hey guys welcome back to another video and today we're going to be solving the lead code question champion towers okay so instead of going through all of the text over here what i'm going to do is i'll be drawing out the question and while doing so i'll explain what the question is asking us to do okay so the question ...
Champagne Tower
minimum-distance-between-bst-nodes
We stack glasses in a pyramid, where the **first** row has `1` glass, the **second** row has `2` glasses, and so on until the 100th row. Each glass holds one cup of champagne. Then, some champagne is poured into the first glass at the top. When the topmost glass is full, any excess liquid poured will fall equally to t...
null
Tree,Depth-First Search,Breadth-First Search,Binary Search Tree,Binary Tree
Easy
94
74
In this problem there is a test which is provided and also like this 23 is bigger than airtel seven is your 27. In this today matrix we will be asked to search a target element like we have to search 3 that element if we have this pea If 1 is present then we have to return 2. If it is not present then we have to return...
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
117
Loot Flirting Next Nine is given more basically, we have to take it from her left leg point to the right side, this is the point of her laptop, this is the point of this, we have to joint it, okay and if you do n't want to subscribe to this disgusting thing, then in this, Mewar is on this side, one special is this. Fro...
Populating Next Right Pointers in Each Node II
populating-next-right-pointers-in-each-node-ii
Given a binary tree struct Node { int val; Node \*left; Node \*right; Node \*next; } Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to `NULL`. Initially, all next pointers are set to `NULL`. **Example 1:** **Input:** root = \[1,2,3...
null
Linked List,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
116
1,043
hello friends today that's of the petition erase for maximum some problem let's first see the statement given an integer array a you partition the array into continuous sub arrays of length at most K after partition Li each sub array has their values changed to become the maximum value of that sub array returned the lo...
Partition Array for Maximum Sum
grid-illumination
Given an integer array `arr`, partition the array into (contiguous) subarrays of length **at most** `k`. After partitioning, each subarray has their values changed to become the maximum value of that subarray. Return _the largest sum of the given array after partitioning. Test cases are generated so that the answer fi...
null
Array,Hash Table
Hard
51
814
for today's algorithm we're going to be discussing delete code question binary tree pruning so the question statement is you're given a binary tree with the following property every node in the tree either contains a 0 or a 1 the task is to remove all sub trees that contain only zeros now if you look in the bottom of t...
Binary Tree Pruning
smallest-rotation-with-highest-score
Given the `root` of a binary tree, return _the same tree where every subtree (of the given tree) not containing a_ `1` _has been removed_. A subtree of a node `node` is `node` plus every node that is a descendant of `node`. **Example 1:** **Input:** root = \[1,null,0,0,1\] **Output:** \[1,null,0,null,1\] **Explanati...
null
Array,Prefix Sum
Hard
null
1,056
hey everybody this is Larry this is me doing week one of the new premium challenge or whatever it's called hit the like button hit the Subscribe button join me on Discord let me know what you think about this and I don't know why it's loading so long oh apparently it's because I've won the annual batch what does that m...
Confusing Number
capacity-to-ship-packages-within-d-days
A **confusing number** is a number that when rotated `180` degrees becomes a different number with **each digit valid**. We can rotate digits of a number by `180` degrees to form new digits. * When `0`, `1`, `6`, `8`, and `9` are rotated `180` degrees, they become `0`, `1`, `9`, `8`, and `6` respectively. * When ...
Binary search on the answer. We need a function possible(capacity) which returns true if and only if we can do the task in D days.
Array,Binary Search,Greedy
Medium
410,1192,2045,2188
1,198
given an N byn Matrix where every row is sorted in strictly increasing order return the smallest common element in all rows if there is no common element return minus one the smallest common element we can iterate through every menu of this uh of this row and uh for every Vue we should check we should use the binary se...
Find Smallest Common Element in All Rows
unpopular-books
Given an `m x n` matrix `mat` where every row is sorted in **strictly** **increasing** order, return _the **smallest common element** in all rows_. If there is no common element, return `-1`. **Example 1:** **Input:** mat = \[\[1,2,3,4,5\],\[2,4,5,8,10\],\[3,5,7,9,11\],\[1,3,5,7,9\]\] **Output:** 5 **Example 2:** ...
null
Database
Medium
null
1,176
welcome to above the training and it killed the solution if you want the best mock interview experience in North America feel free to check us out at about the training part we're here to help you land your next dream offer today we are going to talk about a little code problem 1176 tired of plan performance so it is a...
Diet Plan Performance
design-a-leaderboard
A dieter consumes `calories[i]` calories on the `i`\-th day. Given an integer `k`, for **every** consecutive sequence of `k` days (`calories[i], calories[i+1], ..., calories[i+k-1]` for all `0 <= i <= n-k`), they look at _T_, the total calories consumed during that sequence of `k` days (`calories[i] + calories[i+1] + ...
What data structure can we use to keep the players' data? Keep a map (dictionary) of player scores. For each top(K) function call, find the maximum K scores and add them.
Hash Table,Design,Sorting
Medium
null
39
welcome back to algojs today's question is leak code 39 combination sum so given an array of distinct integers candidates and the target interested target return a list of all unique combinations of candidates with the chosen numbers sum to target you may return the combinations in any order so the same number may be c...
Combination Sum
combination-sum
Given an array of **distinct** integers `candidates` and a target integer `target`, return _a list of all **unique combinations** of_ `candidates` _where the chosen numbers sum to_ `target`_._ You may return the combinations in **any order**. The **same** number may be chosen from `candidates` an **unlimited number of...
null
Array,Backtracking
Medium
17,40,77,216,254,377
787
welcome to javica school today we are going to serve daily question 787 cheapest flights within K stops so there is flight array and then the first one is from the second one is true and then third one is the price to charging from when you move first one to second one so if you want to go to zero to one you have to ch...
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
1,727
hey everyone welcome back and let's write some more neat code today so today let's solve the problem largest submatrix with rearrangements we're given a binary Matrix meaning zeros and ones and it's of size M by n so M rows or n columns and I just refer to these as like rows and columns because it just makes things eas...
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
120
Hello Today They Are Going To Year To Playlist 4021 Problem Friend Show What Is The Given Information Given A Triangle Is Written In Them From Top To Bottom Circumstances Mode Edison Number Absorb More Formal I Control Motu Here Intex Ultra Next9 The Rich Person And Dynamic Programming subscribe Video then subscribe to...
Triangle
triangle
Given a `triangle` array, return _the minimum path sum from top to bottom_. For each step, you may move to an adjacent number of the row below. More formally, if you are on index `i` on the current row, you may move to either index `i` or index `i + 1` on the next row. **Example 1:** **Input:** triangle = \[\[2\],\[...
null
Array,Dynamic Programming
Medium
null
1,171
all right so in this question is remove Zero Sum consecutive note from linkage so you're given a hello for Linked list and then you want the repeating consecrate the sequence of no less sum to zero so uh and this question is three four so you either delete negative three and three or you can delete one two negative thr...
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
1,051
welcome back everyone to another video here on the unknown code YouTube channel and today we are back with an elite code video this one is a little bit more tricky it still categorized as easy however it takes a little bit more logic a little bit more thinking to actually figure out the problem that we're working on to...
Height Checker
shortest-way-to-form-string
A school is trying to take an annual photo of all the students. The students are asked to stand in a single file line in **non-decreasing order** by height. Let this ordering be represented by the integer array `expected` where `expected[i]` is the expected height of the `ith` student in line. You are given an integer...
Which conditions have to been met in order to be impossible to form the target string? If there exists a character in the target string which doesn't exist in the source string then it will be impossible to form the target string. Assuming we are in the case which is possible to form the target string, how can we assur...
String,Dynamic Programming,Greedy
Medium
392,808
901
hello everyone let's solve today's lead code question online stocks pen today's question is a design problem we need to implement an initialization method and the next method we are given two arrays as input the first one is an array of instructions stock spanner means to initialize the object of the class and next mea...
Online Stock Span
advantage-shuffle
Design an algorithm that collects daily price quotes for some stock and returns **the span** of that stock's price for the current day. The **span** of the stock's price in one day is the maximum number of consecutive days (starting from that day and going backward) for which the stock price was less than or equal to ...
null
Array,Greedy,Sorting
Medium
null
141
okay question 141 leak code link list cycle given head the head of a linked list determine if the link list has a cycle in it there is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer internally pos is used to denote the index of the node th...
Linked List Cycle
linked-list-cycle
Given `head`, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the `next` pointer. Internally, `pos` is used to denote the index of the node that tail's `next` pointer is co...
null
Hash Table,Linked List,Two Pointers
Easy
142,202
122
yo what's up everybody how is going so today we are going to solve the one of the another coolest question which is best time to buy and sell stock too yes guys so this question is uh pretty good so basically like if you have sold uh the previous one best time to buy the sell stock one so in that one like we basically ...
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
154
11 Meaning Back Video This Video They Are Going You Solve One Lead Code Problem Which Is Same Best Friend Minimum Rote Direct Part You So Let S Began By First Reading D From Seattle And Give They Bill Be You See What Are D Process Which You Can Solve this problem question is a pebble what is your life that first of all...
Find Minimum in Rotated Sorted Array II
find-minimum-in-rotated-sorted-array-ii
Suppose an array of length `n` sorted in ascending order is **rotated** between `1` and `n` times. For example, the array `nums = [0,1,4,4,5,6,7]` might become: * `[4,5,6,7,0,1,4]` if it was rotated `4` times. * `[0,1,4,4,5,6,7]` if it was rotated `7` times. Notice that **rotating** an array `[a[0], a[1], a[2], ....
null
Array,Binary Search
Hard
153
389
in this tutorial let's discuss the programming question find the difference so let's first understand the problem statement so in this problem we have given two strings s and t which consists of only lower case letters so string t is generated by random shuffling of string s and then added one more letter at a random p...
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
1,232
today we will solve problem number 12 32 it's called is it a straight line so here you will be given a vector of coordinates and these are 2d coordinates in plane space 2d space and these will denote the x and y coordinates of the points and you have to find whether all the points are collinear or not that is they lie ...
Check If It Is a Straight Line
sum-of-mutated-array-closest-to-target
You are given an array `coordinates`, `coordinates[i] = [x, y]`, where `[x, y]` represents the coordinate of a point. Check if these points make a straight line in the XY plane. **Example 1:** **Input:** coordinates = \[\[1,2\],\[2,3\],\[3,4\],\[4,5\],\[5,6\],\[6,7\]\] **Output:** true **Example 2:** **Input:** coo...
If you draw a graph with the value on one axis and the absolute difference between the target and the array sum, what will you get? That graph is uni-modal. Use ternary search on that graph to find the best value.
Array,Binary Search,Sorting
Medium
null
727
minimum window subsequence yeah so let's first understand the question so we are giving a 3 S and another 3 S2 yeah so we're going to find the shortest subsequence yeah you should know that it is a subsequence it is not subing yeah because subsequence it is not continuous so for example bde we can find bcde and inside ...
Minimum Window Subsequence
minimum-window-subsequence
Given strings `s1` and `s2`, return _the minimum contiguous substring part of_ `s1`_, so that_ `s2` _is a subsequence of the part_. If there is no such window in `s1` that covers all characters in `s2`, return the empty string `" "`. If there are multiple such minimum-length windows, return the one with the **left-mos...
Let dp[j][e] = s be the largest index for which S[s:e+1] has T[:j] as a substring.
String,Dynamic Programming,Sliding Window
Hard
76,674
355
355 design Twitter in which we're going to have to post a tweet get a news feed follow and unfollow if you want to read all the instructions they're here but let's go ahead and get started so in order to post a tweet we need to do 12. tweets. append and we're going to append a tweet so let's call it tweet and this is g...
Design Twitter
design-twitter
Design a simplified version of Twitter where users can post tweets, follow/unfollow another user, and is able to see the `10` most recent tweets in the user's news feed. Implement the `Twitter` class: * `Twitter()` Initializes your twitter object. * `void postTweet(int userId, int tweetId)` Composes a new tweet w...
null
Hash Table,Linked List,Design,Heap (Priority Queue)
Medium
1640
1,845
so lead qu problem of the day and here we bring the solution for your question in this video I will be solving the question called as sheet reservation manager most interesting point that is I will be solving in clear concept way so I highly recommend you to watch this video to the end so that you can come across detai...
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,770
hello everyone in today's video i am trying to explain the lead code challenge maximum score performing multiplication operation so in which they will give us our two list numbers and multipliers so our goal is to get a maximum score by multiplying multiplier with numbers so as you can see in this first example what th...
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
337
Hello hello everyone welcome back to my channel today were going to discuss the problem itself is robot 351 toyhouse raj bhawan and highly recommended to start video first play kulvinder description selective this problem in its difficult itself a new place for three again with any one interested To This Area Call Rout...
House Robber III
house-robber-iii
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called `root`. Besides the `root`, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will automatically contact the police if ...
null
Dynamic Programming,Tree,Depth-First Search,Binary Tree
Medium
198,213
387
hey guys welcome to a new video in today's video we are going to look at the lead code problem and the problem's name is first unique character in a string so we are given a string s and we have to find out the first non-repeating have to find out the first non-repeating have to find out the first non-repeating charact...
First Unique Character in a String
first-unique-character-in-a-string
Given a string `s`, _find the first non-repeating character in it and return its index_. If it does not exist, return `-1`. **Example 1:** **Input:** s = "leetcode" **Output:** 0 **Example 2:** **Input:** s = "loveleetcode" **Output:** 2 **Example 3:** **Input:** s = "aabb" **Output:** -1 **Constraints:** * `...
null
Hash Table,String,Queue,Counting
Easy
451
1,975
The problem is that the maximum metric is equal, so here we are given a 2d metric and there are some elements which can be positive as well to make it negative, like if you look at this example, what they have done is that they have tried to convert all the negative events into positive ones. If it is made then I picke...
Maximum Matrix Sum
minimum-distance-to-the-target-element
You are given an `n x n` integer `matrix`. You can do the following operation **any** number of times: * Choose any two **adjacent** elements of `matrix` and **multiply** each of them by `-1`. Two elements are considered **adjacent** if and only if they share a **border**. Your goal is to **maximize** the summatio...
Loop in both directions until you find the target element. For each index i such that nums[i] == target calculate abs(i - start).
Array
Easy
null
221
hey everybody this is larry this is day 17 of the leeco daily december challenge hit the like button and subscribe and drop me this card let me know what you think about today's prom today's problem is maximo square a problem that i've seen a few times in my life i think the first time i've seen it was a long time ago ...
Maximal Square
maximal-square
Given an `m x n` binary `matrix` filled with `0`'s and `1`'s, _find the largest square containing only_ `1`'s _and return its area_. **Example 1:** **Input:** matrix = \[\[ "1 ", "0 ", "1 ", "0 ", "0 "\],\[ "1 ", "0 ", "1 ", "1 ", "1 "\],\[ "1 ", "1 ", "1 ", "1 ", "1 "\],\[ "1 ", "0 ", "0 ", "1 ", "0 "\]\] **Output:*...
null
Array,Dynamic Programming,Matrix
Medium
85,769,1312,2200
34
hello friends today let's show find first and last position of element insulted array in this question given an array of integers numbers sorted in extending order we need to find the starting and ending position of a given target value every time you so sorted you may have to think of binary search and the use case th...
Find First and Last Position of Element in Sorted Array
find-first-and-last-position-of-element-in-sorted-array
Given an array of integers `nums` sorted in non-decreasing order, find the starting and ending position of a given `target` value. If `target` is not found in the array, return `[-1, -1]`. You must write an algorithm with `O(log n)` runtime complexity. **Example 1:** **Input:** nums = \[5,7,7,8,8,10\], target = 8 *...
null
Array,Binary Search
Medium
278,2165,2210
1,791
let's solve problem 1791 find Center of star graph a star graph is nothing but a graph where there is one node to which every other node is connected okay so there in the in this question they giving us an array called edges which has a list of graph details so it gives you the first it gives you all the details in pai...
Find Center of Star Graph
richest-customer-wealth
There is an undirected **star** graph consisting of `n` nodes labeled from `1` to `n`. A star graph is a graph where there is one **center** node and **exactly** `n - 1` edges that connect the center node with every other node. You are given a 2D integer array `edges` where each `edges[i] = [ui, vi]` indicates that th...
Calculate the wealth of each customer Find the maximum element in array.
Array,Matrix
Easy
null
1,299
hello friends so today we want to discuss this question from bi-weekly discuss this question from bi-weekly discuss this question from bi-weekly down 17 problem number 1 2 9 replace elements with greatest element on the right side the question is very simple you are given an array and you have to output an another arra...
Replace Elements with Greatest Element on Right Side
k-concatenation-maximum-sum
Given an array `arr`, replace every element in that array with the greatest element among the elements to its right, and replace the last element with `-1`. After doing so, return the array. **Example 1:** **Input:** arr = \[17,18,5,4,6,1\] **Output:** \[18,6,6,6,1,-1\] **Explanation:** - index 0 --> the greatest e...
How to solve the problem for k=1 ? Use Kadane's algorithm for k=1. What are the possible cases for the answer ? The answer is the maximum between, the answer for k=1, the sum of the whole array multiplied by k, or the maximum suffix sum plus the maximum prefix sum plus (k-2) multiplied by the whole array sum for k > 1.
Array,Dynamic Programming
Medium
null
532
welcome to the coding interview question k div pairs in an array you're given an array of integers nums and an integer k return the number of unique k d fairs in the array a k diff pair is an integer pair nums i nums z where the following are true we have total for condition zero less than equals to i z less than nums ...
K-diff Pairs in an Array
k-diff-pairs-in-an-array
Given an array of integers `nums` and an integer `k`, return _the number of **unique** k-diff pairs in the array_. A **k-diff** pair is an integer pair `(nums[i], nums[j])`, where the following are true: * `0 <= i, j < nums.length` * `i != j` * `nums[i] - nums[j] == k` **Notice** that `|val|` denotes the absol...
null
Array,Hash Table,Two Pointers,Binary Search,Sorting
Medium
530,2116,2150
1,187
Welcome, I 'm trying to learn the problem from their dialect for you I want a program and we will work on it Guys, this is not the case, as I said linked questions, it turned out a little Where exactly is the problem? YouTube 480 Okay, today is not the best Nice English How much of would he like to return For example, ...
Make Array Strictly Increasing
print-foobar-alternately
Given two integer arrays `arr1` and `arr2`, return the minimum number of operations (possibly zero) needed to make `arr1` strictly increasing. In one operation, you can choose two indices `0 <= i < arr1.length` and `0 <= j < arr2.length` and do the assignment `arr1[i] = arr2[j]`. If there is no way to make `arr1` str...
null
Concurrency
Medium
1203,1216
207
so reading the problem we see some courses may have prerequisites for example to take course zero you have to first take course one which is expressed as a pair zero one so zero one uh and it says to take course zero you have to take course one so basically once you do course one you get to course zero we can kind of r...
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