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
27
what's up guys Xavier Elan here I go over hacker ranking leak code video so check out my channel and subscribe if you haven't already and if you like this video hit that like button as well today I'm going over a remove element it's easier a problem so we just have to give it a rating ohms and value valve remove all in...
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,669
em all of the vision vitahealth small image and speak english show factors are much for connection from the ielts test experts in fermentation entangling love you have Special English and the heaven in the recommended system or on the views of use spaces are enough that the folder pineapplechocolate folder and the othe...
Merge In Between Linked Lists
minimum-cost-to-cut-a-stick
You are given two linked lists: `list1` and `list2` of sizes `n` and `m` respectively. Remove `list1`'s nodes from the `ath` node to the `bth` node, and put `list2` in their place. The blue edges and nodes in the following figure indicate the result: _Build the result list and return its head._ **Example 1:** **In...
Build a dp array where dp[i][j] is the minimum cost to achieve all the cuts between i and j. When you try to get the minimum cost between i and j, try all possible cuts k between them, dp[i][j] = min(dp[i][k] + dp[k][j]) + (j - i) for all possible cuts k between them.
Array,Dynamic Programming
Hard
2251
4
Hello friends, welcome to your channel, today is our day for the Lead Code Challenge. So let's start on the screen. Here I have come on the screen. My question is open. Today's question is the four end of the lead code number. The name of the question is Median of two sorted. Okay, so we have to find the median. Two so...
Median of Two Sorted Arrays
median-of-two-sorted-arrays
Given two sorted arrays `nums1` and `nums2` of size `m` and `n` respectively, return **the median** of the two sorted arrays. The overall run time complexity should be `O(log (m+n))`. **Example 1:** **Input:** nums1 = \[1,3\], nums2 = \[2\] **Output:** 2.00000 **Explanation:** merged array = \[1,2,3\] and median is ...
null
Array,Binary Search,Divide and Conquer
Hard
null
1,869
hello welcome back today I'll try to solve another lead code problem 1869 longer contiguous segments of ones than zeros so this means we need to fight the longest clean settlement of ones for example this is a 2 and for zeros the longest consecutive is one so two is more than one this is why we're gonna return a true f...
Longer Contiguous Segments of Ones than Zeros
longer-contiguous-segments-of-ones-than-zeros
Given a binary string `s`, return `true` _if the **longest** contiguous segment of_ `1`'_s is **strictly longer** than the **longest** contiguous segment of_ `0`'_s in_ `s`, or return `false` _otherwise_. * For example, in `s = "110100010 "` the longest continuous segment of `1`s has length `2`, and the longest cont...
null
null
Easy
null
458
hey everyone this is priya and today we will see problem number 458 that is 405 so according to lead word this one is a hard problem but i think it's kind of met's problem and if you crack the logic then you can solve it easily so let's check out the problem there are buckets full of liquids where exactly one bucket is...
Poor Pigs
poor-pigs
There are `buckets` buckets of liquid, where **exactly one** of the buckets is poisonous. To figure out which one is poisonous, you feed some number of (poor) pigs the liquid to see whether they will die or not. Unfortunately, you only have `minutesToTest` minutes to determine which bucket is poisonous. You can feed t...
What if you only have one shot? Eg. 4 buckets, 15 mins to die, and 15 mins to test. How many states can we generate with x pigs and T tests? Find minimum x such that (T+1)^x >= N
Math,Dynamic Programming,Combinatorics
Hard
null
1,353
in 1,353 of vítkov they have just put him in 1,353 of vítkov they have just put him in 1,353 of vítkov they have just put him in the weekly contest 176 it seems to me and it is called maximum number well-being changes called maximum number well-being changes called maximum number well-being changes tendency this proble...
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
894
rit code number 894 all possible for binary trees this is medium question let's get into it uh a full binary tree is a binary tree where each note has exactly one and two children so in this case this one is for binary tree no this one no only this one yes because the children is zero and this one also true because it ...
All Possible Full Binary Trees
random-pick-with-blacklist
Given an integer `n`, return _a list of all possible **full binary trees** with_ `n` _nodes_. Each node of each tree in the answer must have `Node.val == 0`. Each element of the answer is the root node of one possible tree. You may return the final list of trees in **any order**. A **full binary tree** is a binary tr...
null
Hash Table,Math,Binary Search,Sorting,Randomized
Hard
398,912,2107
454
hello everyone hope you all are doing well so i am back with another lit call daily challenge and it is lit called number 454 for some two it is a middle medium level question and i also feel the same so here the question is you are given for integer array uh it is one number two number three and norms for of length n ...
4Sum II
4sum-ii
Given four integer arrays `nums1`, `nums2`, `nums3`, and `nums4` all of length `n`, return the number of tuples `(i, j, k, l)` such that: * `0 <= i, j, k, l < n` * `nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0` **Example 1:** **Input:** nums1 = \[1,2\], nums2 = \[-2,-1\], nums3 = \[-1,2\], nums4 = \[0,2\] **Ou...
null
Array,Hash Table
Medium
18
29
What is given in the unit Welcome back to my channel and you are going to solve divide by individuals switch problem statement that you have been given two integers to divide and adventure. Here it is said to divide two numbers without using multiplication. Division and Mode Operator OK and here it has also been said t...
Divide Two Integers
divide-two-integers
Given two integers `dividend` and `divisor`, divide two integers **without** using multiplication, division, and mod operator. The integer division should truncate toward zero, which means losing its fractional part. For example, `8.345` would be truncated to `8`, and `-2.7335` would be truncated to `-2`. Return _the...
null
Math,Bit Manipulation
Medium
null
65
Hello Hi Everyone Let's All The Facebook Interview Problem Ballot Number 100 This Problem Is Survey Number Can Be Split Up To In This Complex In Order To Decimal Number And Interior Optional Access Point Peeth Mauli And Capital In The Following And Jo After Explain This Must Where Integral Part And With Food Habits Can...
Valid Number
valid-number
A **valid number** can be split up into these components (in order): 1. A **decimal number** or an **integer**. 2. (Optional) An `'e'` or `'E'`, followed by an **integer**. A **decimal number** can be split up into these components (in order): 1. (Optional) A sign character (either `'+'` or `'-'`). 2. One of the...
null
String
Hard
8
347
Hello friends today I'm going to solve liquid problem number 347 top K frequent elements in this problem we have been given an integer array knobs and we are also given an integer value K and we need to return the K most frequent elements from our integer area norms and we could just return the answer in any order so h...
Top K Frequent Elements
top-k-frequent-elements
Given an integer array `nums` and an integer `k`, return _the_ `k` _most frequent elements_. You may return the answer in **any order**. **Example 1:** **Input:** nums = \[1,1,1,2,2,3\], k = 2 **Output:** \[1,2\] **Example 2:** **Input:** nums = \[1\], k = 1 **Output:** \[1\] **Constraints:** * `1 <= nums.lengt...
null
Array,Hash Table,Divide and Conquer,Sorting,Heap (Priority Queue),Bucket Sort,Counting,Quickselect
Medium
192,215,451,659,692,1014,1919
1,790
hey everybody this is larry this is me going over q1 of the weekly contest 232 um i think there's a lot of ways to do it given that n is equal to 100 i am i feel a little bit sad that i actually took almost two minutes uh on this one to be honest because usually i'm really fast on this but i think i was just very not c...
Check if One String Swap Can Make Strings Equal
lowest-common-ancestor-of-a-binary-tree-iii
You are given two strings `s1` and `s2` of equal length. A **string swap** is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices. Return `true` _if it is possible to make both strings equal by performing **at most one string swap** on **exactly on...
Store the path from p to the root. Traverse the path from q to the root, the first common point of the two paths is the LCA.
Hash Table,Tree,Binary Tree
Medium
235,236,1780,1816
223
Hello my dear friend so today we are going to solve rectangle area problem so this is lead code challenge so what will be given to us ok so coordinates will be given to us ok so bottom left co-ordinate will be bottom left co-ordinate will be bottom left co-ordinate will be denoted key ax1 A1 And top right corner will b...
Rectangle Area
rectangle-area
Given the coordinates of two **rectilinear** rectangles in a 2D plane, return _the total area covered by the two rectangles_. The first rectangle is defined by its **bottom-left** corner `(ax1, ay1)` and its **top-right** corner `(ax2, ay2)`. The second rectangle is defined by its **bottom-left** corner `(bx1, by1)` ...
null
Math,Geometry
Medium
866
1,897
Hello everyone Welcome to my channel Here I solve problems Lead code today task number 1897 rearrangement of letters to make a string of strings equal we are given an array of strings Words in one operation you can select two indices in each of the two strings and swap characters We need to return True if possible so r...
Redistribute Characters to Make All Strings Equal
maximize-palindrome-length-from-subsequences
You are given an array of strings `words` (**0-indexed**). In one operation, pick two **distinct** indices `i` and `j`, where `words[i]` is a non-empty string, and move **any** character from `words[i]` to **any** position in `words[j]`. Return `true` _if you can make **every** string in_ `words` _**equal** using **a...
Let's ignore the non-empty subsequence constraint. We can concatenate the two strings and find the largest palindromic subsequence with dynamic programming. Iterate through every pair of characters word1[i] and word2[j], and see if some palindrome begins with word1[i] and ends with word2[j]. This ensures that the subse...
String,Dynamic Programming
Hard
516
225
hey everyone welcome back and let's write some more neat code today so today let's solve the problem implement a stack using cues i think this is a really good problem for beginners to kind of get familiar with stacks and cues and the relationship between both of them so a stack is a lifo data structure last in is the ...
Implement Stack using Queues
implement-stack-using-queues
Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (`push`, `top`, `pop`, and `empty`). Implement the `MyStack` class: * `void push(int x)` Pushes element x to the top of the stack. * `int pop()` Removes the element on the top...
null
Stack,Design,Queue
Easy
232
216
so today we're looking at lead code number 216. it's a question called combination sum three and i would actually start with this if you tried combination sum or combination sum two i would start with this question first if you had trouble with those previous ones and once we solve this one the other two will make much...
Combination Sum III
combination-sum-iii
Find all valid combinations of `k` numbers that sum up to `n` such that the following conditions are true: * Only numbers `1` through `9` are used. * Each number is used **at most once**. Return _a list of all possible valid combinations_. The list must not contain the same combination twice, and the combinations...
null
Array,Backtracking
Medium
39
9
in this video we'll be going over palindrome number so we determine whether an integer is a palindrome when it reads the same forwards as backwards to solve the uh and the follow-up is could you solve uh and the follow-up is could you solve uh and the follow-up is could you solve it without converting this integer to a...
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
1,022
hello everyone this is today we are discussing this problem that is sum of root to leaf binary numbers um this is a very simple yet interesting problem uh the problem says that you are given with the root of binary tree and the only values that this binary tree is containing is zeros in one and each root uh i mean each...
Sum of Root To Leaf Binary Numbers
unique-paths-iii
You are given the `root` of a binary tree where each node has a value `0` or `1`. Each root-to-leaf path represents a binary number starting with the most significant bit. * For example, if the path is `0 -> 1 -> 1 -> 0 -> 1`, then this could represent `01101` in binary, which is `13`. For all leaves in the tree, c...
null
Array,Backtracking,Bit Manipulation,Matrix
Hard
37,63,212
978
hey everyone welcome back and let's write some more neat code today so today let's solve the problem longest turbulent subarray we're given an integer subarray and we want to return the length of the maximum size turbulent subarray from the given input array now what exactly is a turbulent array well it's best understo...
Longest Turbulent Subarray
valid-mountain-array
Given an integer array `arr`, return _the length of a maximum size turbulent subarray of_ `arr`. A subarray is **turbulent** if the comparison sign flips between each adjacent pair of elements in the subarray. More formally, a subarray `[arr[i], arr[i + 1], ..., arr[j]]` of `arr` is said to be turbulent if and only i...
It's very easy to keep track of a monotonically increasing or decreasing ordering of elements. You just need to be able to determine the start of the valley in the mountain and from that point onwards, it should be a valley i.e. no mini-hills after that. Use this information in regards to the values in the array and yo...
Array
Easy
1766
1,716
hello guys and welcome to today's daily lead code challenge today we'll be solving question 1,76 calculate money in the lead code 1,76 calculate money in the lead code 1,76 calculate money in the lead code Bank let's get straight to the question um heresy wants to save money in for his new first car he puts money in a ...
Calculate Money in Leetcode Bank
maximum-non-negative-product-in-a-matrix
Hercy wants to save money for his first car. He puts money in the Leetcode bank **every day**. He starts by putting in `$1` on Monday, the first day. Every day from Tuesday to Sunday, he will put in `$1` more than the day before. On every subsequent Monday, he will put in `$1` more than the **previous Monday**. Given...
Use Dynamic programming. Keep the highest value and lowest value you can achieve up to a point.
Array,Dynamic Programming,Matrix
Medium
null
4
Hello everyone welcome to my channel codestorywithMIK but it is quite easy but very popular question this is ok lead code number four medium of you sorted ok this is part one of this video so it is known that I will make it with two approaches ok One will be Brat Force which will be a very simple approach and the other...
Median of Two Sorted Arrays
median-of-two-sorted-arrays
Given two sorted arrays `nums1` and `nums2` of size `m` and `n` respectively, return **the median** of the two sorted arrays. The overall run time complexity should be `O(log (m+n))`. **Example 1:** **Input:** nums1 = \[1,3\], nums2 = \[2\] **Output:** 2.00000 **Explanation:** merged array = \[1,2,3\] and median is ...
null
Array,Binary Search,Divide and Conquer
Hard
null
120
hey guys this is a lead good questions 120 the triangle right so the question is given a triangle array return the minimum number minimum path from top to bottom for each step you may move to an adjacent number of the row below move formally if you are on index i or any index right to cut it right you may move to i or ...
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,012
hey everybody this is Larry this is me doing uh a second bonus question man I don't know just figure out I uh put it on YouTube so maybe people can figure something out from this um this is not gonna be my usual video in the sense that I am going to stop alive but I know what the answer is kind of but I am out of pract...
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
938
hello I will be doing all nine three eight one little which is called rate some of my research tree so given a root note of binary search tree return the sum of values of all nodes between L are the binary search tree is guaranteed to have unique values so in this example well we're given this binary search tree and th...
Range Sum of BST
numbers-at-most-n-given-digit-set
Given the `root` node of a binary search tree and two integers `low` and `high`, return _the sum of values of all nodes with a value in the **inclusive** range_ `[low, high]`. **Example 1:** **Input:** root = \[10,5,15,3,7,null,18\], low = 7, high = 15 **Output:** 32 **Explanation:** Nodes 7, 10, and 15 are in the ra...
null
Array,Math,Binary Search,Dynamic Programming
Hard
null
712
um hello so today we are going to do this problem which is part of Fleet code daily challenge minimum as key delete some for the string so basically what we are asking here is that we get two strings S1 and S2 and we want to return the lowest as key sum of the deleted characters so that we can make the two strings equa...
Minimum ASCII Delete Sum for Two Strings
minimum-ascii-delete-sum-for-two-strings
Given two strings `s1` and `s2`, return _the lowest **ASCII** sum of deleted characters to make two strings equal_. **Example 1:** **Input:** s1 = "sea ", s2 = "eat " **Output:** 231 **Explanation:** Deleting "s " from "sea " adds the ASCII value of "s " (115) to the sum. Deleting "t " from "eat " adds 116 to ...
Let dp(i, j) be the answer for inputs s1[i:] and s2[j:].
String,Dynamic Programming
Medium
72,300,583
368
hi guys today I'm going to solve lead code question number 368 that is largest divisible subset so let us try understanding the question says that given a set of distinct positive integers nums return the largest subset answer such that every pair present in that particular subset of elements satisfies the following co...
Largest Divisible Subset
largest-divisible-subset
Given a set of **distinct** positive integers `nums`, return the largest subset `answer` such that every pair `(answer[i], answer[j])` of elements in this subset satisfies: * `answer[i] % answer[j] == 0`, or * `answer[j] % answer[i] == 0` If there are multiple solutions, return any of them. **Example 1:** **Inp...
null
Array,Math,Dynamic Programming,Sorting
Medium
null
5
given a input string we need to find its longest periodomic substring for example investing b a d a b and a b a will be the longest paranormic substrings let's solve this problem first using Brute Force approach in Big O of n Cube using two pointers I and J we can check whether the substring from I to J is a palindrome...
Longest Palindromic Substring
longest-palindromic-substring
Given a string `s`, return _the longest_ _palindromic_ _substring_ in `s`. **Example 1:** **Input:** s = "babad " **Output:** "bab " **Explanation:** "aba " is also a valid answer. **Example 2:** **Input:** s = "cbbd " **Output:** "bb " **Constraints:** * `1 <= s.length <= 1000` * `s` consist of only dig...
How can we reuse a previously computed palindrome to compute a larger palindrome? If “aba” is a palindrome, is “xabax” a palindrome? Similarly is “xabay” a palindrome? Complexity based hint: If we use brute-force and check whether for every start and end position a substring is a palindrome we have O(n^2) start - end ...
String,Dynamic Programming
Medium
214,266,336,516,647
1,518
yeahyeah yeah Hello everyone, I'm a programmer, I'm going to make this video to introduce to you a problem about water bottles, a problem called Water Bottles in Lacoste that I just I also find it quite interesting to solve the problem. First, we need to look at the requirements of the problem as we can see that it wil...
Water Bottles
total-sales-amount-by-year
There are `numBottles` water bottles that are initially full of water. You can exchange `numExchange` empty water bottles from the market with one full water bottle. The operation of drinking a full water bottle turns it into an empty bottle. Given the two integers `numBottles` and `numExchange`, return _the **maximu...
null
Database
Hard
null
1,448
Hello guys welcome back to take admission in this video also see the direct account notes in three problem questions from record number 108 and desist from the angry topic and they will see the solution using requirement so let's posted the problem statement in this problem given up under root No Taxes In That Is Name ...
Count Good Nodes in Binary Tree
maximum-69-number
Given a binary tree `root`, a node _X_ in the tree is named **good** if in the path from root to _X_ there are no nodes with a value _greater than_ X. Return the number of **good** nodes in the binary tree. **Example 1:** **Input:** root = \[3,1,4,3,null,1,5\] **Output:** 4 **Explanation:** Nodes in blue are **good*...
Convert the number in an array of its digits. Brute force on every digit to get the maximum number.
Math,Greedy
Easy
null
1,696
hey everybody this is larry this is day nine of the july league daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's bomb jump game six okay yeah i hope everyone's having a beginning a good beginning of the weekend hopefully all right the two contests ...
Jump Game VI
strange-printer-ii
You are given a **0-indexed** integer array `nums` and an integer `k`. You are initially standing at index `0`. In one move, you can jump at most `k` steps forward without going outside the boundaries of the array. That is, you can jump from index `i` to any index in the range `[i + 1, min(n - 1, i + k)]` **inclusive*...
Try thinking in reverse. Given the grid, how can you tell if a colour was painted last?
Array,Graph,Topological Sort,Matrix
Hard
664
725
Ram Bhai Sir, today is 6th September and today 's question is 7:25. Split link list 's question is 7:25. Split link list 's question is 7:25. Split link list in part question is that you have to give a link and how many parts have to be divided into parts which you have given us. And how to divide if our length is comp...
Split Linked List in Parts
split-linked-list-in-parts
Given the `head` of a singly linked list and an integer `k`, split the linked list into `k` consecutive linked list parts. The length of each part should be as equal as possible: no two parts should have a size differing by more than one. This may lead to some parts being null. The parts should be in the order of occ...
If there are N nodes in the list, and k parts, then every part has N/k elements, except the first N%k parts have an extra one.
Linked List
Medium
61,328
51
hey everyone it's Chaz welcome back to the channel hope you're ready for another coding challenge because in this video we will be looking at leite code problem 51 n Queens this is actually going to be the first hard problem that we do on the channel but honestly this problem it's not hard because of the algorithm that...
N-Queens
n-queens
The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other. Given an integer `n`, return _all distinct solutions to the **n-queens puzzle**_. You may return the answer in **any order**. Each solution contains a distinct board configuration of the n-...
null
Array,Backtracking
Hard
52,1043
1,437
Hello Hi Everyone Welcome To My Channel Let's Check All The Problem Is All 108 List Length Of Places Where They Sleep Very Straightforward Problem And Easy If You Have Done From Problems With Solid And Liquid 10K Through All Subscribe For This Problem Is Given To Subscribe And the distance between the subscribe our Cha...
Check If All 1's Are at Least Length K Places Away
minimum-insertion-steps-to-make-a-string-palindrome
Given an binary array `nums` and an integer `k`, return `true` _if all_ `1`_'s are at least_ `k` _places away from each other, otherwise return_ `false`. **Example 1:** **Input:** nums = \[1,0,0,0,1,0,0,1\], k = 2 **Output:** true **Explanation:** Each of the 1s are at least 2 places away from each other. **Example ...
Is dynamic programming suitable for this problem ? If we know the longest palindromic sub-sequence is x and the length of the string is n then, what is the answer to this problem? It is n - x as we need n - x insertions to make the remaining characters also palindrome.
String,Dynamic Programming
Hard
1356
148
video we're going to look at a legal problem called sort list so given the head note of linked list we want to be able to sort this list in ace and the order so the goal for this question is we want to be able to do this uh complete this problem in n log in time complexity and its base complexity is constant right so i...
Sort List
sort-list
Given the `head` of a linked list, return _the list after sorting it in **ascending order**_. **Example 1:** **Input:** head = \[4,2,1,3\] **Output:** \[1,2,3,4\] **Example 2:** **Input:** head = \[-1,5,3,4,0\] **Output:** \[-1,0,3,4,5\] **Example 3:** **Input:** head = \[\] **Output:** \[\] **Constraints:** * ...
null
Linked List,Two Pointers,Divide and Conquer,Sorting,Merge Sort
Medium
21,75,147,1992
1,662
Hello Hi Everyone Welcome To My Channel It's All Also Problem Text To Strings Are Yaar Equivalent To Give Into Steve Whitmore Aka He Tours And Travels The Amazing Contaminated Water For Subscribing To String Events Will B C D E F This Is The Spelling Of Birth subscribe The Members of the Channel Please subscribe and su...
Check If Two String Arrays are Equivalent
minimum-numbers-of-function-calls-to-make-target-array
Given two string arrays `word1` and `word2`, return `true` _if the two arrays **represent** the same string, and_ `false` _otherwise._ A string is **represented** by an array if the array elements concatenated **in order** forms the string. **Example 1:** **Input:** word1 = \[ "ab ", "c "\], word2 = \[ "a ", "bc "...
Work backwards: try to go from nums to arr. You should try to divide by 2 as much as possible, but you can only divide by 2 if everything is even.
Array,Greedy
Medium
null
796
Hello everyone, how are you all, so today we will delete another interesting question whose name is Roti String 1796 question and in this we have to write the string, one S and one code, so we have to rotate the string S and number of numbers. Off character in that barium can make me cry D by crying Our street string i...
Rotate String
reaching-points
Given two strings `s` and `goal`, return `true` _if and only if_ `s` _can become_ `goal` _after some number of **shifts** on_ `s`. A **shift** on `s` consists of moving the leftmost character of `s` to the rightmost position. * For example, if `s = "abcde "`, then it will be `"bcdea "` after one shift. **Example 1...
null
Math
Hard
null
45
this is a fairly simple problem to solve as long as you understand how do you reverse a string in the best time possible so in this particular video I will be discussing three different methods how you can reverse a string and each of the method is equally optimal and fast as well all of them will give you a correct an...
Jump Game II
jump-game-ii
You are given a **0-indexed** array of integers `nums` of length `n`. You are initially positioned at `nums[0]`. Each element `nums[i]` represents the maximum length of a forward jump from index `i`. In other words, if you are at `nums[i]`, you can jump to any `nums[i + j]` where: * `0 <= j <= nums[i]` and * `i +...
null
Array,Dynamic Programming,Greedy
Medium
55,1428,2001
368
hello everybody welcome to my channel today is the day 13 of june recording challenge and the problem is largest divisible subset so let's read the problem statement and try to understand the given example so given a set of distinct positive integer find the largest subset such that every pair s i and sj of element in ...
Largest Divisible Subset
largest-divisible-subset
Given a set of **distinct** positive integers `nums`, return the largest subset `answer` such that every pair `(answer[i], answer[j])` of elements in this subset satisfies: * `answer[i] % answer[j] == 0`, or * `answer[j] % answer[i] == 0` If there are multiple solutions, return any of them. **Example 1:** **Inp...
null
Array,Math,Dynamic Programming,Sorting
Medium
null
1,675
Okay so today our daily task problem is minimum division in Hey so today we have to solve this problem so you can see now just 3 minutes ago it was accepted after three trials three colors answer tirely after that it was accepted Namas Joe It will remain basically unsorted if it is necessary and we had to tell what wil...
Minimize Deviation in Array
magnetic-force-between-two-balls
You are given an array `nums` of `n` positive integers. You can perform two types of operations on any element of the array any number of times: * If the element is **even**, **divide** it by `2`. * For example, if the array is `[1,2,3,4]`, then you can do this operation on the last element, and the array wil...
If you can place balls such that the answer is x then you can do it for y where y < x. Similarly if you cannot place balls such that the answer is x then you can do it for y where y > x. Binary search on the answer and greedily see if it is possible.
Array,Binary Search,Sorting
Medium
2188
538
hello everyone welcome or welcome back to my channel so today we are going to discuss another problem is convert bst to greater tree so in this problem we are given root of binary search tree converted into a greater tree such that every key of the original bst is changed to original key plus the sum of all the keys gr...
Convert BST to Greater Tree
convert-bst-to-greater-tree
Given the `root` of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all keys greater than the original key in BST. As a reminder, a _binary search tree_ is a tree that satisfies these constraints: * The left subtree of a...
null
Tree,Depth-First Search,Binary Search Tree,Binary Tree
Medium
null
112
lead code number 112 it's a question called path sum and here we're given a root of a binary tree and an integer target sum we want to return true if the tree has a root to leave path such that adding up all the values along the path equals the target sum and a leaf is a node with no children so here we have this tree ...
Path Sum
path-sum
Given the `root` of a binary tree and an integer `targetSum`, return `true` if the tree has a **root-to-leaf** path such that adding up all the values along the path equals `targetSum`. A **leaf** is a node with no children. **Example 1:** **Input:** root = \[5,4,8,11,null,13,4,7,2,null,null,null,1\], targetSum = 22...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
113,124,129,437,666
111
hi let's talk about the second question which is minimum depth of binary tree right so if you have not checked out the similar question maximum depth of a binary tree I would strongly advise you all that please make sure you look at that video and we then come back here because then yeah this question is basically kind...
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,771
hey what's up guys uh this is sean here so this time on 1771 maximize palindrome length from subsequences so you're given like a two strings right word one and word two so you need to construct a string in the volume in the following manner so choose any subsequence from word one and then choose another subsequence fro...
Maximize Palindrome Length From Subsequences
sell-diminishing-valued-colored-balls
You are given two strings, `word1` and `word2`. You want to construct a string in the following manner: * Choose some **non-empty** subsequence `subsequence1` from `word1`. * Choose some **non-empty** subsequence `subsequence2` from `word2`. * Concatenate the subsequences: `subsequence1 + subsequence2`, to make ...
Greedily sell the most expensive ball. There is some value k where all balls of value > k are sold, and some, (maybe 0) of balls of value k are sold. Use binary search to find this value k, and use maths to find the total sum.
Array,Math,Binary Search,Greedy,Sorting,Heap (Priority Queue)
Medium
2263
98
hello everybody welcome to another video on problem solving and today we are going to be solving a problem on lead code which is validate a binary search tree so you can see it's a medium level problem and let's just quickly go through the description and then we'll talk about that approach so we've been given the root...
Validate Binary Search Tree
validate-binary-search-tree
Given the `root` of a binary tree, _determine if it is a valid binary search tree (BST)_. A **valid BST** is defined as follows: * The left subtree of a node contains only nodes with keys **less than** the node's key. * The right subtree of a node contains only nodes with keys **greater than** the node's key. * ...
null
Tree,Depth-First Search,Binary Search Tree,Binary Tree
Medium
94,501
454
Hello friends, in today's video we are going to discuss Net Profit Addition 250. If you have not subscribed our channel then subscribe our channel. You will get good content related to date in easy language on our channel. Knowledge is less problem, Veer. 140 Hey Namaskar Subscribe Now Hey Zindagi This Number Subscribe...
4Sum II
4sum-ii
Given four integer arrays `nums1`, `nums2`, `nums3`, and `nums4` all of length `n`, return the number of tuples `(i, j, k, l)` such that: * `0 <= i, j, k, l < n` * `nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0` **Example 1:** **Input:** nums1 = \[1,2\], nums2 = \[-2,-1\], nums3 = \[-1,2\], nums4 = \[0,2\] **Ou...
null
Array,Hash Table
Medium
18
55
day 25 and the problem is jump game it's lead code problem number 55 and uh we will see at a solution which is order and time and order one space complexity so first let's understand the problem so we have some blocks or you can think of them as an array of numbers and these numbers are non-negative non-negative non-ne...
Jump Game
jump-game
You are given an integer array `nums`. You are initially positioned at the array's **first index**, and each element in the array represents your maximum jump length at that position. Return `true` _if you can reach the last index, or_ `false` _otherwise_. **Example 1:** **Input:** nums = \[2,3,1,1,4\] **Output:** t...
null
Array,Dynamic Programming,Greedy
Medium
45,1428,2001
65
hello everyone welcome to codex cam we are the 15th day of mail etc challenge and the problem we are going to cover is valid number so the input given here is a string which consists of a number either it can be an integer or decimal we have to return true or false if a number is valid or not so let's understand this p...
Valid Number
valid-number
A **valid number** can be split up into these components (in order): 1. A **decimal number** or an **integer**. 2. (Optional) An `'e'` or `'E'`, followed by an **integer**. A **decimal number** can be split up into these components (in order): 1. (Optional) A sign character (either `'+'` or `'-'`). 2. One of the...
null
String
Hard
8
490
hey everybody this is Larry this is me doing week uh three week three of the liquor premium charge hit the like button the Subscribe button drop my Discord let me know what you think about today's Palm I'm going to sneeze give me a second oh man I'm like in between sneezing so give me a second uh or you know fast forwa...
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
1,008
hey what's up guys chung here so this time let's continue our trade journey unlit cold and so we're gonna talk about this number one thousand and eight right so construct binary search tree from pre-order binary search tree from pre-order binary search tree from pre-order traverse right so what does so you're given lik...
Construct Binary Search Tree from Preorder Traversal
binary-tree-cameras
Given an array of integers preorder, which represents the **preorder traversal** of a BST (i.e., **binary search tree**), construct the tree and return _its root_. It is **guaranteed** that there is always possible to find a binary search tree with the given requirements for the given test cases. A **binary search tr...
null
Dynamic Programming,Tree,Depth-First Search,Binary Tree
Hard
1021
103
249 Welcome back to my channel. In today's video, the name of the oath we are going to call is Bionic Pimples and what will we do in it in the previous, we will do the same as we did with the battery level, the objective was sugar, just one more thing and we will maintain the information power level. The name is fine, ...
Binary Tree Zigzag Level Order Traversal
binary-tree-zigzag-level-order-traversal
Given the `root` of a binary tree, return _the zigzag level order traversal of its nodes' values_. (i.e., from left to right, then right to left for the next level and alternate between). **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[\[3\],\[20,9\],\[15,7\]\] **Example 2:** **Input:** roo...
null
Tree,Breadth-First Search,Binary Tree
Medium
102
871
hello and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem 871 minimum number of refueling stops before we read the question prompt i would just like to kindly ask you to subscribe i have the goal of reaching a thousand subscribers by the end of may and i need your hel...
Minimum Number of Refueling Stops
keys-and-rooms
A car travels from a starting position to a destination which is `target` miles east of the starting position. There are gas stations along the way. The gas stations are represented as an array `stations` where `stations[i] = [positioni, fueli]` indicates that the `ith` gas station is `positioni` miles east of the sta...
null
Depth-First Search,Breadth-First Search,Graph
Medium
261
476
hello friends welcome again to my youtube channel today the problem that we are going to discuss is number complement uh it's problem number 476 let's go through the problem description first so given a positive integer output its complement number and the complement strategy is to flip the bits of its binary represent...
Number Complement
number-complement
The **complement** of an integer is the integer you get when you flip all the `0`'s to `1`'s and all the `1`'s to `0`'s in its binary representation. * For example, The integer `5` is `"101 "` in binary and its **complement** is `"010 "` which is the integer `2`. Given an integer `num`, return _its complement_. **...
null
Bit Manipulation
Easy
null
72
72 that says edit distance so in this question you are given two strings word one and word two you need to perform some operation like inserting a character deleting a character and replacing a character on word one to make it similar to word two correct and in the end we need to return minimum number of operation requ...
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
191
today we are going to solve number of one bits we are given a number and we need to return the number of ones in its binary representation so for example if we are given 6 so that is 1 0 in binary representation and the number of ones in this is 2 so we are going to output 2. so the one way of solving this problem is t...
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
922
That my become I am Anand and today we will see by listing the question shot dead by parity come in simple tense that the center is intense and being this recipe which will be the last bullion is one it is zero it has positive sign now question What is there is that we are given an interior in the input and what we hav...
Sort Array By Parity II
possible-bipartition
Given an array of integers `nums`, half of the integers in `nums` are **odd**, and the other half are **even**. Sort the array so that whenever `nums[i]` is odd, `i` is **odd**, and whenever `nums[i]` is even, `i` is **even**. Return _any answer array that satisfies this condition_. **Example 1:** **Input:** nums =...
null
Depth-First Search,Breadth-First Search,Union Find,Graph
Medium
null
205
hey good to see you here so today we are going to solve a really good problem which is uh isomorphic strings so given to string s and d we have to determine if it is isomorphic or not so the question arises what is isomorphic so we can say that if two string s and t will be called isomorphic if the character and s can ...
Isomorphic Strings
isomorphic-strings
Given two strings `s` and `t`, _determine if they are isomorphic_. Two strings `s` and `t` are isomorphic if the characters in `s` can be replaced to get `t`. All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same characte...
null
Hash Table,String
Easy
290
1,713
hey what's up guys this is sean here again so this time uh 1713 minimum operations to make a subsequence pretty cool problem okay so you're given like an array target that consists of distinct integers and another integer array that can have duplicates so in one operations you can in one operation you can insert any in...
Minimum Operations to Make a Subsequence
dot-product-of-two-sparse-vectors
You are given an array `target` that consists of **distinct** integers and another integer array `arr` that **can** have duplicates. In one operation, you can insert any integer at any position in `arr`. For example, if `arr = [1,4,1,2]`, you can add `3` in the middle and make it `[1,4,3,1,2]`. Note that you can inser...
Because the vector is sparse, use a data structure that stores the index and value where the element is nonzero.
Array,Hash Table,Two Pointers,Design
Medium
null
1,672
foreign so this is the 1672nd episode or an episode the question of click so here we are given an M into an integer grid accounts so it's essentially a matrix it's a fancy way of telling a matrix okay so this account or a matrix has obviously i j a 2 row and a column index is the amount of money the ith customer has in...
Richest Customer Wealth
find-the-index-of-the-large-integer
You are given an `m x n` integer grid `accounts` where `accounts[i][j]` is the amount of money the `i​​​​​​​​​​​th​​​​` customer has in the `j​​​​​​​​​​​th`​​​​ bank. Return _the **wealth** that the richest customer has._ A customer's **wealth** is the amount of money they have in all their bank accounts. The richest ...
Do a binary search over the array, exclude the half of the array that doesn't contain the largest number. Keep shrinking the search space till it reaches the size of 2 where you can easily determine which one has the largest integer.
Array,Binary Search,Interactive
Medium
786
1,406
hey everyone welcome back and let's write some more neat code today so they'll solve the problem Stone game three and to be honest I don't know what leak code was smoking when they made this a hard problem and they made Stone game 2 a medium problem in my opinion this problem is definitely easier I mean there's some sm...
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
269
hey guys it's offi1 here and today we're going to be solving alien dictionary now I'm sure you can see that the interface is a bit different and that is because I don't have Lee code premium so I'm solving this problem on the website called lint code the only difference for this problem is that they have extra requirem...
Alien Dictionary
alien-dictionary
There is a new alien language that uses the English alphabet. However, the order among the letters is unknown to you. You are given a list of strings `words` from the alien language's dictionary, where the strings in `words` are **sorted lexicographically** by the rules of this new language. Return _a string of the u...
null
Array,String,Depth-First Search,Breadth-First Search,Graph,Topological Sort
Hard
210
205
here is Misha winter fashion high five rings snt morphing with interest mafik tongue with Andryukha students here are the men's guys in bed with VAT yes targa sing se and the sun and the wind blows and for a little mary kay sensor ceramicas secret incantation induction and markers charge handed over Crimea from where c...
Isomorphic Strings
isomorphic-strings
Given two strings `s` and `t`, _determine if they are isomorphic_. Two strings `s` and `t` are isomorphic if the characters in `s` can be replaced to get `t`. All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same characte...
null
Hash Table,String
Easy
290
1,460
welcome guys so at least we today uh we are solving this legal video uh one four six zero so make two arrays equal by reversing sub arrays so given to a race with equal length target and array and you can select any non-empty sub and you can select any non-empty sub and you can select any non-empty sub array at the rev...
Make Two Arrays Equal by Reversing Subarrays
number-of-substrings-containing-all-three-characters
You are given two integer arrays of equal length `target` and `arr`. In one step, you can select any **non-empty subarray** of `arr` and reverse it. You are allowed to make any number of steps. Return `true` _if you can make_ `arr` _equal to_ `target` _or_ `false` _otherwise_. **Example 1:** **Input:** target = \[1,...
For each position we simply need to find the first occurrence of a/b/c on or after this position. So we can pre-compute three link-list of indices of each a, b, and c.
Hash Table,String,Sliding Window
Medium
2187
1,326
all right let's take a look at lead code 1326 minimum number of taps to open to water a garden so the question is going to give us an input an n value which tells us how many units large the garden is and then it gives us a range list so all of these numbers so the first index represents the sprinkler size that the 0th...
Minimum Number of Taps to Open to Water a Garden
sum-of-floored-pairs
There is a one-dimensional garden on the x-axis. The garden starts at the point `0` and ends at the point `n`. (i.e The length of the garden is `n`). There are `n + 1` taps located at points `[0, 1, ..., n]` in the garden. Given an integer `n` and an integer array `ranges` of length `n + 1` where `ranges[i]` (0-index...
Find the frequency (number of occurrences) of all elements in the array. For each element, iterate through its multiples and multiply frequencies to find the answer.
Array,Math,Binary Search,Prefix Sum
Hard
null
1,385
hello everyone here's your friend one punch coder today we're gonna talk about legal question 1385 finding the distance value between two arrays so this is easy questions if you haven't read the question yet please pause the video for one second and just to read the description and anus then what is asking right it is ...
Find the Distance Value Between Two Arrays
number-of-ways-to-build-house-of-cards
Given two integer arrays `arr1` and `arr2`, and the integer `d`, _return the distance value between the two arrays_. The distance value is defined as the number of elements `arr1[i]` such that there is not any element `arr2[j]` where `|arr1[i]-arr2[j]| <= d`. **Example 1:** **Input:** arr1 = \[4,5,8\], arr2 = \[10,9...
If a row has k triangles, how many cards does it take to build that row? It takes 3 * k - 1 cards. If you still have i cards left, and on the previous row there were k triangles, what are the possible ways to build the current row? You can start at 1 triangle and continue adding more until you run out of cards or reach...
Math,Dynamic Programming
Medium
815
1,704
hey this is ike so we're back on leak code again today i'm just going to go ahead and do pick one we'll go for an easy problem uh i'll just keep clicking pick one until we get something all right so this problem says determine if string halves are alike so you are given a string s of even length split the string into t...
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,363
Minimum that you will see the channel man notification will be visible whose name is Largest Multiple of Three To see To see To see something keep writing this Mukesh Open and give and interiors of its internal Jasmine Table of Three Left Hand Witch Formed By contesting Samudra given it's an order tap critical problem ...
Largest Multiple of Three
largest-multiple-of-three
Given an array of digits `digits`, return _the largest multiple of **three** that can be formed by concatenating some of the given digits in **any order**_. If there is no answer return an empty string. Since the answer may not fit in an integer data type, return the answer as a string. Note that the returning answer ...
null
null
Hard
null
208
hi everyone welcome back to the series so in this video lecture we'll be implementing this dry data structure so before you watch this video make sure to watch the previous video because I have implemented the same data structure using pointers in this video lecture we'll be implementing this data structure using 2D ar...
Implement Trie (Prefix Tree)
implement-trie-prefix-tree
A [**trie**](https://en.wikipedia.org/wiki/Trie) (pronounced as "try ") or **prefix tree** is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker. Implement the Trie class: * `Trie()` ...
null
Hash Table,String,Design,Trie
Medium
211,642,648,676,1433,1949
146
what's up everyone sam here from byte by byte calm and in this video I'm going to show you exactly how to implement an LRU cache so that's the least recently used cache and this is a very common problem in a lot of coding interviews so we're gonna dig into it right after the intro and if you haven't already make sure y...
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
203
hi guys welcome to algorithms made easy today we will go through the day 20 problem from the july lead coding challenge remove linked list elements please like the video and if you are new don't forget to subscribe to our channel so that you never miss any update we need to remove all the elements from a linked list of...
Remove Linked List Elements
remove-linked-list-elements
Given the `head` of a linked list and an integer `val`, remove all the nodes of the linked list that has `Node.val == val`, and return _the new head_. **Example 1:** **Input:** head = \[1,2,6,3,4,5,6\], val = 6 **Output:** \[1,2,3,4,5\] **Example 2:** **Input:** head = \[\], val = 1 **Output:** \[\] **Example 3:**...
null
Linked List,Recursion
Easy
27,237,2216
1,044
hello everyone welcome to codas camp we are at 30th day of october challenge and the problem we are going to cover in this video is longest duplicate substring so the input given here is a string variable yes and we have to return the longest duplicate substring in the given input so let's understand this with an examp...
Longest Duplicate Substring
find-common-characters
Given a string `s`, consider all _duplicated substrings_: (contiguous) substrings of s that occur 2 or more times. The occurrences may overlap. Return **any** duplicated substring that has the longest possible length. If `s` does not have a duplicated substring, the answer is `" "`. **Example 1:** **Input:** s = "ba...
null
Array,Hash Table,String
Easy
350
56
welcome back to algojs today's question is leak code 56 merge intervals so given an array of intervals where interval i equals start end merge all overlapping intervals and return an array of the non-overlapping intervals that cover all non-overlapping intervals that cover all non-overlapping intervals that cover all t...
Merge Intervals
merge-intervals
Given an array of `intervals` where `intervals[i] = [starti, endi]`, merge all overlapping intervals, and return _an array of the non-overlapping intervals that cover all the intervals in the input_. **Example 1:** **Input:** intervals = \[\[1,3\],\[2,6\],\[8,10\],\[15,18\]\] **Output:** \[\[1,6\],\[8,10\],\[15,18\]\...
null
Array,Sorting
Medium
57,252,253,495,616,715,761,768,1028,2297,2319
80
hey guys today we're going to solve lead code number 80. remove duplicates from sorted array 2. so we're given a sorted array numbers and we need to remove the duplicates in place so that duplicates appear at most twice so there can't be in the return array there can't be any number that appears more than two times and...
Remove Duplicates from Sorted Array II
remove-duplicates-from-sorted-array-ii
Given an integer array `nums` sorted in **non-decreasing order**, remove some duplicates [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm) such that each unique element appears **at most twice**. The **relative order** of the elements should be kept the **same**. Since it is impossible to change the len...
null
Array,Two Pointers
Medium
26
1,346
foreign and its double exist so like how an actor has its double you have to check whether the number has a double of it okay so we are given an array of integers and we have to check if there exists two distinct integers ing that means I is not equal to J and the indices are between 0 and array dot length so it doesn'...
Check If N and Its Double Exist
maximize-the-topmost-element-after-k-moves
Given an array `arr` of integers, check if there exist two indices `i` and `j` such that : * `i != j` * `0 <= i, j < arr.length` * `arr[i] == 2 * arr[j]` **Example 1:** **Input:** arr = \[10,2,5,3\] **Output:** true **Explanation:** For i = 0 and j = 2, arr\[i\] == 10 == 2 \* 5 == 2 \* arr\[j\] **Example 2:**...
For each index i, how can we check if nums[i] can be present at the top of the pile or not after k moves? For which conditions will we end up with an empty pile?
Array,Greedy
Medium
134
403
hello and welcome to another video in this video we're going to be doing frog jump and so in this problem it's pretty straightforward a frog is crossing a river and it's divided into some number of units and essentially you have the stones array where at all of these indices a stone exists and the Frog starts at zero i...
Frog Jump
frog-jump
A frog is crossing a river. The river is divided into some number of units, and at each unit, there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water. Given a list of `stones`' positions (in units) in sorted **ascending order**, determine if the frog can cross the river by...
null
Array,Dynamic Programming
Hard
1952,2262
476
hello welcome back to my channel and today we will be solving it good problem number 476 that is number complement so the problem statement given here is given a positive integer num we need to output its complement number and the complement is flipping it splits to the opposite and let's check with it let's check with...
Number Complement
number-complement
The **complement** of an integer is the integer you get when you flip all the `0`'s to `1`'s and all the `1`'s to `0`'s in its binary representation. * For example, The integer `5` is `"101 "` in binary and its **complement** is `"010 "` which is the integer `2`. Given an integer `num`, return _its complement_. **...
null
Bit Manipulation
Easy
null
1,838
hi everyone today we are going to solve the little question frequency of the most frequent element the frequency of an element is a number of times it occurs in Array so you are given integer array norms and the integer K in one operation you can choose the index of nums and increase an element at the index by 1. retur...
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
144
um hello so continuing on January lead code daily challenge one of the problems today's problem is binary tree pre-order today's problem is binary tree pre-order today's problem is binary tree pre-order traversal um so what this problem says is we get the root of a binary tree and we want to return the pre-order and we...
Binary Tree Preorder Traversal
binary-tree-preorder-traversal
Given the `root` of a binary tree, return _the preorder traversal of its nodes' values_. **Example 1:** **Input:** root = \[1,null,2,3\] **Output:** \[1,2,3\] **Example 2:** **Input:** root = \[\] **Output:** \[\] **Example 3:** **Input:** root = \[1\] **Output:** \[1\] **Constraints:** * The number of nodes ...
null
Stack,Tree,Depth-First Search,Binary Tree
Easy
94,255,775
1,647
how's it going guys today we'll be working on legal question 1647 it is a medium difficulty it's called minimum deletions to make character frequencies unique okay so in this question we're given a string s and we're trying to figure out if it's good and if it's not good how many uh characters do we remove it so that i...
Minimum Deletions to Make Character Frequencies Unique
can-convert-string-in-k-moves
A string `s` is called **good** if there are no two different characters in `s` that have the same **frequency**. Given a string `s`, return _the **minimum** number of characters you need to delete to make_ `s` _**good**._ The **frequency** of a character in a string is the number of times it appears in the string. F...
Observe that shifting a letter x times has the same effect of shifting the letter x + 26 times. You need to check whether k is large enough to cover all shifts with the same remainder after modulo 26.
Hash Table,String
Medium
null
462
hello everyone welcome to day 19th of may liquid challenge and today's question is minimum moves to equal array elements too in this question we are given an array of size n and we need to return the minimum number of moves required to make all the elements of the array equal how can you define one single move in a sin...
Minimum Moves to Equal Array Elements II
minimum-moves-to-equal-array-elements-ii
Given an integer array `nums` of size `n`, return _the minimum number of moves required to make all array elements equal_. In one move, you can increment or decrement an element of the array by `1`. Test cases are designed so that the answer will fit in a **32-bit** integer. **Example 1:** **Input:** nums = \[1,2,3...
null
Array,Math,Sorting
Medium
296,453,2160,2290
969
hey everybody this is larry this is day 29 two more days of the lego daily challenge on in august uh hit the like button in the subscribe button also my apparently my math is wrong there three more days but uh anyway let's get to uh pancake sorting given an array of integers a we saw them with pancake flips okay that s...
Pancake Sorting
number-of-recent-calls
Given an array of integers `arr`, sort the array by performing a series of **pancake flips**. In one pancake flip we do the following steps: * Choose an integer `k` where `1 <= k <= arr.length`. * Reverse the sub-array `arr[0...k-1]` (**0-indexed**). For example, if `arr = [3,2,1,4]` and we performed a pancake f...
null
Design,Queue,Data Stream
Easy
null
62
in this video we're going to look at a legal problem called unique paths so we're basically given a robot that located at the top left corner of the m times n grid so we want to figure out how many unique paths that the robot can travel down to the bottom right corner of the grid so you can see here we have an example ...
Unique Paths
unique-paths
There is a robot on an `m x n` grid. The robot is initially located at the **top-left corner** (i.e., `grid[0][0]`). The robot tries to move to the **bottom-right corner** (i.e., `grid[m - 1][n - 1]`). The robot can only move either down or right at any point in time. Given the two integers `m` and `n`, return _the nu...
null
Math,Dynamic Programming,Combinatorics
Medium
63,64,174,2192
299
Hello friends, in this video we are going to do all the balls and count in this game. There is a question which is quite tricky and when I wanted to understand it, I was not able to understand it but I will explain it to you so well that after watching this video. After this you will definitely not have to watch any ot...
Bulls and Cows
bulls-and-cows
You are playing the **[Bulls and Cows](https://en.wikipedia.org/wiki/Bulls_and_Cows)** game with your friend. You write down a secret number and ask your friend to guess what the number is. When your friend makes a guess, you provide a hint with the following info: * The number of "bulls ", which are digits in the ...
null
Hash Table,String,Counting
Medium
null
1,630
hello everyone welcome to my channel here I solve L Cod problems and prepare to the court interview today's problem number is 1630 arithmetic subarray a sequence of numbers is called arithmetic if it consists of at least two elements and the difference between every two cons consecutive elements is the same for example...
Arithmetic Subarrays
count-odd-numbers-in-an-interval-range
A sequence of numbers is called **arithmetic** if it consists of at least two elements, and the difference between every two consecutive elements is the same. More formally, a sequence `s` is arithmetic if and only if `s[i+1] - s[i] == s[1] - s[0]` for all valid `i`. For example, these are **arithmetic** sequences: 1...
If the range (high - low + 1) is even, the number of even and odd numbers in this range will be the same. If the range (high - low + 1) is odd, the solution will depend on the parity of high and low.
Math
Easy
null
84
hey everybody this is larry this is day 29 of the general eco daily challenge almost to the end of the month hope you're doing all right stay good stay healthy wait what now hit the like button hit the subscribe button join me on discord let me know what you think about today's problem i just i don't know largest recta...
Largest Rectangle in Histogram
largest-rectangle-in-histogram
Given an array of integers `heights` representing the histogram's bar height where the width of each bar is `1`, return _the area of the largest rectangle in the histogram_. **Example 1:** **Input:** heights = \[2,1,5,6,2,3\] **Output:** 10 **Explanation:** The above is a histogram where width of each bar is 1. The l...
null
Array,Stack,Monotonic Stack
Hard
85,1918
1,063
hey everybody this is Larry this is me doing week four of the legal premium weekly challenge uh hit the like button hit the Subscribe and join me on Discord let me know what you think about today's form 1063 number of valid Subways we haven't solved this one yet yay I don't know maybe not that excited but uh okay so gi...
Number of Valid Subarrays
best-sightseeing-pair
Given an integer array `nums`, return _the number of non-empty **subarrays** with the leftmost element of the subarray not larger than other elements in the subarray_. A **subarray** is a **contiguous** part of an array. **Example 1:** **Input:** nums = \[1,4,2,5,3\] **Output:** 11 **Explanation:** There are 11 vali...
Can you tell the best sightseeing spot in one pass (ie. as you iterate over the input?) What should we store or keep track of as we iterate to do this?
Array,Dynamic Programming
Medium
null
1,956
hey everybody this is Larry this is me doing an extra prom for today I feel like I haven't done this in a while but I do have premium for I don't know how much longer so we'll see uh you know I'm gonna try to do a random premium that I haven't done yet yeah and then we'll see how far I get yeah that's let's do it wow a...
Minimum Time For K Virus Variants to Spread
maximum-element-after-decreasing-and-rearranging
There are `n` **unique** virus variants in an infinite 2D grid. You are given a 2D array `points`, where `points[i] = [xi, yi]` represents a virus originating at `(xi, yi)` on day `0`. Note that it is possible for **multiple** virus variants to originate at the **same** point. Every day, each cell infected with a viru...
Sort the Array. Decrement each element to the largest integer that satisfies the conditions.
Array,Greedy,Sorting
Medium
null
939
hey guys how's it going John here today we're going to be solving another legal problem and this problem is called binary search tree range I decided to choose this problem because in my last legal problem I made a mistake where I wrote BST for a function name when it's supposed to be just like a binary tree I believe ...
Minimum Area Rectangle
valid-permutations-for-di-sequence
You are given an array of points in the **X-Y** plane `points` where `points[i] = [xi, yi]`. Return _the minimum area of a rectangle formed from these points, with sides parallel to the X and Y axes_. If there is not any such rectangle, return `0`. **Example 1:** **Input:** points = \[\[1,1\],\[1,3\],\[3,1\],\[3,3\]...
null
Dynamic Programming
Hard
null
1,266
in this problem you are given a few points in a 2d space and the points have some order so they will be given in some order like this point is first this is second this is third and your task is to find the minimum or distance minimum time you will take to visit all these points in order that is first this point you wi...
Minimum Time Visiting All Points
minimum-time-visiting-all-points
On a 2D plane, there are `n` points with integer coordinates `points[i] = [xi, yi]`. Return _the **minimum time** in seconds to visit all the points in the order given by_ `points`. You can move according to these rules: * In `1` second, you can either: * move vertically by one unit, * move horizontally...
null
null
Easy
null
203
hello everybody I'm gonna be going over remove linked list elements on Lee code problem number 203 and it says given the head of a linked list and it enters your Veil and remove all the nodes in the link list that has node.bell equal to link list that has node.bell equal to link list that has node.bell equal to Veil an...
Remove Linked List Elements
remove-linked-list-elements
Given the `head` of a linked list and an integer `val`, remove all the nodes of the linked list that has `Node.val == val`, and return _the new head_. **Example 1:** **Input:** head = \[1,2,6,3,4,5,6\], val = 6 **Output:** \[1,2,3,4,5\] **Example 2:** **Input:** head = \[\], val = 1 **Output:** \[\] **Example 3:**...
null
Linked List,Recursion
Easy
27,237,2216
56
another day another problem so let's Solve IT hello guys I hope you are all doing well in this video we're gonna solve the problem merge interval so let's get started first I will show you a technique that I use to read the problem and try to visualize the solution a lot of people don't know how to read the problem cor...
Merge Intervals
merge-intervals
Given an array of `intervals` where `intervals[i] = [starti, endi]`, merge all overlapping intervals, and return _an array of the non-overlapping intervals that cover all the intervals in the input_. **Example 1:** **Input:** intervals = \[\[1,3\],\[2,6\],\[8,10\],\[15,18\]\] **Output:** \[\[1,6\],\[8,10\],\[15,18\]\...
null
Array,Sorting
Medium
57,252,253,495,616,715,761,768,1028,2297,2319
462
hi guys welcome to tech geek so again i'm back with today's lead code problem that's minimum moves to it to moves to equal array elements that means you have to make the array elements equal and how many moves you have to do minimum that you have to take so that's a leak for medium question you can see lead code medium...
Minimum Moves to Equal Array Elements II
minimum-moves-to-equal-array-elements-ii
Given an integer array `nums` of size `n`, return _the minimum number of moves required to make all array elements equal_. In one move, you can increment or decrement an element of the array by `1`. Test cases are designed so that the answer will fit in a **32-bit** integer. **Example 1:** **Input:** nums = \[1,2,3...
null
Array,Math,Sorting
Medium
296,453,2160,2290
395
hi guys welcome to beginner techies in this video I'm going to discuss about another problem of sliding window in the last couple of videos I have already discussed your problems and uh I have solved this problem with the help of sliding me today and also discuss about the sliding window if there is a problem so how ca...
Longest Substring with At Least K Repeating Characters
longest-substring-with-at-least-k-repeating-characters
Given a string `s` and an integer `k`, return _the length of the longest substring of_ `s` _such that the frequency of each character in this substring is greater than or equal to_ `k`. **Example 1:** **Input:** s = "aaabb ", k = 3 **Output:** 3 **Explanation:** The longest substring is "aaa ", as 'a' is repeated 3...
null
Hash Table,String,Divide and Conquer,Sliding Window
Medium
2140,2209
889
Hai gas welcome you today's video and today we are going to do problem 889 of lead company whose name is Construct binary tree from pre order and post order driver so basically here we have been given one pre order and one post order has also been given. And from these two we have to construct our trick, so let's see h...
Construct Binary Tree from Preorder and Postorder Traversal
buddy-strings
Given two integer arrays, `preorder` and `postorder` where `preorder` is the preorder traversal of a binary tree of **distinct** values and `postorder` is the postorder traversal of the same tree, reconstruct and return _the binary tree_. If there exist multiple answers, you can **return any** of them. **Example 1:**...
null
Hash Table,String
Easy
1777,1915
207
hello everyone in this video we are going to see the lead code question number 207 course schedule there are a total of n number of courses you have to take labeled from 0 to nus1 you are given an array of prerequisites a comma B indicates that you must take cos B first if you want to take Co a for example the pair 0a ...
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,685
hey everyone welcome back today we are going to solve problem number 1685 sum of absolute differences in a sorted array first we will see the explanation of the problem statement in the logic and the code now let's dive into the solution so in this problem we are given a nums array in a sorted order and we need to find...
Sum of Absolute Differences in a Sorted Array
stone-game-v
You are given an integer array `nums` sorted in **non-decreasing** order. Build and return _an integer array_ `result` _with the same length as_ `nums` _such that_ `result[i]` _is equal to the **summation of absolute differences** between_ `nums[i]` _and all the other elements in the array._ In other words, `result[i...
We need to try all possible divisions for the current row to get the max score. As calculating all possible divisions will lead us to calculate some sub-problems more than once, we need to think of dynamic programming.
Array,Math,Dynamic Programming,Game Theory
Hard
909,1240,1522,1617,1788,1808,2002,2156
1,773
Soon God talks Latwal Number Se Zuki Hai Tata Matching Broad Festival Subscribe Color Name Dispenser Tape Alert Mother Item subscribe The Channel If you wash then I am explaining to you by giving an example Example I am like we have given an accused and a rule and item Like covered item and this second item now I have ...
Count Items Matching a Rule
percentage-of-users-attended-a-contest
You are given an array `items`, where each `items[i] = [typei, colori, namei]` describes the type, color, and name of the `ith` item. You are also given a rule represented by two strings, `ruleKey` and `ruleValue`. The `ith` item is said to match the rule if **one** of the following is true: * `ruleKey == "type "` ...
null
Database
Easy
1338
141
200 Hi Guys Today Evening At Least Cycle This Printed Or Cycle In The List Sunth And Cycle Defined You Are Inquiry Into Your Native Can Never Getting Out Of The Earliest You Can See That Year 320 Maang - Poems From Her Against You Can See That Year 320 Maang - Poems From Her Against You Can See That Year 320 Maang - Po...
Linked List Cycle
linked-list-cycle
Given `head`, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the `next` pointer. Internally, `pos` is used to denote the index of the node that tail's `next` pointer is co...
null
Hash Table,Linked List,Two Pointers
Easy
142,202
1,232
Hello hello guys welcome back to join this video will see give in assam coordinator points want to take off the volume straight line half yadav challenge so let's look at the problems sexual subscribe points collect daily point to straight line in the subscribe and subscribe the Channel Please subscribe and subscribe t...
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
1,846
hello guys today Cod problem so uh this problem is very uh simple problem so let's code together uh basically in this problem we have given the topics like uh counting and shorting and Grading so let's start the code of this problem initially but we have to do that uh int answer equals to array of okay and short okay s...
Maximum Element After Decreasing and Rearranging
maximum-element-after-decreasing-and-rearranging
You are given an array of positive integers `arr`. Perform some operations (possibly none) on `arr` so that it satisfies these conditions: * The value of the **first** element in `arr` must be `1`. * The absolute difference between any 2 adjacent elements must be **less than or equal to** `1`. In other words, `abs...
null
null
Medium
null
393
hey everybody this is larry this is day 13 of the leco daily challenge hit the like button hit the subscribe button join me on discord whoops one bun let me know what you think about today's prom uh no extra coins today's prime is utf-8 utf-8 utf-8 validation okay let's see i think i've done this recently because it wa...
UTF-8 Validation
utf-8-validation
Given an integer array `data` representing the data, return whether it is a valid **UTF-8** encoding (i.e. it translates to a sequence of valid UTF-8 encoded characters). A character in **UTF8** can be from **1 to 4 bytes** long, subjected to the following rules: 1. For a **1-byte** character, the first bit is a `0`...
All you have to do is follow the rules. For a given integer, obtain its binary representation in the string form and work with the rules given in the problem. An integer can either represent the start of a UTF-8 character, or a part of an existing UTF-8 character. There are two separate rules for these two scenarios in...
Array,Bit Manipulation
Medium
null