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
433
we Define a gene as an eight character string where each character can be a c g o t we have an initial G installed and we want to know the minimum number of mutations to perform to reach a gene and a mutation is changing one character in a gene to one of the four possible letters of course knowing that not all genes ar...
Minimum Genetic Mutation
minimum-genetic-mutation
A gene string can be represented by an 8-character long string, with choices from `'A'`, `'C'`, `'G'`, and `'T'`. Suppose we need to investigate a mutation from a gene string `startGene` to a gene string `endGene` where one mutation is defined as one single character changed in the gene string. * For example, `"AAC...
null
Hash Table,String,Breadth-First Search
Medium
127
745
all right welcome to may's elite coding challenge today's challenge is prefix and subject search design a special dictionary which has some words and allows you to search those words in it by prefix and suffix so implement the word filter class uh word filter initialize the object with the words and dictionary the meth...
Prefix and Suffix Search
find-smallest-letter-greater-than-target
Design a special dictionary that searches the words in it by a prefix and a suffix. Implement the `WordFilter` class: * `WordFilter(string[] words)` Initializes the object with the `words` in the dictionary. * `f(string pref, string suff)` Returns _the index of the word in the dictionary,_ which has the prefix `p...
Try to find whether each of 26 next letters are in the given string array.
Array,Binary Search
Easy
2269
5
That this is the death of line 725 and our problem comes to list this longest talent roaming subtracted longest electronic shop string then edit this question and in front of you that extreme has been given return the longest platform in substring in less okay if our What is there is such that what is the chief that if...
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,695
That the 15-minute playlist Channel Test Vaishnav Maximum 15-minute playlist Channel Test Vaishnav Maximum 15-minute playlist Channel Test Vaishnav Maximum Volume Inspiration with Giveth Andhe subscribe Video subscribe The Channel subscribe Video Ko A Hind Is Kaise Between Two Points And Modes Element 200 Ki Without Mu...
Maximum Erasure Value
maximum-sum-obtained-of-any-permutation
You are given an array of positive integers `nums` and want to erase a subarray containing **unique elements**. The **score** you get by erasing the subarray is equal to the **sum** of its elements. Return _the **maximum score** you can get by erasing **exactly one** subarray._ An array `b` is called to be a subarray...
Indexes with higher frequencies should be bound with larger values
Array,Greedy,Sorting,Prefix Sum
Medium
null
3
Jhaal Hello Guys Welcome to Gautami Yash Lungi Subscribe subscribe kare subscribe and subscribe the Channel Please subscribe and subscribe Subscribe all characters subscribe thank you will have to enter into another point Abhishek will start from zero Uday Singh going all the way will depend on this point Meeting This ...
Longest Substring Without Repeating Characters
longest-substring-without-repeating-characters
Given a string `s`, find the length of the **longest** **substring** without repeating characters. **Example 1:** **Input:** s = "abcabcbb " **Output:** 3 **Explanation:** The answer is "abc ", with the length of 3. **Example 2:** **Input:** s = "bbbbb " **Output:** 1 **Explanation:** The answer is "b ", with t...
null
Hash Table,String,Sliding Window
Medium
159,340,1034,1813,2209
215
Yes everyone welcome back to my channel so today we are going to solve the problem where we have to find the largest element so there is a different approach through which we can solve it but it is given in the question that not through sorting. Let's see what to do if you see the question statement then target is give...
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
4
Hello gas I am self Amrita welcome back to our channel technoscies so in today's video we are going to discuss lead code problem number four date is median of you sorted are it is a hard difficulty problem but don't worry we are going to be simplified in next few minutes So let's get started let's first understand d pr...
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
869
hey guys how's everything going this is jason in this video i'm going to solve number eight six nine we ordered power of two from lead code let's take a look starting with a positive integer n we ordered the digits in any order including the original order so it's actually technically all the permutation right such tha...
Reordered Power of 2
similar-string-groups
You are given an integer `n`. We reorder the digits in any order (including the original order) such that the leading digit is not zero. Return `true` _if and only if we can do this so that the resulting number is a power of two_. **Example 1:** **Input:** n = 1 **Output:** true **Example 2:** **Input:** n = 10 **...
null
Array,String,Depth-First Search,Breadth-First Search,Union Find
Hard
2276
118
9th Guys Welcome To Step Cornice Latest 25 Triangle Today Like And Share The Video Subscribe The Channel To Get Up And The Problem End User Password Triangle Way Rajya Krishi Vidyapeeth Pune Me Sandy Then And Password Triangle Is Triangle The Subscribe Rule Ardash Loot Gayi Ek Recording Now Will roll this championship ...
Pascal's Triangle
pascals-triangle
Given an integer `numRows`, return the first numRows of **Pascal's triangle**. In **Pascal's triangle**, each number is the sum of the two numbers directly above it as shown: **Example 1:** **Input:** numRows = 5 **Output:** \[\[1\],\[1,1\],\[1,2,1\],\[1,3,3,1\],\[1,4,6,4,1\]\] **Example 2:** **Input:** numRows = ...
null
Array,Dynamic Programming
Easy
119
380
hello hi guys good morning welcome back to a new video in this we want see problem insert delete get random in o one time it has been asked by Bloomberg yendes Facebook Tik Tok Amazon Google Adobe spinkler Uber uh airm uh Oracle Gman Netflix grammarly ICL LinkedIn Microsoft Apple Twitter Snapchat daaw Sophie Salesforce...
Insert Delete GetRandom O(1)
insert-delete-getrandom-o1
Implement the `RandomizedSet` class: * `RandomizedSet()` Initializes the `RandomizedSet` object. * `bool insert(int val)` Inserts an item `val` into the set if not present. Returns `true` if the item was not present, `false` otherwise. * `bool remove(int val)` Removes an item `val` from the set if present. Retur...
null
Array,Hash Table,Math,Design,Randomized
Medium
381
187
everyone welcome back and let's write some more neat code today so today let's solve the problem repeated dna sequences we're given a dna sequence and these are represented by four different characters a c g and t so this could be an example dna sequence using those four characters we are given some arbitrarily long dn...
Repeated DNA Sequences
repeated-dna-sequences
The **DNA sequence** is composed of a series of nucleotides abbreviated as `'A'`, `'C'`, `'G'`, and `'T'`. * For example, `"ACGAATTCCG "` is a **DNA sequence**. When studying **DNA**, it is useful to identify repeated sequences within the DNA. Given a string `s` that represents a **DNA sequence**, return all the *...
null
Hash Table,String,Bit Manipulation,Sliding Window,Rolling Hash,Hash Function
Medium
null
953
Hello gaze ma agarwal welcome tu all on coding channel co tricks made by you made for you so lets na was tattoo des let kar raha hoon aaj ki let ki problem kya bol rahi hai because movie whatsapp problem na van mein discussion for 2 jinko ab agla They have come to the match and want to do whatever they want, see what w...
Verifying an Alien Dictionary
reverse-only-letters
In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different `order`. The `order` of the alphabet is some permutation of lowercase letters. Given a sequence of `words` written in the alien language, and the `order` of the alphabet, return `true` if and only if the given `wor...
This problem is exactly like reversing a normal string except that there are certain characters that we have to simply skip. That should be easy enough to do if you know how to reverse a string using the two-pointer approach.
Two Pointers,String
Easy
null
70
hello everyone in this question we'll be doing question number 70 on leak code climbing stairs this is part of our blind 75 playlist only code where we go through the blind 75 question so let's begin so in this question you are climbing a staircase it takes n steps to reach the top and at any time you can either climb ...
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
236
in this video we will talk about two problems it is focused on the lowest common ancestor lca so we have two problems one is easy the other is medium but both of those problems are quite similar so let's see so first we have problem 235 so yeah so we have a so here we have a binary search tree and the other problem we ...
Lowest Common Ancestor of a Binary Tree
lowest-common-ancestor-of-a-binary-tree
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the [definition of LCA on Wikipedia](https://en.wikipedia.org/wiki/Lowest_common_ancestor): "The lowest common ancestor is defined between two nodes `p` and `q` as the lowest node in `T` that has both `p` and `q` as...
null
Tree,Depth-First Search,Binary Tree
Medium
235,1190,1354,1780,1790,1816,2217
1,091
hey everyone welcome back and let's write some more neat code today so today let's solve the problem shortest path in a binary Matrix given an N by n Matrix so note that this is a square Matrix that's not like a major point but we will come back to that later it's a binary Matrix so every value will be either a 0 or a ...
Shortest Path in Binary Matrix
maximum-average-subtree
Given an `n x n` binary matrix `grid`, return _the length of the shortest **clear path** in the matrix_. If there is no clear path, return `-1`. A **clear path** in a binary matrix is a path from the **top-left** cell (i.e., `(0, 0)`) to the **bottom-right** cell (i.e., `(n - 1, n - 1)`) such that: * All the visite...
Can you find the sum of values and the number of nodes for every sub-tree ? Can you find the sum of values and the number of nodes for a sub-tree given the sum of values and the number of nodes of it's left and right sub-trees ? Use depth first search to recursively find the solution for the children of a node then use...
Tree,Depth-First Search,Binary Tree
Medium
2126
1,630
Hello everyone welcome to my channel code story with mike so today we are going to do video number 71 of our playlist lead code number 6130 is a very easy question the constraints are also so less that it can be done with simple brute force ok question My name is Arith May, everything is fine, I will update the company...
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
142
Hello friends welcome back to my YouTube channel today I'm going to solve liquid problem number 142 linked list cycle 2. so in this problem we are given the head of a linked list and we need to return the node where the cycle begins if there is no cycle we are just going to return a null value so let's see how we could...
Linked List Cycle II
linked-list-cycle-ii
Given the `head` of a linked list, return _the node where the cycle begins. If there is no cycle, return_ `null`. 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 ta...
null
Hash Table,Linked List,Two Pointers
Medium
141,287
100
hey everyone welcome back and let's write some more neat code today so today let's solve same tree so i'm going to upload this on a friday so today we're going to be doing an easy-ish problem doing an easy-ish problem doing an easy-ish problem so we're given the root of two binary trees p and q we need to write a funct...
Same Tree
same-tree
Given the roots of two binary trees `p` and `q`, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical, and the nodes have the same value. **Example 1:** **Input:** p = \[1,2,3\], q = \[1,2,3\] **Output:** true **Example 2:** **Input:** p...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
null
275
Hello viewers welcome back to decades in this video you will see the question text to problem special half yadav challenge personal problem hui idli negative energy resources of computers and definition Wikipedia subscribe and the advisors who decide for various problems as an example to understand HOW MAKE THE PROBLEM...
H-Index II
h-index-ii
Given an array of integers `citations` where `citations[i]` is the number of citations a researcher received for their `ith` paper and `citations` is sorted in **ascending order**, return _the researcher's h-index_. According to the [definition of h-index on Wikipedia](https://en.wikipedia.org/wiki/H-index): The h-ind...
Expected runtime complexity is in O(log n) and the input is sorted.
Array,Binary Search
Medium
274
937
cool 937 we ordered data in locked files you have in a way of locks each log is a space limb delimited string of words each log the first word in each log is an alphanumeric identifier then either each word after that I never what consists of only in lower case that is or each word added identify fire will consist of a...
Reorder Data in Log Files
online-stock-span
You are given an array of `logs`. Each log is a space-delimited string of words, where the first word is the **identifier**. There are two types of logs: * **Letter-logs**: All words (except the identifier) consist of lowercase English letters. * **Digit-logs**: All words (except the identifier) consist of digits...
null
Stack,Design,Monotonic Stack,Data Stream
Medium
739
421
hello everyone welcome to our channel code with sunny and today we will be discussing the problem related to bit manipulation and it is the medium type problem of the lead code and you can see over here i have given a like and i also have added to my favorite list like this problem is going to teach us many concepts al...
Maximum XOR of Two Numbers in an Array
maximum-xor-of-two-numbers-in-an-array
Given an integer array `nums`, return _the maximum result of_ `nums[i] XOR nums[j]`, where `0 <= i <= j < n`. **Example 1:** **Input:** nums = \[3,10,5,25,2,8\] **Output:** 28 **Explanation:** The maximum result is 5 XOR 25 = 28. **Example 2:** **Input:** nums = \[14,70,53,83,49,91,36,80,92,51,66,70\] **Output:** 1...
null
Array,Hash Table,Bit Manipulation,Trie
Medium
1826
371
So guys welcome back to my channel today our question is sum of two integers you must be thinking on the question that it is very simple sum of two would hurt a mine b but this is not problem with you The exception is that we should not sum the two integers using the sum operator plus or minus. Okay, we have to do it i...
Sum of Two Integers
sum-of-two-integers
Given two integers `a` and `b`, return _the sum of the two integers without using the operators_ `+` _and_ `-`. **Example 1:** **Input:** a = 1, b = 2 **Output:** 3 **Example 2:** **Input:** a = 2, b = 3 **Output:** 5 **Constraints:** * `-1000 <= a, b <= 1000`
null
Math,Bit Manipulation
Medium
2
1,266
number 1266 minimum time visiting all points on the plane there are n points with integer coordinates uh points so this is a point with x and y your task is to find the minimum time minimum and seconds to visit all points so we have n number of points and we want to visit all of them you can move according to next rows...
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
1,751
welcome to Pomodoro Joe for Saturday July 15 2023. today we're doing a lead to good problem 1751 maximum number of events that can be attended two this is a hard problem you are given an array of events where events index I is equal to the start day the end day and the value the ith event starts at start day and ends a...
Maximum Number of Events That Can Be Attended II
slowest-key
You are given an array of `events` where `events[i] = [startDayi, endDayi, valuei]`. The `ith` event starts at `startDayi` and ends at `endDayi`, and if you attend this event, you will receive a value of `valuei`. You are also given an integer `k` which represents the maximum number of events you can attend. You can o...
Get for each press its key and amount of time taken. Iterate on the presses, maintaining the answer so far. The current press will change the answer if and only if its amount of time taken is longer than that of the previous answer, or they are equal but the key is larger than that of the previous answer.
Array,String
Easy
null
34
foreign challenge it's already around 11 pm and I had a hectic day I had to go to office in the morning I came back around 8 39 then I had my dinner and now I'm here with solving this problem which is fine first and last position of elements in a sorted array so here you are given an array that is sorted in nature what...
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
234
hey guys welcome back to helper function in this video we will discuss a popular linked list question palindrome linked list so the problem statement is pretty straightforward given a singly linked list we need to determine if it is a palindrome or not so if it is a palindrome we will return true otherwise we will retu...
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
68
Hello gas, so the question to be asked today is text justification, which is our daily lead code challenge August 24, 2023 question, so when we do this text application, then what is said in it, the word Jivan and are of strings, given the word God of string. And Maxwell is given and we have to format the text line, it...
Text Justification
text-justification
Given an array of strings `words` and a width `maxWidth`, format the text such that each line has exactly `maxWidth` characters and is fully (left and right) justified. You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces `' '` when necessary so that ea...
null
Array,String,Simulation
Hard
1714,2260
1,011
Okay, so here's this function, what we're going to do for this problem is a binary search, okay, it's just not going to be a binary search directly in this director, we 're going to do a binary search in the weight Ah, 're going to do a binary search in the weight Ah, 're going to do a binary search in the weight Ah, w...
Capacity To Ship Packages Within D Days
flip-binary-tree-to-match-preorder-traversal
A conveyor belt has packages that must be shipped from one port to another within `days` days. The `ith` package on the conveyor belt has a weight of `weights[i]`. Each day, we load the ship with packages on the conveyor belt (in the order given by `weights`). We may not load more weight than the maximum weight capaci...
null
Tree,Depth-First Search,Binary Tree
Medium
null
900
hey everybody this is Larry this is Dade oh uh this is General this is January 20th uh on 19th so I hit the like button in the Subscribe button drop me a Discord let me know what you think about this bonus question so I uh so as usual I'm doing an extra bonus question for um for uh for today just like you know getting ...
RLE Iterator
reordered-power-of-2
We can use run-length encoding (i.e., **RLE**) to encode a sequence of integers. In a run-length encoded array of even length `encoding` (**0-indexed**), for all even `i`, `encoding[i]` tells us the number of times that the non-negative integer value `encoding[i + 1]` is repeated in the sequence. * For example, the ...
null
Math,Sorting,Counting,Enumeration
Medium
null
735
Hey Gas, today we are going to solve another problem which is Asteroid Collision Late Course 735. Let's first see its question. Here we will have Android, okay and its sign will basically define which position of the straight. If we have a positive element and this one is also a positive element, it means that everyone...
Asteroid Collision
asteroid-collision
We are given an array `asteroids` of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed. Find out the state of the asteroids after all collisio...
Say a row of asteroids is stable. What happens when a new asteroid is added on the right?
Array,Stack
Medium
605,2245,2317
1,455
hello guys myself Amrita welcome back to our Channel techno Siege so this is our lead code Series in which we are solving lead code problems if you also wish to join you can subscribe to our channel so now let's move ahead with today's problem today we will be solving problem number one four double five that is check i...
Check If a Word Occurs As a Prefix of Any Word in a Sentence
filter-restaurants-by-vegan-friendly-price-and-distance
Given a `sentence` that consists of some words separated by a **single space**, and a `searchWord`, check if `searchWord` is a prefix of any word in `sentence`. Return _the index of the word in_ `sentence` _(**1-indexed**) where_ `searchWord` _is a prefix of this word_. If `searchWord` is a prefix of more than one wor...
Do the filtering and sort as said. Note that the id may not be the index in the array.
Array,Sorting
Medium
null
665
welcome to mazelico challenge today's problem is non-decreasing array today's problem is non-decreasing array today's problem is non-decreasing array given an array nums with n integers your task is to check if it could become non-decreasing by if it could become non-decreasing by if it could become non-decreasing by m...
Non-decreasing Array
non-decreasing-array
Given an array `nums` with `n` integers, your task is to check if it could become non-decreasing by modifying **at most one element**. We define an array is non-decreasing if `nums[i] <= nums[i + 1]` holds for every `i` (**0-based**) such that (`0 <= i <= n - 2`). **Example 1:** **Input:** nums = \[4,2,3\] **Output:...
null
Array
Medium
2205
27
hello everyone so welcome to another lead good question and in this question we will be solving a remove element so what we have in input is that we have an integer array nums and an integer value represented by a variable well we have to remove all occurrences of this variable or the value val in nums in place okay an...
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
138
hello everyone welcome or welcome back to my channel so today we are going to discuss another problem but before going forward if you've not liked the video please like it subscribe to my channel and hit the bell icon so that you get notified whenever i post a new video so without any further ado let's get started prob...
Copy List with Random Pointer
copy-list-with-random-pointer
A linked list of length `n` is given such that each node contains an additional random pointer, which could point to any node in the list, or `null`. Construct a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) of the list. The deep copy should consist of exactly `n` **brand new** nodes, where e...
Just iterate the linked list and create copies of the nodes on the go. Since a node can be referenced from multiple nodes due to the random pointers, make sure you are not making multiple copies of the same node. You may want to use extra space to keep old node ---> new node mapping to prevent creating multiples copies...
Hash Table,Linked List
Medium
133,1624,1634
32
welcome to april's leeco challenge today's problem is longest valid parentheses given a string containing just the character's open and closed parenthesis find the length of the longest valid parenthesis substring now a valid parenthesis is one where the open parenthesis is matched by closed parenthesis in order so her...
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
1,696
hey everybody this is larry this is day 9 of the june the code daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's farm jump game six uh as you can see i still have to get a new ac i'd just been busy and cheap so that didn't change anyway in case you ...
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
797
welcome back to uncle Jess today's question is Elite code 797 all paths from source to Target so given a directed adhesive to the graph of endnodes labeled from 0 to n minus 1 find all possible paths from 0 to node n minus 1 and return them in any order the graph is given as follows graph I is a list of all nodes you c...
All Paths From Source to Target
rabbits-in-forest
Given a directed acyclic graph (**DAG**) of `n` nodes labeled from `0` to `n - 1`, find all possible paths from node `0` to node `n - 1` and return them in **any order**. The graph is given as follows: `graph[i]` is a list of all nodes you can visit from node `i` (i.e., there is a directed edge from node `i` to node `...
null
Array,Hash Table,Math,Greedy
Medium
null
101
hi guys welcome to algorithms made easy in this series we are going to cover concepts from tree data structure and getting hands-on the topic as we and getting hands-on the topic as we and getting hands-on the topic as we move ahead so please like the video and if you are new don't forget to subscribe to our channel so...
Symmetric Tree
symmetric-tree
Given the `root` of a binary tree, _check whether it is a mirror of itself_ (i.e., symmetric around its center). **Example 1:** **Input:** root = \[1,2,2,3,4,4,3\] **Output:** true **Example 2:** **Input:** root = \[1,2,2,null,3,null,3\] **Output:** false **Constraints:** * The number of nodes in the tree is in...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
null
714
hello everyone welcome back here is vanamsen and today we are discussing a daily challenge best time to buy and sell stock with a transaction fee it's categorized as medium difficulty level problem and I will be solving it in uh JavaScript so I have previously solved this problem in Python and we are going to uh do sim...
Best Time to Buy and Sell Stock with Transaction Fee
best-time-to-buy-and-sell-stock-with-transaction-fee
You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day, and an integer `fee` representing a transaction fee. Find the maximum profit you can achieve. You may complete as many transactions as you like, but you need to pay the transaction fee for each transaction. **Note:** You...
Consider the first K stock prices. At the end, the only legal states are that you don't own a share of stock, or that you do. Calculate the most profit you could have under each of these two cases.
Array,Dynamic Programming,Greedy
Medium
122
692
Hello friends, subscribe and hit the bell notification, so today we are going to read the top frequent words, question number 692, lead code, so what is this question saying to you, it will be vector given or list and strings will be given in it and in this The value of the cake has been given to you, now what do you h...
Top K Frequent Words
top-k-frequent-words
Given an array of strings `words` and an integer `k`, return _the_ `k` _most frequent strings_. Return the answer **sorted** by **the frequency** from highest to lowest. Sort the words with the same frequency by their **lexicographical order**. **Example 1:** **Input:** words = \[ "i ", "love ", "leetcode ", "i ", "...
null
Hash Table,String,Trie,Sorting,Heap (Priority Queue),Bucket Sort,Counting
Medium
347,1014,1919
679
If we have High Court and Welcome Back to Hut series, then as you have seen in the last five, you have covered the topic of FACE, it is fine, it is relatively, if you think about it and look at the question, then it can be from 25 speakers here and the benefits of both of them. I had also made you face both the points,...
24 Game
24-game
You are given an integer array `cards` of length `4`. You have four cards, each containing a number in the range `[1, 9]`. You should arrange the numbers on these cards in a mathematical expression using the operators `['+', '-', '*', '/']` and the parentheses `'('` and `')'` to get the value 24. You are restricted wi...
null
Array,Math,Backtracking
Hard
null
1,763
So Hello Everyone I am Vijay Kumar and today we will solve problem number 1763 taken from T code and problem name is Longest Nice Substring. It is a very small question, we have chosen and today we will solve this question using divide and conquer approach. Using divide and kick approach so jump to the problem statemen...
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
275
today we're gonna be working on lead code question number 275 age index part 2. given an array of integer citations where the citations of I where the citations uh of I is the number of citations a researcher received for the ith in ith paper in citations is sorted in an ascending order this is the only difference we h...
H-Index II
h-index-ii
Given an array of integers `citations` where `citations[i]` is the number of citations a researcher received for their `ith` paper and `citations` is sorted in **ascending order**, return _the researcher's h-index_. According to the [definition of h-index on Wikipedia](https://en.wikipedia.org/wiki/H-index): The h-ind...
Expected runtime complexity is in O(log n) and the input is sorted.
Array,Binary Search
Medium
274
234
hey everyone welcome back and let's write some more neat code today so today let's solve leak code 234 palindrome linked list so we're given a singly linked list and we just want to know is it a palindrome or not true or false yes or no now what even is a palindrome that if you don't know what that is that should be yo...
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
112
what's up nerds welcome back to tee time with your favorite software engineer today we're going to be going over easy problem nicole pathsome so it's a pretty popular question but first i wanted to mention my leeco competition that i'm hosting um so there's several of us competing this is for the month of november so w...
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
589
Hello viewers welcome to my video one day series to coding this follow minute call in free mode on medium ne problem not completed the name of elements in order to travel from root for child to go to the children to 4999 Twitter The Video then subscribe to the Page if you liked The Video then subscribe to the and sorry...
N-ary Tree Preorder Traversal
n-ary-tree-preorder-traversal
Given the `root` of an n-ary tree, return _the preorder traversal of its nodes' values_. Nary-Tree input serialization is represented in their level order traversal. Each group of children is separated by the null value (See examples) **Example 1:** **Input:** root = \[1,null,3,2,4,null,5,6\] **Output:** \[1,3,5,6,2...
null
null
Easy
null
436
hello everyone and today we are going to solve find right interval so that's our problem for today and we are at day 27 so we almost we are almost at the end of august and now or today's problem is uh if you solve it by a brute force approach uh it will be accepted and that's what i'm going to show today if you want a ...
Find Right Interval
find-right-interval
You are given an array of `intervals`, where `intervals[i] = [starti, endi]` and each `starti` is **unique**. The **right interval** for an interval `i` is an interval `j` such that `startj >= endi` and `startj` is **minimized**. Note that `i` may equal `j`. Return _an array of **right interval** indices for each int...
null
Array,Binary Search,Sorting
Medium
352
1,813
hello everyone now we are here to solve question number 18 13 of lead code sentence similarity three it's a medium level question so it is a good one okay let's see over what the question is asking sentence a list of words that are separated by a single is the main question two sentences sentence one and sentence two a...
Sentence Similarity III
maximum-erasure-value
A sentence is a list of words that are separated by a single space with no leading or trailing spaces. For example, `"Hello World "`, `"HELLO "`, `"hello world hello world "` are all sentences. Words consist of **only** uppercase and lowercase English letters. Two sentences `sentence1` and `sentence2` are **similar** ...
The main point here is for the subarray to contain unique elements for each index. Only the first subarrays starting from that index have unique elements. This can be solved using the two pointers technique
Array,Hash Table,Sliding Window
Medium
3
1,381
Loot Hello viewers welcome back to my channel I hope you are doing all problems at 3am plodding history subscribe To My Channel Please 28 subscribe and also share magar friends today's problem is design stocks with instrument operations on this web design problem vv how to design Stand with Instrument Operation Normall...
Design a Stack With Increment Operation
maximum-score-words-formed-by-letters
Design a stack that supports increment operations on its elements. Implement the `CustomStack` class: * `CustomStack(int maxSize)` Initializes the object with `maxSize` which is the maximum number of elements in the stack. * `void push(int x)` Adds `x` to the top of the stack if the stack has not reached the `max...
Note that words.length is small. This means you can iterate over every subset of words (2^N).
Array,String,Dynamic Programming,Backtracking,Bit Manipulation,Bitmask
Hard
2272
63
everyone welcome to my channel again so today we will discuss one problem from lead code that is unique path 2 and the problem number is 63 so before coming to this problem i will highly recommend you to go through this problem that is unique paths after completing this problem if you come to this problem it will be ve...
Unique Paths II
unique-paths-ii
You are given an `m x n` integer array `grid`. There is a robot 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. An obstacle and space are marked as ...
The robot can only move either down or right. Hence any cell in the first row can only be reached from the cell left to it. However, if any cell has an obstacle, you don't let that cell contribute to any path. So, for the first row, the number of ways will simply be if obstacleGrid[i][j] is not an obstacle ...
Array,Dynamic Programming,Matrix
Medium
62,1022
1,984
hey everyone welcome back and let's write some more neat code today let's solve minimum difference between highest and lowest of k scores this is the easy problem from today's leak code contest so we're given an array of nums each value in the array represents a student's score that's not really super important but we ...
Minimum Difference Between Highest and Lowest of K Scores
maximum-distance-between-a-pair-of-values
You are given a **0-indexed** integer array `nums`, where `nums[i]` represents the score of the `ith` student. You are also given an integer `k`. Pick the scores of any `k` students from the array so that the **difference** between the **highest** and the **lowest** of the `k` scores is **minimized**. Return _the **m...
Since both arrays are sorted in a non-increasing way this means that for each value in the first array. We can find the farthest value smaller than it using binary search. There is another solution using a two pointers approach since the first array is non-increasing the farthest j such that nums2[j] ≥ nums1[i] is at l...
Array,Two Pointers,Binary Search,Greedy
Medium
2199
96
hi everyone today we are going to disrupt the little question unique binary search tree so you are given an integer n Returns the number of structurally unique binary search trees which has exact any nodes of unique values from 1 to n so let's see the example so you are given n equals 3 and the output should be 5 becau...
Unique Binary Search Trees
unique-binary-search-trees
Given an integer `n`, return _the number of structurally unique **BST'**s (binary search trees) which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`. **Example 1:** **Input:** n = 3 **Output:** 5 **Example 2:** **Input:** n = 1 **Output:** 1 **Constraints:** * `1 <= n <= 19`
null
Math,Dynamic Programming,Tree,Binary Search Tree,Binary Tree
Medium
95
1,793
the problem maximum score of a good sub okay so let's read the problem so you have been given an array of integer nums and an integer K okay the score of a sub I and J is defined as minimum of nums I to J and then multiply by J minus a + 1 to J and then multiply by J minus a + 1 to J and then multiply by J minus a + 1 ...
Maximum Score of a Good Subarray
minimum-moves-to-make-array-complementary
You are given an array of integers `nums` **(0-indexed)** and an integer `k`. The **score** of a subarray `(i, j)` is defined as `min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1)`. A **good** subarray is a subarray where `i <= k <= j`. Return _the maximum possible **score** of a **good** subarray._ **Example 1:**...
Given a target sum x, each pair of nums[i] and nums[n-1-i] would either need 0, 1, or 2 modifications. Can you find the optimal target sum x value such that the sum of modifications is minimized? Create a difference array to efficiently sum all the modifications.
Array,Hash Table,Prefix Sum
Medium
null
1,943
hey what's up guys this is sean here again so this time it called number 1943 describe the penny right so this time um this is like uh an interval problem right where we have a long and thin painting blah right and then we also have like start and end right but this time we have a color right so for each segment we hav...
Describe the Painting
count-pairs-of-equal-substrings-with-minimum-difference
There is a long and thin painting that can be represented by a number line. The painting was painted with multiple overlapping segments where each segment was painted with a **unique** color. You are given a 2D integer array `segments`, where `segments[i] = [starti, endi, colori]` represents the **half-closed segment**...
If the chosen substrings are of size larger than 1, then you can remove all but the first character from both substrings, and you'll get equal substrings of size 1, with the same a but less j. Hence, it's always optimal to choose substrings of size 1. If you choose a specific letter, then it's optimal to choose its fir...
Hash Table,String,Greedy
Medium
null
110
great so welcome back and this is a question called balance binary tree and it's an easy level binary tree question where we are given a tree and we want to check if its height is balanced so the important thing to realize that a balanced binary tree is not only balanced at the root level but the sub trees are balanced...
Balanced Binary Tree
balanced-binary-tree
Given a binary tree, determine if it is **height-balanced**. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** true **Example 2:** **Input:** root = \[1,2,2,3,3,null,null,4,4\] **Output:** false **Example 3:** **Input:** root = \[\] **Output:** true **Constraints:** * The number of nodes ...
null
Tree,Depth-First Search,Binary Tree
Easy
104
97
hey everybody this is larry this is day two of the june eco daily challenge hit the like button in the subscribe button join me on discord let me know what you think about today's prom and welcome if you're new if not that's fine too let's just you know enjoy this problem and join me on discord we could chat about it o...
Interleaving String
interleaving-string
Given strings `s1`, `s2`, and `s3`, find whether `s3` is formed by an **interleaving** of `s1` and `s2`. An **interleaving** of two strings `s` and `t` is a configuration where `s` and `t` are divided into `n` and `m` substrings respectively, such that: * `s = s1 + s2 + ... + sn` * `t = t1 + t2 + ... + tm` * `|...
null
String,Dynamic Programming
Medium
null
95
welcome to june's leeco challenge today's problem is unique binary search trees given n some number how many structurally unique binary search trees are there that store values 1 through n for example if we're given the number three that means there's going to be three nodes one two three how many unique binary search ...
Unique Binary Search Trees II
unique-binary-search-trees-ii
Given an integer `n`, return _all the structurally unique **BST'**s (binary search trees), which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`. Return the answer in **any order**. **Example 1:** **Input:** n = 3 **Output:** \[\[1,null,2,null,3\],\[1,null,3,2\],\[2,1,3\],\[3,1,null,null,2\],\[3,2,null,1\...
null
Dynamic Programming,Backtracking,Tree,Binary Search Tree,Binary Tree
Medium
96,241
54
hey guys welcome back to the channel in the previous video we went through this legal problem um spiral matrix however today we're going to actually visualize this code and see what's actually going on as always this is the exact same function we created enrico however i did create this driver function which kind of in...
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
551
I didn't tweet this that's why I was a little faster than usual okay 551 student attendance record one you're given a string representing as an attendance record for student Wicker only contains two filing three letters al MP for absent main and pleasant a student could be one of its attendants marketers and contain mo...
Student Attendance Record I
student-attendance-record-i
You are given a string `s` representing an attendance record for a student where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three characters: * `'A'`: Absent. * `'L'`: Late. * `'P'`: Present. The student is eligible for an attend...
null
String
Easy
552
518
hey everybody this is Larry this is day 11 of the August hit the like button hit the Subscribe button join me on Discord let me know what you think about today's form if I could click on it uh yeah today's problem is 518 coin change two so a little bit of a disclaimer I'm going to get uh well I'm not the beginner anymo...
Coin Change II
coin-change-2
You are given an integer array `coins` representing coins of different denominations and an integer `amount` representing a total amount of money. Return _the number of combinations that make up that amount_. If that amount of money cannot be made up by any combination of the coins, return `0`. You may assume that yo...
null
Array,Dynamic Programming
Medium
1393
1,791
welcome back everyone we're gonna be solving Lee code 1791 find center of a star graph so 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 minus one edges that connect the center node with every other node and we are given a...
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
299
Hello Everybody Welcome To My Channel Let's Solve All Today's Problem But Before You Start The Problem Here Is The Result Of Community post-poll Yesterday Is Posted This Community post-poll Yesterday Is Posted This Community post-poll Yesterday Is Posted This Over Template Coloring Black And White Sauce Clear Winner Is...
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
283
hey guys welcome back to my channel and i hope you are all doing great today we are going to see one more important problem from the lead code the problem difficulty is easy problem number 283 move zeros let's see what this problem is all about we are given an integer r nums and we need to move all zeros to the end of ...
Move Zeroes
move-zeroes
Given an integer array `nums`, move all `0`'s to the end of it while maintaining the relative order of the non-zero elements. **Note** that you must do this in-place without making a copy of the array. **Example 1:** **Input:** nums = \[0,1,0,3,12\] **Output:** \[1,3,12,0,0\] **Example 2:** **Input:** nums = \[0\]...
In-place means we should not be allocating any space for extra array. But we are allowed to modify the existing array. However, as a first step, try coming up with a solution that makes use of additional space. For this problem as well, first apply the idea discussed using an additional array and the in-place solution ...
Array,Two Pointers
Easy
27
48
code problem number 48 rotate image so this problem gives us a n * n 2D Matrix this problem gives us a n * n 2D Matrix this problem gives us a n * n 2D Matrix which means it's going to be a square Matrix representing an image the goal is to rotate the image by 90 degrees clockwise here are some additional rules we have...
Rotate Image
rotate-image
You are given an `n x n` 2D `matrix` representing an image, rotate the image by **90** degrees (clockwise). You have to rotate the image [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm), which means you have to modify the input 2D matrix directly. **DO NOT** allocate another 2D matrix and do the rotati...
null
Array,Math,Matrix
Medium
2015
1,027
hi everyone in today challenge we are going to solve this problem the problem in the longest arithmetic subsequence and the problem number is one zero two seven as usual first of all we are going to clearly understand this problem statement after that we are going to move to the logic part we are going to see how we ca...
Longest Arithmetic Subsequence
sum-of-even-numbers-after-queries
Given an array `nums` of integers, return _the length of the longest arithmetic subsequence in_ `nums`. **Note** that: * A **subsequence** is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements. * A sequence `seq` is arithmetic if `s...
null
Array,Simulation
Medium
null
274
So hey guys welcome to code today we are going to do a medium level question of Lee which is h index okay so the question is like given an array of inj site where site of a is the number of sites researcher received for their i paper Return The Researcher's H Index Okay, first let's understand what a site is. Sites are...
H-Index
h-index
Given an array of integers `citations` where `citations[i]` is the number of citations a researcher received for their `ith` paper, return _the researcher's h-index_. According to the [definition of h-index on Wikipedia](https://en.wikipedia.org/wiki/H-index): The h-index is defined as the maximum value of `h` such th...
An easy approach is to sort the array first. What are the possible values of h-index? A faster approach is to use extra space.
Array,Sorting,Counting Sort
Medium
275
1,814
all right let's talk about accounts nice peers in array so you're giving the array numbers that consist of non-negative number non-negative number non-negative number and then the basic idea is you have to satisfy the following condition for i less than j less than num star length num psi plus reverse j equal to num sh...
Count Nice Pairs in an Array
jump-game-vi
You are given an array `nums` that consists of non-negative integers. Let us define `rev(x)` as the reverse of the non-negative integer `x`. For example, `rev(123) = 321`, and `rev(120) = 21`. A pair of indices `(i, j)` is **nice** if it satisfies all of the following conditions: * `0 <= i < j < nums.length` * `nu...
Let dp[i] be "the maximum score to reach the end starting at index i". The answer for dp[i] is nums[i] + max{dp[i+j]} for 1 <= j <= k. That gives an O(n*k) solution. Instead of checking every j for every i, keep track of the largest dp[i] values in a heap and calculate dp[i] from right to left. When the largest value i...
Array,Dynamic Programming,Queue,Sliding Window,Heap (Priority Queue),Monotonic Queue
Medium
239,2001
1,293
hey what's up guys chung here again and today let's take a look at another elite code problem here number 1293 short is the path in the grid is obstacles elimination you're given an m times n 2d grid where the cell could be either zero or one zero means you can pass and one means it's obstacle and you can move freely i...
Shortest Path in a Grid with Obstacles Elimination
three-consecutive-odds
You are given an `m x n` integer matrix `grid` where each cell is either `0` (empty) or `1` (obstacle). You can move up, down, left, or right from and to an empty cell in **one step**. Return _the minimum number of **steps** to walk from the upper left corner_ `(0, 0)` _to the lower right corner_ `(m - 1, n - 1)` _giv...
Check every three consecutive numbers in the array for parity.
Array
Easy
null
81
r security in the rejoinder is possible not since incredible feel favored evangelists softer and clearer 3 or frauds nation more receives the power and it is easy to do ah ok given vet it is not limited the writing and small that or no yes he and you go to yes als parís mel es golden dawn or you smell deslindes more pr...
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
1,742
welcome back for another video we are going to do another equal question the question is maximum number of balls in a box you are working in a ball factory where you have ambles numbered from low limit up to high limit inclusive and is equal to high limit minus low limit plus one and the infinite number of boxes number...
Maximum Number of Balls in a Box
widest-vertical-area-between-two-points-containing-no-points
You are working in a ball factory where you have `n` balls numbered from `lowLimit` up to `highLimit` **inclusive** (i.e., `n == highLimit - lowLimit + 1`), and an infinite number of boxes numbered from `1` to `infinity`. Your job at this factory is to put each ball in the box with a number equal to the sum of digits ...
Try sorting the points Think is the y-axis of a point relevant
Array,Sorting
Medium
null
923
welcome to march's leeco challenge today's problem is threesome with multiplicity given an integer array r and integer target we turn the number of tuples i j k such that i is less than j and j is less than k and ri plus rj plus rk is going to equal to the target if the answer is very large we turn it modulo 10 to the ...
3Sum With Multiplicity
super-egg-drop
Given an integer array `arr`, and an integer `target`, return the number of tuples `i, j, k` such that `i < j < k` and `arr[i] + arr[j] + arr[k] == target`. As the answer can be very large, return it **modulo** `109 + 7`. **Example 1:** **Input:** arr = \[1,1,2,2,3,3,4,4,5,5\], target = 8 **Output:** 20 **Explanatio...
null
Math,Binary Search,Dynamic Programming
Hard
2031
1,769
Ki K Khi also 150 Arvind Solv Amazon online play the Question is the number of you and you to two Is 9th complete and take the question example 12345 is a pointer pmpoint and post element of a great and even last hunter pmpoint glass elements and e will give oo that sub committee battu ke no what will oo Neeru this poi...
Minimum Number of Operations to Move All Balls to Each Box
get-maximum-in-generated-array
You have `n` boxes. You are given a binary string `boxes` of length `n`, where `boxes[i]` is `'0'` if the `ith` box is **empty**, and `'1'` if it contains **one** ball. In one operation, you can move **one** ball from a box to an adjacent box. Box `i` is adjacent to box `j` if `abs(i - j) == 1`. Note that after doing ...
Try generating the array. Make sure not to fall in the base case of 0.
Array,Dynamic Programming,Simulation
Easy
null
127
welcome to another lead code problem discussion today's problem is problem 1 to7 Word ladder uh this is one of the problems within the blind 75 list so without further delay let's see the problem description so what we have here is we will be given a string or word the begin word and also another word the end word and ...
Word Ladder
word-ladder
A **transformation sequence** from word `beginWord` to word `endWord` using a dictionary `wordList` is a sequence of words `beginWord -> s1 -> s2 -> ... -> sk` such that: * Every adjacent pair of words differs by a single letter. * Every `si` for `1 <= i <= k` is in `wordList`. Note that `beginWord` does not need ...
null
Hash Table,String,Breadth-First Search
Hard
126,433
232
hey everybody welcome back to another lead code two three two implement queue using stacks this is an easy one and a very uh you can say uh important one interesting one we have already done stacks use implement stack using queues and this is just the opposite implement of first and first out q is first and first out u...
Implement Queue using Stacks
implement-queue-using-stacks
Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (`push`, `peek`, `pop`, and `empty`). Implement the `MyQueue` class: * `void push(int x)` Pushes element x to the back of the queue. * `int pop()` Removes the element from th...
null
Stack,Design,Queue
Easy
225
373
hello welcome to my channel today if you have leeco 373 find k pairs with smaller sum so in this question uh pretty straightforward it's like a permutation problem we have input nums one as a array of integer num to another array of integer and k is three so the permutation will uh get one numbers from here and get ano...
Find K Pairs with Smallest Sums
find-k-pairs-with-smallest-sums
You are given two integer arrays `nums1` and `nums2` sorted in **ascending order** and an integer `k`. Define a pair `(u, v)` which consists of one element from the first array and one element from the second array. Return _the_ `k` _pairs_ `(u1, v1), (u2, v2), ..., (uk, vk)` _with the smallest sums_. **Example 1:**...
null
Array,Heap (Priority Queue)
Medium
378,719,2150
131
um hello so today we are going to do this problem which is part of Fleet code January daddy challenge so palindrome partitioning so we get a string s um such that every substring of the partition um basically we get a string s and we want to partition it such that every substring of that partition is a palindrome and a...
Palindrome Partitioning
palindrome-partitioning
Given a string `s`, partition `s` such that every substring of the partition is a **palindrome**. Return _all possible palindrome partitioning of_ `s`. **Example 1:** **Input:** s = "aab" **Output:** \[\["a","a","b"\],\["aa","b"\]\] **Example 2:** **Input:** s = "a" **Output:** \[\["a"\]\] **Constraints:** * `1...
null
String,Dynamic Programming,Backtracking
Medium
132,1871
934
hey there today we will be doing this question from the graph playlist of fleet code that is 934 shortest bridge and the other videos from the d5 till the day five have been already been uploaded please do check those out that will be helpful to you as well and to me as well and today's question is 934 shortest bridge ...
Shortest Bridge
bitwise-ors-of-subarrays
You are given an `n x n` binary matrix `grid` where `1` represents land and `0` represents water. An **island** is a 4-directionally connected group of `1`'s not connected to any other `1`'s. There are **exactly two islands** in `grid`. You may change `0`'s to `1`'s to connect the two islands to form **one island**. ...
null
Array,Dynamic Programming,Bit Manipulation
Medium
null
1,818
today we're doing problem 1818 minimum the smallest absolute tells you well it depends on what it is absolute is usually positive right like absolute difference the minimum the smallest absolute sum is when you take things and you add them together different so the minimum absolute sum difference all right minimum abso...
Minimum Absolute Sum Difference
maximum-score-from-removing-substrings
You are given two positive integer arrays `nums1` and `nums2`, both of length `n`. The **absolute sum difference** of arrays `nums1` and `nums2` is defined as the **sum** of `|nums1[i] - nums2[i]|` for each `0 <= i < n` (**0-indexed**). You can replace **at most one** element of `nums1` with **any** other element in ...
Note that it is always more optimal to take one type of substring before another You can use a stack to handle erasures
String,Stack,Greedy
Medium
2256
16
hi guys welcome back to another video today's lead quote question is threesome closest which states that given an array numbers of n integers and an integer target find three integers in nums such that the sum is closest to target return the sum of the three integers you may assume that each input would have exactly on...
3Sum Closest
3sum-closest
Given an integer array `nums` of length `n` and an integer `target`, find three integers in `nums` such that the sum is closest to `target`. Return _the sum of the three integers_. You may assume that each input would have exactly one solution. **Example 1:** **Input:** nums = \[-1,2,1,-4\], target = 1 **Output:** ...
null
Array,Two Pointers,Sorting
Medium
15,259
658
this video we're going to look at a legal problem called find closest elements so given a sorted integer array two integers k and x return the k closest integers to x in the array so the result should also be sorted in ascending order and integer a is closer to x than an integer b if a minus x right the absolute value ...
Find K Closest Elements
find-k-closest-elements
Given a **sorted** integer array `arr`, two integers `k` and `x`, return the `k` closest integers to `x` in the array. The result should also be sorted in ascending order. An integer `a` is closer to `x` than an integer `b` if: * `|a - x| < |b - x|`, or * `|a - x| == |b - x|` and `a < b` **Example 1:** **Input:...
null
Array,Two Pointers,Binary Search,Sorting,Heap (Priority Queue)
Medium
374,375,719
91
okay let's talk about the code waves in this question you are given a messages that contains later from a to z and can be encoded into numbers using the following mapping so a equal to 1 be equal to 2 and c equal to 3 and so on right so in this question you are given the integer string and you are going to return how m...
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
55
hello guys welcome to algorithms made easy my name is richard and today we will be discussing the question jump game in this question we are given an integer array norms and we are initially positioned at the array's first index and each element in the array represent the maximum jump that we can take from that particu...
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
72
okay today we will look at the problem number 72 which is a distance before this was marked as hard but now since this has become very popular now this has become quite medium and this is become basis of many other uh problems so let's look at the problem so we are given two words word one and word two we are asked to ...
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,910
hey everyone welcome back to my channel today let's go through legal problem 1910 remove all occurrences of a substring let's take a look at the problem first given two strings s and part perform the following operation on s until all occurrences of the substring part are removed so one rule of this problem is that we ...
Remove All Occurrences of a Substring
check-if-binary-string-has-at-most-one-segment-of-ones
Given two strings `s` and `part`, perform the following operation on `s` until **all** occurrences of the substring `part` are removed: * Find the **leftmost** occurrence of the substring `part` and **remove** it from `s`. Return `s` _after removing all occurrences of_ `part`. A **substring** is a contiguous seque...
It's guaranteed to have at least one segment The string size is small so you can count all segments of ones with no that have no adjacent ones.
String
Easy
1999
1,799
all right what is up here back and uh we're gonna be trying today's uh leeco daily challenge so it reads uh maximize the score after n operations uh it's a hard one so you're given nums an array of positive integers of size 2N you must perform n operations on this array in the ith operation one indexed you will choose ...
Maximize Score After N Operations
minimum-incompatibility
You are given `nums`, an array of positive integers of size `2 * n`. You must perform `n` operations on this array. In the `ith` operation **(1-indexed)**, you will: * Choose two elements, `x` and `y`. * Receive a score of `i * gcd(x, y)`. * Remove `x` and `y` from `nums`. Return _the maximum score you can rec...
The constraints are small enough for a backtrack solution but not any backtrack solution If we use a naive n^k don't you think it can be optimized
Array,Dynamic Programming,Bit Manipulation,Bitmask
Hard
null
138
Hello Donkeys of Mobile Companies Alarm List Question And In This Bluetooth That Ravana Purchases That Thursday Loot Into Custody Copy and Paste This List To WhatsApp Question Pimple Veer Which Can Instead Of KFC Remind Me Liquid And Which Contains Notes Like This Is Not Interested In These questions are related to Vih...
Copy List with Random Pointer
copy-list-with-random-pointer
A linked list of length `n` is given such that each node contains an additional random pointer, which could point to any node in the list, or `null`. Construct a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) of the list. The deep copy should consist of exactly `n` **brand new** nodes, where e...
Just iterate the linked list and create copies of the nodes on the go. Since a node can be referenced from multiple nodes due to the random pointers, make sure you are not making multiple copies of the same node. You may want to use extra space to keep old node ---> new node mapping to prevent creating multiples copies...
Hash Table,Linked List
Medium
133,1624,1634
980
hey everybody this is Larry this is day is it the last day it is huh the last day of the year hit the like button hit the Subscribe button join me on Discord and with this problem we would have done every problem uh we will have a video for every Prime this year and more if you've been following because you know that w...
Unique Paths III
find-the-shortest-superstring
You are given an `m x n` integer array `grid` where `grid[i][j]` could be: * `1` representing the starting square. There is exactly one starting square. * `2` representing the ending square. There is exactly one ending square. * `0` representing empty squares we can walk over. * `-1` representing obstacles tha...
null
Array,String,Dynamic Programming,Bit Manipulation,Bitmask
Hard
null
424
hello guys what's up this is the polyglot programmer and i'm back today actually it's pretty late at night it's almost 10 p.m late at night it's almost 10 p.m late at night it's almost 10 p.m here in the netherlands uh and in the back you can hear my airfryer it's cooking my kitchen my chicken so i wanna uh but i still...
Longest Repeating Character Replacement
longest-repeating-character-replacement
You are given a string `s` and an integer `k`. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most `k` times. Return _the length of the longest substring containing the same letter you can get after performing the above operations_. ...
null
Hash Table,String,Sliding Window
Medium
340,1046,2119,2134,2319
696
hi guys this is kushpu and welcome to algorithms made easy in this video we will see the question count binary substrings given a string s count the number of non-empty sub strings non-empty sub strings non-empty sub strings that have the same number of zeros and ones and all the zeros and all the ones in this substrin...
Count Binary Substrings
count-binary-substrings
Given a binary string `s`, return the number of non-empty substrings that have the same number of `0`'s and `1`'s, and all the `0`'s and all the `1`'s in these substrings are grouped consecutively. Substrings that occur multiple times are counted the number of times they occur. **Example 1:** **Input:** s = "001100...
How many valid binary substrings exist in "000111", and how many in "11100"? What about "00011100"?
Two Pointers,String
Easy
271
1,727
Hello everyone welcome to CP Gig and today we will be solving the question largest sub matrix with rearrangements so you are given a binary matrix of size m cross n and you are allowed to rearrange the columns of the matrix in any order return the area of ​​largest Sub matrix return the area of ​​largest Sub matrix ret...
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
378
hey everybody this is larry this is me going over um the seventh day of july uh for the daily little challenge uh cave smallest element in sort of the matrix hit the like button hit the subscribe button join me on discord let me know what you think about this forum uh usually i saw these live and you could still see me...
Kth Smallest Element in a Sorted Matrix
kth-smallest-element-in-a-sorted-matrix
Given an `n x n` `matrix` where each of the rows and columns is sorted in ascending order, return _the_ `kth` _smallest element in the matrix_. Note that it is the `kth` smallest element **in the sorted order**, not the `kth` **distinct** element. You must find a solution with a memory complexity better than `O(n2)`....
null
Array,Binary Search,Sorting,Heap (Priority Queue),Matrix
Medium
373,668,719,802
1,375
hello and let's go through this slight problem so there's a room with M bobs and a number from one to n a range in a row from left to right so usually all pubs are turned off at the moment k which is from 0 to n minus when we turn on the light k Bob so Bob change color to Blue if it is on and all the previous bulbs are...
Number of Times Binary String Is Prefix-Aligned
find-palindrome-with-fixed-length
You have a **1-indexed** binary string of length `n` where all the bits are `0` initially. We will flip all the bits of this binary string (i.e., change them from `0` to `1`) one by one. You are given a **1-indexed** integer array `flips` where `flips[i]` indicates that the bit at index `i` will be flipped in the `ith`...
For any value of queries[i] and intLength, how can you check if there exists at least queries[i] palindromes of length intLength? Since a palindrome reads the same forwards and backwards, consider how you can efficiently find the first half (ceil(intLength/2) digits) of the palindrome.
Array,Math
Medium
9,564
224
hi everyone let's take a look at number 224 basic a clear clean implement the basic calculator to evaluate simple string with parentheses and plus/minus string with parentheses and plus/minus string with parentheses and plus/minus non-negative integers and empty cases in non-negative integers and empty cases in non-neg...
Basic Calculator
basic-calculator
Given a string `s` representing a valid expression, implement a basic calculator to evaluate it, and return _the result of the evaluation_. **Note:** You are **not** allowed to use any built-in function which evaluates strings as mathematical expressions, such as `eval()`. **Example 1:** **Input:** s = "1 + 1 " **O...
null
Math,String,Stack,Recursion
Hard
150,227,241,282,785,2147,2328
7
we now have this lead code challenge called reverse integer given is signed 32 bits integer called X we have to return x with its digits reversed there is a chance that the value is going to overflow meaning is going to go outside of the allows memory space for that integer and in which case we need to return 0. for ex...
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
616
hey what's up guys this is chung here again so this time i want to talk about this called problem 616. add bold tag in string so let's take a look at the description of the problem here so you're given like a string and a dictionary of words right and you need to add anything that appears in this dictionary and encapsu...
Add Bold Tag in String
add-bold-tag-in-string
You are given a string `s` and an array of strings `words`. You should add a closed pair of bold tag **and** to wrap the substrings in `s` that exist in `words`. * If two such substrings overlap, you should wrap them together with only one pair of closed bold-tag. * If two substrings wrapped by bold tags are cons...
null
Array,Hash Table,String,Trie,String Matching
Medium
56,591
260
hey everybody this is Larry there's a state 23rd of July Lakota recharge yeah hit the like button to subscribe and let me know what your friend can hit join it this chord let's get started single number three given in a way of numbers in which exactly two elements appear once and all the other elements appear exactly t...
Single Number III
single-number-iii
Given an integer array `nums`, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. You can return the answer in **any order**. You must write an algorithm that runs in linear runtime complexity and uses only constant extra space. ...
null
Array,Bit Manipulation
Medium
136,137
1,004
hello everyone welcome to courage camp we are at 29th day of june later challenge and the problem we are going to cover today is max consecutive ones three so the input given here is a integer array nums which consists of only ones and zeros and an integer variable k and we have to return the maximum number of consecut...
Max Consecutive Ones III
least-operators-to-express-number
Given a binary array `nums` and an integer `k`, return _the maximum number of consecutive_ `1`_'s in the array if you can flip at most_ `k` `0`'s. **Example 1:** **Input:** nums = \[1,1,1,0,0,0,1,1,1,1,0\], k = 2 **Output:** 6 **Explanation:** \[1,1,1,0,0,**1**,1,1,1,1,**1**\] Bolded numbers were flipped from 0 to 1....
null
Math,Dynamic Programming
Hard
null
10
all right guys happy chinese new year and uh today i'm going to talk about question 10 on the code so we're given a input string s and a pattern p and we're trying to implement a regular expression matching that supports dot and star where the dot can match any single character and star can match zero or more of the pr...
Regular Expression Matching
regular-expression-matching
Given an input string `s` and a pattern `p`, implement regular expression matching with support for `'.'` and `'*'` where: * `'.'` Matches any single character.​​​​ * `'*'` Matches zero or more of the preceding element. The matching should cover the **entire** input string (not partial). **Example 1:** **Input:...
null
String,Dynamic Programming,Recursion
Hard
44
66
series we are gonna solve the question name plus one so this is the 66th question in the e-code problems there question in the e-code problems there question in the e-code problems there will be linked to this after watching the video if you want to go check it out and try to solve it so let's first read the question t...
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
808
hey everybody this is Larry this is me going over the uh the daily problem for July 28th or 29th I guess but I'm doing on the 28th uh 808 soup servings so actually um as you can see I already kind of solved this Farm a little bit um this video was kind of long so I just want to give you an intro before you actually see...
Soup Servings
number-of-matching-subsequences
There are two types of soup: **type A** and **type B**. Initially, we have `n` ml of each type of soup. There are four kinds of operations: 1. Serve `100` ml of **soup A** and `0` ml of **soup B**, 2. Serve `75` ml of **soup A** and `25` ml of **soup B**, 3. Serve `50` ml of **soup A** and `50` ml of **soup B**, an...
null
Hash Table,String,Trie,Sorting
Medium
392,1051,2186