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
424
in this video we're going to look at a legal problem called longest repeating character replacement so we're basically given a string and a integer value k and we want to find the longest repeating character after we can be able to replace k characters right if we were to have the chance to replace k characters in a st...
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
1,306
hey everybody this is larry this is day 29 of the lead code november daily challenge hit the like button hit the subscribe on drum and discord it's almost to the end so you know make sure i don't know you finished the month in a strong way and this is jump game three okay so which variation is this so given an array yo...
Jump Game III
minimum-absolute-difference
Given an array of non-negative integers `arr`, you are initially positioned at `start` index of the array. When you are at index `i`, you can jump to `i + arr[i]` or `i - arr[i]`, check if you can reach to **any** index with value 0. Notice that you can not jump outside of the array at any time. **Example 1:** **Inp...
Find the minimum absolute difference between two elements in the array. The minimum absolute difference must be a difference between two consecutive elements in the sorted array.
Array,Sorting
Easy
2248
1,057
hey what's up guys John here so this time let's take a look at another lead called problem 1057 Kemper spikes a very interesting problem I'm gonna give my own vote here so there's a campers represented as a to degrade and on each of the coordinates here they're like some bikes and some workers each often will be repres...
Campus Bikes
numbers-with-repeated-digits
On a campus represented on the X-Y plane, there are `n` workers and `m` bikes, with `n <= m`. You are given an array `workers` of length `n` where `workers[i] = [xi, yi]` is the position of the `ith` worker. You are also given an array `bikes` of length `m` where `bikes[j] = [xj, yj]` is the position of the `jth` bike...
How many numbers with no duplicate digits? How many numbers with K digits and no duplicates? How many numbers with same length as N? How many numbers with same prefix as N?
Math,Dynamic Programming
Hard
null
382
okay guys so this will be our seventh problem of the late code january 2022 the daily problems and today we are going to face the problem linked list random node its index is 382 and it is the medium type problem of the lead code okay so the prerequisites required to solve such type of problems is like you must be fami...
Linked List Random Node
linked-list-random-node
Given a singly linked list, return a random node's value from the linked list. Each node must have the **same probability** of being chosen. Implement the `Solution` class: * `Solution(ListNode head)` Initializes the object with the head of the singly-linked list `head`. * `int getRandom()` Chooses a node randoml...
null
Linked List,Math,Reservoir Sampling,Randomized
Medium
398
48
hello everyone what's up today in this video we'll be solving this question called rotate image which is one of the most commonly asked questions by facebook as mentioned by elite code and if you like watching these videos then please do consider subscribing to this channel and sharing it with your friends would really...
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
126
hey everybody this is larry this is me doing the day 14 of the august eco daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's farm word ladder too uh also for my usual people i do an extra problem uh because nowadays i feel like every problem i've don...
Word Ladder II
word-ladder-ii
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,Backtracking,Breadth-First Search
Hard
127,2276
347
welcome back to algojs today's question is leak code 347 top k frequent element so you're given an integer array nums and an integer k return the k most frequent elements you may return the answer in any order so in example one we have an oms array and we have k which is set to two so we need to return the k most frequ...
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
5
hello everyone my name is raveena welcome to City coder today we are going to solve problem number five that is longest palindromic substring so let's start reading the problem statement it says that given a string s return the longest palindromic substring in s so first of all what is subscript what is a palindrome so...
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
3
Hello Everyone Welcome Back To Channels Iodine Extremely Well Suitable Also Solving Problems Long Spring Without Reading Practice All Problems Tube Baby Aspirin Gas Any To Find The Length Of The Longest Born Without Revealing Characters For Example Of Giving A String In The Longest Running Without Putting Characters Hi...
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
121
hey everyone welcome back and let's write some more neat code today and don't forget to hit the like button it supports the channel a lot so today let's look at leak code 121 best time to buy and sell a stock so if you know a little about the stock market the saying is usually buy low and sell high so in this case we'r...
Best Time to Buy and Sell Stock
best-time-to-buy-and-sell-stock
You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day. You want to maximize your profit by choosing a **single day** to buy one stock and choosing a **different day in the future** to sell that stock. Return _the maximum profit you can achieve from this transaction_. If you ...
null
Array,Dynamic Programming
Easy
53,122,123,188,309,2138,2144
84
what up this is Jackson Gabbard back for episode 5 of the unqualified engineer I'm going to be real with you people getting a little bit bored with the polite PC delicate episodes that I've been up to recently I'd like to just keep it a little bit more real with you all and so this episode you're gonna get the raw uncu...
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
189
hi all welcome to learn code repeat so today we'll be looking at day 15 of the october elite food challenge the name of the problem is rotate array so before we start the problem if you haven't subscribed to the channel please do subscribe to the channel and hit the bell icon so let us look into the problem so the prob...
Rotate Array
rotate-array
Given an integer array `nums`, rotate the array to the right by `k` steps, where `k` is non-negative. **Example 1:** **Input:** nums = \[1,2,3,4,5,6,7\], k = 3 **Output:** \[5,6,7,1,2,3,4\] **Explanation:** rotate 1 steps to the right: \[7,1,2,3,4,5,6\] rotate 2 steps to the right: \[6,7,1,2,3,4,5\] rotate 3 steps to...
The easiest solution would use additional memory and that is perfectly fine. The actual trick comes when trying to solve this problem without using any additional memory. This means you need to use the original array somehow to move the elements around. Now, we can place each element in its original location and shift ...
Array,Math,Two Pointers
Medium
61,186
622
hey everyone welcome back and let's write some more neat code today so today let's solve the problem design a circular queue basically we want to implement this data structure a circular queue where the operations are performed in fifo order so as we add elements to the queue we're going to be removing the ones that we...
Design Circular Queue
design-circular-queue
Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle, and the last position is connected back to the first position to make a circle. It is also called "Ring Buffer ". One of the benefits of th...
null
null
Medium
null
6
hello everyone welcome or welcome back to coding chance in this video we are going to be solving the problem zigzag conversion in this problem we are given with a string which is written in a zigzag pattern on a given number of rows like this and we have to then read it line by line so if this is the exact pattern of t...
Zigzag Conversion
zigzag-conversion
The string `"PAYPALISHIRING "` is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: `"PAHNAPLSIIGYIR "` Write the code that will take a string and make this co...
null
String
Medium
null
746
hi everyone today we are going to solve the little question minkos climbing stairs so you are given an integer array cost where cost I is the cost of I step or staircase once you pay the cost you can either climb one or two steps you can either start from the step with index 0 it was a step with index one Returns the m...
Min Cost Climbing Stairs
prefix-and-suffix-search
You are given an integer array `cost` where `cost[i]` is the cost of `ith` step on a staircase. Once you pay the cost, you can either climb one or two steps. You can either start from the step with index `0`, or the step with index `1`. Return _the minimum cost to reach the top of the floor_. **Example 1:** **Input...
For a word like "test", consider "#test", "t#test", "st#test", "est#test", "test#test". Then if we have a query like prefix = "te", suffix = "t", we can find it by searching for something we've inserted starting with "t#te".
String,Design,Trie
Hard
211
1,913
so hello guys my name is arsalam welcome back to my channel and today we will be solving a new liquid question that is maximum product difference between two peers so the question says the product difference between two pairs a b and c d is defined as a into B minus C into D for example the product difference between 5...
Maximum Product Difference Between Two Pairs
make-the-xor-of-all-segments-equal-to-zero
The **product difference** between two pairs `(a, b)` and `(c, d)` is defined as `(a * b) - (c * d)`. * For example, the product difference between `(5, 6)` and `(2, 7)` is `(5 * 6) - (2 * 7) = 16`. Given an integer array `nums`, choose four **distinct** indices `w`, `x`, `y`, and `z` such that the **product differ...
Let's note that for the XOR of all segments with size K to be equal to zeros, nums[i] has to be equal to nums[i+k] Basically, we need to make the first K elements have XOR = 0 and then modify them.
Array,Dynamic Programming,Bit Manipulation
Hard
null
171
Yes, hello, I am one of the developer children, Gary Ni. Today's Pro Bowl problem is number 171, the CeCi column number. A string color on the title is given. This is a problem that represents the column that represents the color in the Excel C font. The column number corresponding to this is opened. The goal of this p...
Excel Sheet Column Number
excel-sheet-column-number
Given a string `columnTitle` that represents the column title as appears in an Excel sheet, return _its corresponding column number_. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... **Example 1:** **Input:** columnTitle = "A " **Output:** 1 **Example 2:** **Input:** columnTitle = "AB " **Ou...
null
Math,String
Easy
168,2304
1,594
hey what's up guys today we're doing legal problem number 1594 maximum non-negative product non-negative product non-negative product in a matrix you're given a row times what row x carl's matrix grid initially you're located at the top left corner 0 and each step you can only move right or down in the matrix okay so w...
Maximum Non Negative Product in a Matrix
maximum-non-negative-product-in-a-matrix
You are given a `m x n` matrix `grid`. Initially, you are located at the top-left corner `(0, 0)`, and in each step, you can only **move right or down** in the matrix. Among all possible paths starting from the top-left corner `(0, 0)` and ending in the bottom-right corner `(m - 1, n - 1)`, find the path with the **ma...
null
null
Medium
null
429
hello friends in this video we will solve lead code problem number 429 and array tree level order traversal so first we will understand the problem statement and after that we will approach how to solve this problem and at the end we will see code in javascript and java so the question says that we have given an annihi...
N-ary Tree Level Order Traversal
n-ary-tree-level-order-traversal
Given an n-ary tree, return the _level order_ 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,2,4\],\...
null
null
Medium
null
1,640
hi guys welcome to algorithms made easy today we will be going through the question check array formation through concatenation you are given an array of distinct integers and an area of integer array where the integers and pieces are distinct your goal is to form an array by concatenating the array in pieces in any or...
Check Array Formation Through Concatenation
design-a-file-sharing-system
You are given an array of **distinct** integers `arr` and an array of integer arrays `pieces`, where the integers in `pieces` are **distinct**. Your goal is to form `arr` by concatenating the arrays in `pieces` **in any order**. However, you are **not** allowed to reorder the integers in each array `pieces[i]`. Return...
Try to solve it by keeping for each file chunk, the users who have this chunk. Try to solve it by keeping all the users in the system with their owned chunks, and when you request a chunk, check all users for it.
Hash Table,Design,Heap (Priority Queue),Data Stream
Medium
355
83
Hello friends welcome back to the PM softic Solutions basically in this session we will going to solve lead code problem number 83 remove duplicates from the sorted list so without further delay let's go to the dashboard and try to understand the statement says that given the head of assorted link list delete all dupli...
Remove Duplicates from Sorted List
remove-duplicates-from-sorted-list
Given the `head` of a sorted linked list, _delete all duplicates such that each element appears only once_. Return _the linked list **sorted** as well_. **Example 1:** **Input:** head = \[1,1,2\] **Output:** \[1,2\] **Example 2:** **Input:** head = \[1,1,2,3,3\] **Output:** \[1,2,3\] **Constraints:** * The numb...
null
Linked List
Easy
82,1982
390
hey everyone welcome to my channel so in this video i'm going to try to solve this problem do some live coding work at the same time i'm going to follow the general interview steps so first of all let's try to resolve this problem elimination game you have a list of array of all integers in the range of one to end sort...
Elimination Game
elimination-game
You have a list `arr` of all integers in the range `[1, n]` sorted in a strictly increasing order. Apply the following algorithm on `arr`: * Starting from left to right, remove the first number and every other number afterward until you reach the end of the list. * Repeat the previous step again, but this time fro...
null
Math
Medium
null
1,190
foreign code easily so today we will continue with our stack Series so before moving if you haven't subscribed the channel and you haven't access the playlist access it because we are continuously uh making the videos so in the last video we have seen that how to solve the question for daily temperature using stack so ...
Reverse Substrings Between Each Pair of Parentheses
smallest-common-region
You are given a string `s` that consists of lower case English letters and brackets. Reverse the strings in each pair of matching parentheses, starting from the innermost one. Your result should **not** contain any brackets. **Example 1:** **Input:** s = "(abcd) " **Output:** "dcba " **Example 2:** **Input:** s...
Try to model the problem as a graph problem. The given graph is a tree. The problem is reduced to finding the lowest common ancestor of two nodes in a tree.
Array,Hash Table,String,Tree,Depth-First Search,Breadth-First Search
Medium
235,236
172
That Agri One My name is Adarsh ​​Mishra And That Agri One My name is Adarsh ​​Mishra And That Agri One My name is Adarsh ​​Mishra And you Urination Ko Dress Today we are going to talk about the provisions of factorial trading scheme on List Ko, this is a very sweet problem and it is a very tricky problem, you people w...
Factorial Trailing Zeroes
factorial-trailing-zeroes
Given an integer `n`, return _the number of trailing zeroes in_ `n!`. Note that `n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1`. **Example 1:** **Input:** n = 3 **Output:** 0 **Explanation:** 3! = 6, no trailing zero. **Example 2:** **Input:** n = 5 **Output:** 1 **Explanation:** 5! = 120, one trailing zero. **Exa...
null
Math
Medium
233,809,2222
1,569
hey everybody this is Larry this is me going to do uh the daily problem day 16 of the what month is this June daily challenge hit the like button subscribe and join me on Discord let me know what you think about this Pro and it's a hard one today so sorry that I didn't do it earlier I just got back from a very long tri...
Number of Ways to Reorder Array to Get Same BST
max-dot-product-of-two-subsequences
Given an array `nums` that represents a permutation of integers from `1` to `n`. We are going to construct a binary search tree (BST) by inserting the elements of `nums` in order into an initially empty BST. Find the number of different ways to reorder `nums` so that the constructed BST is identical to that formed from...
Use dynamic programming, define DP[i][j] as the maximum dot product of two subsequences starting in the position i of nums1 and position j of nums2.
Array,Dynamic Programming
Hard
null
1,968
O clock is closed, the student has come up with this problem which is last Sunday's electricity don't see problem and related to it and the title of this problem is Affidavit Therewith element is not equal to average of animals problem let's see what it is so it is in this That the first or second number one of you wil...
Array With Elements Not Equal to Average of Neighbors
maximum-building-height
You are given a **0-indexed** array `nums` of **distinct** integers. You want to rearrange the elements in the array such that every element in the rearranged array is **not** equal to the **average** of its neighbors. More formally, the rearranged array should have the property such that for every `i` in the range `1...
Is it possible to find the max height if given the height range of a particular building? You can find the height range of a restricted building by doing 2 passes from the left and right.
Array,Math
Hard
null
219
So now in this question we will see the contents duplicate, if your problem is easy then let's read it once What is different, whose value is theirs, what is the position of the indices, how small is the difference, it should be equal, okay then. If you see in the first example, one is two, three is one, this one and t...
Contains Duplicate II
contains-duplicate-ii
Given an integer array `nums` and an integer `k`, return `true` _if there are two **distinct indices**_ `i` _and_ `j` _in the array such that_ `nums[i] == nums[j]` _and_ `abs(i - j) <= k`. **Example 1:** **Input:** nums = \[1,2,3,1\], k = 3 **Output:** true **Example 2:** **Input:** nums = \[1,0,1,1\], k = 1 **Outp...
null
Array,Hash Table,Sliding Window
Easy
217,220
190
all right let's talk about reverse phase so in this question you're given an integer and it doesn't matter like uh what integer you're giving you just reverse then in this case uh i have a result and i have n right so i will shift left uh for the result but shoot right for the end and how many times 32 times is a littl...
Reverse Bits
reverse-bits
Reverse bits of a given 32 bits unsigned integer. **Note:** * Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer's internal binary representation is the s...
null
Divide and Conquer,Bit Manipulation
Easy
7,191,2238
1,971
1971 find if paths exist in the graph there is a bidirectional graph with n vertices where each vertex is labeled from 0 to n minus 1 inclusive the question says the edges in the graph are represented as a 2d integer array edges as you see in this example this is the edges that is given to us and we have a it's a bi-di...
Find if Path Exists in Graph
incremental-memory-leak
There is a **bi-directional** graph with `n` vertices, where each vertex is labeled from `0` to `n - 1` (**inclusive**). The edges in the graph are represented as a 2D integer array `edges`, where each `edges[i] = [ui, vi]` denotes a bi-directional edge between vertex `ui` and vertex `vi`. Every vertex pair is connecte...
What is the upper bound for the number of seconds? Simulate the process of allocating memory.
Simulation
Medium
null
258
hey everybody welcome back and today we'll be doing another lead code two five eight add digits this is an easy one given integer now repeatedly add all its stitches until the result has only one digit and return it so this is an easy one because um this the process the algorithms which we can use to solve this problem...
Add Digits
add-digits
Given an integer `num`, repeatedly add all its digits until the result has only one digit, and return it. **Example 1:** **Input:** num = 38 **Output:** 2 **Explanation:** The process is 38 --> 3 + 8 --> 11 11 --> 1 + 1 --> 2 Since 2 has only one digit, return it. **Example 2:** **Input:** num = 0 **Output:** 0 *...
A naive implementation of the above process is trivial. Could you come up with other methods? What are all the possible results? How do they occur, periodically or randomly? You may find this Wikipedia article useful.
Math,Simulation,Number Theory
Easy
202,1082,2076,2264
399
hey everyone welcome back and let's write some more neat code today so today let's solve the problem evaluate Division I don't know if I'm getting Dumber or these Elite code problem descriptions are getting a lot worse well I guess this is one of the earlier problems but I'm just going to skip straight to the example b...
Evaluate Division
evaluate-division
You are given an array of variable pairs `equations` and an array of real numbers `values`, where `equations[i] = [Ai, Bi]` and `values[i]` represent the equation `Ai / Bi = values[i]`. Each `Ai` or `Bi` is a string that represents a single variable. You are also given some `queries`, where `queries[j] = [Cj, Dj]` rep...
Do you recognize this as a graph problem?
Array,Depth-First Search,Breadth-First Search,Union Find,Graph,Shortest Path
Medium
null
1,941
uh hello everyone so today we are going to solve this lead code easy tagged problem check if all characters have equal number of occurrences given a string as return true if s is a good string or false otherwise a string s is good if all the characters that appear in s have the same number of occurrences that is the sa...
Check if All Characters Have Equal Number of Occurrences
minimum-number-of-operations-to-make-string-sorted
Given a string `s`, return `true` _if_ `s` _is a **good** string, or_ `false` _otherwise_. A string `s` is **good** if **all** the characters that appear in `s` have the **same** number of occurrences (i.e., the same frequency). **Example 1:** **Input:** s = "abacbc " **Output:** true **Explanation:** The character...
Note that the operations given describe getting the previous permutation of s To solve this problem you need to solve every suffix separately
Math,String,Combinatorics
Hard
null
1,029
hi everyone this is ravi and again the lead code problem every s people a company is planning to interview the cost of flying eighth person to city a is okay or a two dimensional cost and the cost of flying eighth percent to city b is the same uh okay return the minimum cost to fly every person to uh to a city such tha...
Two City Scheduling
vertical-order-traversal-of-a-binary-tree
A company is planning to interview `2n` people. Given the array `costs` where `costs[i] = [aCosti, bCosti]`, the cost of flying the `ith` person to city `a` is `aCosti`, and the cost of flying the `ith` person to city `b` is `bCosti`. Return _the minimum cost to fly every person to a city_ such that exactly `n` people...
null
Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Hard
null
416
all right this lead code question is called partition equals subset sum it says given a non-empty array containing only given a non-empty array containing only given a non-empty array containing only positive integers find if the array can be partitioned into two subsets such that the sum of elements in both subsets is...
Partition Equal Subset Sum
partition-equal-subset-sum
Given an integer array `nums`, return `true` _if you can partition the array into two subsets such that the sum of the elements in both subsets is equal or_ `false` _otherwise_. **Example 1:** **Input:** nums = \[1,5,11,5\] **Output:** true **Explanation:** The array can be partitioned as \[1, 5, 5\] and \[11\]. **E...
null
Array,Dynamic Programming
Medium
698,2108,2135,2162
382
welcome back friends today we are going to solve lead code problem 382 linked list random node given a singly linked list return a random nodes value from the linked list each node must have the same probability of being chosen implement solution class so in the solution class we have been given a head of the list and ...
Linked List Random Node
linked-list-random-node
Given a singly linked list, return a random node's value from the linked list. Each node must have the **same probability** of being chosen. Implement the `Solution` class: * `Solution(ListNode head)` Initializes the object with the head of the singly-linked list `head`. * `int getRandom()` Chooses a node randoml...
null
Linked List,Math,Reservoir Sampling,Randomized
Medium
398
83
hey hello there so today I'm continuing looking at link to lists or related questions so I got to question today one the first one is 83 remove duplicates for unsorted list we have a sorted a linked list so they're nodes inside this linked list that there are values are in the ascending order we need to delete all the ...
Remove Duplicates from Sorted List
remove-duplicates-from-sorted-list
Given the `head` of a sorted linked list, _delete all duplicates such that each element appears only once_. Return _the linked list **sorted** as well_. **Example 1:** **Input:** head = \[1,1,2\] **Output:** \[1,2\] **Example 2:** **Input:** head = \[1,1,2,3,3\] **Output:** \[1,2,3\] **Constraints:** * The numb...
null
Linked List
Easy
82,1982
837
Hello everyone welcome to my channel, it is a mathematical question, but I felt that it should come in the middle of medium and hard, but if you understand it, then it is okay, it can be done till medium level only, ok, the name of the question is New Game 21. Ok, now we have to read the question asked by Google and le...
New 21 Game
most-common-word
Alice plays the following game, loosely based on the card game **"21 "**. Alice starts with `0` points and draws numbers while she has less than `k` points. During each draw, she gains an integer number of points randomly from the range `[1, maxPts]`, where `maxPts` is an integer. Each draw is independent and the outc...
null
Hash Table,String,Counting
Easy
null
206
hello everyone my name is Horus and in this video we're going to be going through Lee code number 206 reverse link lists so for this problem we're given a head of a singly linked list and we simply want to reverse the list and return the reverse list so as always let's go through an example so for this example we're gi...
Reverse Linked List
reverse-linked-list
Given the `head` of a singly linked list, reverse the list, and return _the reversed list_. **Example 1:** **Input:** head = \[1,2,3,4,5\] **Output:** \[5,4,3,2,1\] **Example 2:** **Input:** head = \[1,2\] **Output:** \[2,1\] **Example 3:** **Input:** head = \[\] **Output:** \[\] **Constraints:** * The number...
null
Linked List,Recursion
Easy
92,156,234,2196,2236
70
great hello everyone um this is logic coding this time we're going to look at another very classical um i think it's elementary dynamic program question called climb stairs it's very similar to fibonacci number we are given n and access to climbing a staircase it takes n steps to reach to the top each time we can eithe...
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
47
hey everybody this is larry this is day 12 of the lead code daily challenge hit the like button it's a subscribe button join me on this card let me know what you think about today's problem permutations too so given the collections of numbers nums that might contain stupid return all possible unique permutation in any ...
Permutations II
permutations-ii
Given a collection of numbers, `nums`, that might contain duplicates, return _all possible unique permutations **in any order**._ **Example 1:** **Input:** nums = \[1,1,2\] **Output:** \[\[1,1,2\], \[1,2,1\], \[2,1,1\]\] **Example 2:** **Input:** nums = \[1,2,3\] **Output:** \[\[1,2,3\],\[1,3,2\],\[2,1,3\],\[2,3,...
null
Array,Backtracking
Medium
31,46,267,1038
452
in this video we're going to take a look at a legal problem called minimal number of arrows to burst balloons so basically the question um given us a 2d array and this 2d array symbolizes the balloon size right so here you can see we have 1 six one six that's the balloon and the other um two eight is another balloon th...
Minimum Number of Arrows to Burst Balloons
minimum-number-of-arrows-to-burst-balloons
There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array `points` where `points[i] = [xstart, xend]` denotes a balloon whose **horizontal diameter** stretches between `xstart` and `xend`. You do not know the exact y-coordinates of the ball...
null
Array,Greedy,Sorting
Medium
253,435
328
hi everyone get a solid question called old even like this uh so given single linked list one group all knows such order then the odd indexes will appear before all the even indexes now let's check the example one okay so example one here we see all nodes is one three five if we put these all nodes uh one side to be li...
Odd Even Linked List
odd-even-linked-list
Given the `head` of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return _the reordered list_. The **first** node is considered **odd**, and the **second** node is **even**, and so on. Note that the relative order inside both the even and odd groups s...
null
Linked List
Medium
725
77
and today we're going to solve another lead code problem that is combinations so in this one we are given two integers n and K and we have to return the possible combinations of K numbers chosen from the range 1 to n so what does that mean so we are given range from 1 to 4 so we have numbers like 1 2 3 4 and we have to...
Combinations
combinations
Given two integers `n` and `k`, return _all possible combinations of_ `k` _numbers chosen from the range_ `[1, n]`. You may return the answer in **any order**. **Example 1:** **Input:** n = 4, k = 2 **Output:** \[\[1,2\],\[1,3\],\[1,4\],\[2,3\],\[2,4\],\[3,4\]\] **Explanation:** There are 4 choose 2 = 6 total combin...
null
Backtracking
Medium
39,46
1,704
let's go over question number 1704 determine if string halves are alike now the question says you are given a string s of even length so it's an even length split this string into two halves of equal length and then a be the first half and b be the second half two strings are alike if they have the same number of vowel...
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
593
hey guys let's talk about problem from google which is known as valid square it's a medium level problem so we are given the coordinates of four points in 2d space p1 p2 p3 and p4 we need to return true if four points construct a square the coordinate of points p i is represented as x i and y i the input is not given i...
Valid Square
valid-square
Given the coordinates of four points in 2D space `p1`, `p2`, `p3` and `p4`, return `true` _if the four points construct a square_. The coordinate of a point `pi` is represented as `[xi, yi]`. The input is **not** given in any order. A **valid square** has four equal sides with positive length and four equal angles (9...
null
Math,Geometry
Medium
null
1,061
hello everyone welcome to algo simplified today we will be solving lead codes 1061 problem lexicographically smallest equivalent string now moving to the problem statement you are given two strings of the same length S1 and S2 and a string base Str we say S1 I and s2i are equivalent characters for example S1 equal to A...
Lexicographically Smallest Equivalent String
number-of-valid-subarrays
You are given two strings of the same length `s1` and `s2` and a string `baseStr`. We say `s1[i]` and `s2[i]` are equivalent characters. * For example, if `s1 = "abc "` and `s2 = "cde "`, then we have `'a' == 'c'`, `'b' == 'd'`, and `'c' == 'e'`. Equivalent characters follow the usual rules of any equivalence rela...
Given a data structure that answers queries of the type to find the minimum in a range of an array (Range minimum query (RMQ) sparse table) in O(1) time. How can you solve this problem? For each starting index do a binary search with an RMQ to find the ending possible position.
Array,Stack,Monotonic Stack
Hard
2233
133
hey guys persistent programmer here and welcome back to my channel so in this channel we solve a lot of algorithms and go over legal questions so if you haven't subscribed already go ahead and hit the subscribe button smash that like button because that helps me create this content for you guys so without further ado l...
Clone Graph
clone-graph
Given a reference of a node in a **[connected](https://en.wikipedia.org/wiki/Connectivity_(graph_theory)#Connected_graph)** undirected graph. Return a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) (clone) of the graph. Each node in the graph contains a value (`int`) and a list (`List[Node]`)...
null
Hash Table,Depth-First Search,Breadth-First Search,Graph
Medium
138,1624,1634
888
Will try 200 and the family has given hundreds in the description but Baghwa subscribe The Channel subscribe and subscribe the Channel subscribe Karna should subscribe 1000 will tell that it will need this much size and tell with tears how much it is The President Clan Minimum Return Even Attempted Guarantee If you und...
Fair Candy Swap
mirror-reflection
Alice and Bob have a different total number of candies. You are given two integer arrays `aliceSizes` and `bobSizes` where `aliceSizes[i]` is the number of candies of the `ith` box of candy that Alice has and `bobSizes[j]` is the number of candies of the `jth` box of candy that Bob has. Since they are friends, they wo...
null
Math,Geometry
Medium
null
845
Hello Illusion Cars Video Subscribe to Channel Properties Subscribe 4000 Videos That Hina Do and Science Questions Page Vote in Food Will Work Like a Middle Egg subscribe comment And subscribe The Amazing Subscribe Former MLA Anil Kumar subscribe and subscribe Maximum Volume Enrollment Question Lite subscribe Video Sub...
Longest Mountain in Array
longest-mountain-in-array
You may recall that an array `arr` is a **mountain array** if and only if: * `arr.length >= 3` * There exists some index `i` (**0-indexed**) with `0 < i < arr.length - 1` such that: * `arr[0] < arr[1] < ... < arr[i - 1] < arr[i]` * `arr[i] > arr[i + 1] > ... > arr[arr.length - 1]` Given an integer arr...
null
null
Medium
null
1,760
hey there everyone welcome back to lead coding so we are in the middle of the contest number 228 and this is the problem number three i'm making this video so that i can upload it as soon as the contest is over so during the contest i have come up with one of the solutions to this problem and i will explain you the int...
Minimum Limit of Balls in a Bag
check-array-formation-through-concatenation
You are given an integer array `nums` where the `ith` bag contains `nums[i]` balls. You are also given an integer `maxOperations`. You can perform the following operation at most `maxOperations` times: * Take any bag of balls and divide it into two new bags with a **positive** number of balls. * For example, ...
Note that the distinct part means that every position in the array belongs to only one piece Note that you can get the piece every position belongs to naively
Array,Hash Table
Easy
null
84
Hello Hi Everyone Welcome to my channel it's all the problem large rectangle in histogram given in the winters representing district where do I am with which would find the area of ​​rectangle example subscribe like no one will start from which country from subscribe after subscribe and Share and subscirbe 21 20130 spi...
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
70
hi guys hope you are doing great a today's question is climbing stairs it's an easy question but it's a dynamic programming question and a very good one to just understand a lot of questions were just submitted to this alright so you are climbing a staircase it takes n steps to reach to the top each time you can either...
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
926
hello everyone welcome to our channel kodu sunny and in this video i will be talking about a simple problem flip strength to monotone increasing its index is nine to six and it is a medium type problem the liquid okay so this problem basically has like a dynamic programming approach you need to store the frequency of p...
Flip String to Monotone Increasing
find-and-replace-pattern
A binary string is monotone increasing if it consists of some number of `0`'s (possibly none), followed by some number of `1`'s (also possibly none). You are given a binary string `s`. You can flip `s[i]` changing it from `0` to `1` or from `1` to `0`. Return _the minimum number of flips to make_ `s` _monotone increa...
null
Array,Hash Table,String
Medium
null
168
so our today's problem is L code 168 Excel sheet column title it is a easy level problem and it consists of topics such as math and string it is asked in only single company Amazon in last few six month here we are given with the integer column number and we have to return a corresponding column title as it appear in o...
Excel Sheet Column Title
excel-sheet-column-title
Given an integer `columnNumber`, return _its corresponding column title as it appears in an Excel sheet_. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... **Example 1:** **Input:** columnNumber = 1 **Output:** "A " **Example 2:** **Input:** columnNumber = 28 **Output:** "AB " **Example 3:**...
null
Math,String
Easy
171,2304
1,266
Hello everyone welcome to my channel quote sir with mike so today we are going to do video number 17 of the playlist of maths 1266 yes easy marked has minimum time visiting all points but it is a very good question it means not to be ignored ok meya net Has asked this question. Let's see what the question says. It says...
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
438
hey guys how you doing this is Jay sir who is not good algorithms I'm recording these videos to prepare my Facebook interview next month in this video I'm going to take a look at four three eight find all anagrams in a strange we're giving a string and non empty string P find all the start indices of P is anagram succe...
Find All Anagrams in a String
find-all-anagrams-in-a-string
Given two strings `s` and `p`, return _an array of all the start indices of_ `p`_'s anagrams in_ `s`. You may return the answer in **any order**. An **Anagram** is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. **Example 1:** *...
null
Hash Table,String,Sliding Window
Medium
242,567
524
Hello Welcome Back Friends Today We Are Going To Solve Liquid Problem 1119 Longest Word In Dictionary Roop Deleting Aa Shyam Yaar Ajeeb Developer Aur Fever On Monday This Preparing For Coding Interview And Job Interviews Channel Please subscribe The Channel Asap Play List For Your Interview Preparation Subscribe So Let...
Longest Word in Dictionary through Deleting
longest-word-in-dictionary-through-deleting
Given a string `s` and a string array `dictionary`, return _the longest string in the dictionary that can be formed by deleting some of the given string characters_. If there is more than one possible result, return the longest word with the smallest lexicographical order. If there is no possible result, return the emp...
null
Array,Two Pointers,String,Sorting
Medium
720
491
join us as we tackle coding challenges on code Crusaders in this video we'll be diving deep into the problem by addressing five crucial elements the problem definition our approach to the code an example to illustrate the code the intuition behind the code and the complexity analysis the problem is non-decreasing the p...
Non-decreasing Subsequences
increasing-subsequences
Given an integer array `nums`, return _all the different possible non-decreasing subsequences of the given array with at least two elements_. You may return the answer in **any order**. **Example 1:** **Input:** nums = \[4,6,7,7\] **Output:** \[\[4,6\],\[4,6,7\],\[4,6,7,7\],\[4,7\],\[4,7,7\],\[6,7\],\[6,7,7\],\[7,7\]...
null
Array,Hash Table,Backtracking,Bit Manipulation
Medium
646
35
greetings youtube today we're doing problem 35 search insert position now this problem was given by amazon in a coding interview and it is based on binary search so let's read the problem and figure out a solution given a sorted array of distinct integers and a target value return the index of the target as fouled if i...
Search Insert Position
search-insert-position
Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with `O(log n)` runtime complexity. **Example 1:** **Input:** nums = \[1,3,5,6\], target = 5 **Output:** 2 **Exa...
null
Array,Binary Search
Easy
278
1,460
okay let code number 14 60 make two arrays equal by reversing sub arrays we have to erase we can reverse any sub array of one of them and the question is can we obtain the second one okay well if they're not of equal lengths we cannot obtain any one of them of course and then there is the second idea so we can perform ...
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
454
hello everyone i'm bihan chakravarti and today i'll be discussing problem number 454 from late code that is for some two so this is february 2022's day three problem and it's a medium level problem as you can see so let's get started so in this problem we have been given four arrays num one two three four and we have t...
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
455
So hello what is up guys so happy new year to all of you first of all ok and today we will try again new questions new year new what ever you can call it so let's start without any delay ok So the first one is today's first January question, it is easy, it has come ok for us, assign cookie ok, so let's see what is tell...
Assign Cookies
assign-cookies
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child `i` has a greed factor `g[i]`, which is the minimum size of a cookie that the child will be content with; and each cookie `j` has a size `s[j]`. If `s[j] >= g[i]`, we can assign ...
null
Array,Greedy,Sorting
Easy
null
148
hey guys welcome back to another video and today we're going to be solving the leak code question sort list all right so as the title says we're going to be given a linked list and all we need to do is we're going to sort it so real quickly given the head of the linked list return the list after sorting it in ascending...
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,431
hey so welcome back and this is another daily code problem so today it was called kids with the greatest number of candies and it's just an easy level problem you can actually do it in a one-liner so all can actually do it in a one-liner so all can actually do it in a one-liner so all that you're given here is a candie...
Kids With the Greatest Number of Candies
all-ancestors-of-a-node-in-a-directed-acyclic-graph
There are `n` kids with candies. You are given an integer array `candies`, where each `candies[i]` represents the number of candies the `ith` kid has, and an integer `extraCandies`, denoting the number of extra candies that you have. Return _a boolean array_ `result` _of length_ `n`_, where_ `result[i]` _is_ `true` _i...
Consider how reversing each edge of the graph can help us. How can performing BFS/DFS on the reversed graph help us find the ancestors of every node?
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Medium
1912
32
hi everyone welcome to this recorder this is raveena and uh today I am going to solve liquid problem number 32. I actually selected this problem based on the poll that I did last week uh and the based on the words uh the you guys want me to solve string problems so I'm gonna do that now I'm I will keep referring back t...
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
341
Today's problem is to multiply the nested list. In this problem, you have been given a nested list. Every element of this list is a sequence or is another list in itself. You have to multiply this nested list and after that you have to implement some API. The first API is your naked outer, in this you will be passed th...
Flatten Nested List Iterator
flatten-nested-list-iterator
You are given a nested list of integers `nestedList`. Each element is either an integer or a list whose elements may also be integers or other lists. Implement an iterator to flatten it. Implement the `NestedIterator` class: * `NestedIterator(List nestedList)` Initializes the iterator with the nested list `nestedLi...
null
Stack,Tree,Depth-First Search,Design,Queue,Iterator
Medium
251,281,385,565
1,012
Hello Everyone I am Jaysh Today in today's video I will be sharing with you how I studied Digit DP. How I asked myself this question, what was my thought process and while solving and practicing DP, what were the patterns which mostly helped me. Which seems important and on which a lot of questions have come, which is ...
Numbers With Repeated Digits
equal-rational-numbers
Given an integer `n`, return _the number of positive integers in the range_ `[1, n]` _that have **at least one** repeated digit_. **Example 1:** **Input:** n = 20 **Output:** 1 **Explanation:** The only positive number (<= 20) with at least 1 repeated digit is 11. **Example 2:** **Input:** n = 100 **Output:** 10 **...
null
Math,String
Hard
null
1,328
so today we're gonna discuss this question from bi-weekly contest 18 question from bi-weekly contest 18 question from bi-weekly contest 18 problem number one three to eight break a palindrome so in this you are given a parent drumming string as an input and you have to replace exactly one character by an lower degree s...
Break a Palindrome
monthly-transactions-ii
Given a palindromic string of lowercase English letters `palindrome`, replace **exactly one** character with any lowercase English letter so that the resulting string is **not** a palindrome and that it is the **lexicographically smallest** one possible. Return _the resulting string. If there is no way to replace a ch...
null
Database
Medium
1317
412
hello everyone welcome to the channel today we are going to solve lead code 412 fbus so we'll be given an integer array n as an input we need to return a string array of size n so they have given as a condition four conditions so for each element that we are going to visit in the range n if the visited number is divisi...
Fizz Buzz
fizz-buzz
Given an integer `n`, return _a string array_ `answer` _(**1-indexed**) where_: * `answer[i] == "FizzBuzz "` if `i` is divisible by `3` and `5`. * `answer[i] == "Fizz "` if `i` is divisible by `3`. * `answer[i] == "Buzz "` if `i` is divisible by `5`. * `answer[i] == i` (as a string) if none of the above condit...
null
Math,String,Simulation
Easy
1316
1,763
welcome back daily lead coders daily leak code lead code daily Elite code day 52 we're back once again uh yeah we're back once again we just got off uh we just finished talks with uh Elon and Joe Byron we're making sure that we're allocating uh I think the about 33 percent of the US's available networking resources and...
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
468
hello everyone.welcome the hacker key in hello everyone.welcome the hacker key in hello everyone.welcome the hacker key in this video we will look into solving the problem validates IP address it is a medium problem but it's very straightforward problem before we start please do like and subscribe to the channel hacker...
Validate IP Address
validate-ip-address
Given a string `queryIP`, return `"IPv4 "` if IP is a valid IPv4 address, `"IPv6 "` if IP is a valid IPv6 address or `"Neither "` if IP is not a correct IP of any type. **A valid IPv4** address is an IP in the form `"x1.x2.x3.x4 "` where `0 <= xi <= 255` and `xi` **cannot contain** leading zeros. For example, `"192.16...
null
String
Medium
752
128
welcome ladies and gentlemen so today we are going to solve google most asked question which is longest consecutive sequence this is a google frequency frequently asked question so without any further ado let's start solving this problem okay so to solve this problem what the question is first of all we are over here w...
Longest Consecutive Sequence
longest-consecutive-sequence
Given an unsorted array of integers `nums`, return _the length of the longest consecutive elements sequence._ You must write an algorithm that runs in `O(n)` time. **Example 1:** **Input:** nums = \[100,4,200,1,3,2\] **Output:** 4 **Explanation:** The longest consecutive elements sequence is `[1, 2, 3, 4]`. Therefor...
null
Array,Hash Table,Union Find
Medium
298,2278
290
hello everyone i hope all of you are having a great time i know it's a monday and everyone's having monday blues but still we have to solve the lead code daily question and the question that we have in today is word search lead code 290. it's an easy level question on lead code and i totally feel the same to our surpri...
Word Pattern
word-pattern
Given a `pattern` and a string `s`, find if `s` follows the same pattern. Here **follow** means a full match, such that there is a bijection between a letter in `pattern` and a **non-empty** word in `s`. **Example 1:** **Input:** pattern = "abba ", s = "dog cat cat dog " **Output:** true **Example 2:** **Input:*...
null
Hash Table,String
Easy
205,291
435
hey so welcome back and there's another daily code problem so today it's called non-overlapping intervals now I actually non-overlapping intervals now I actually non-overlapping intervals now I actually did this one yesterday but I thought we'd do it today and so essentially uh what you're given here is just a two-dime...
Non-overlapping Intervals
non-overlapping-intervals
Given an array of intervals `intervals` where `intervals[i] = [starti, endi]`, return _the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping_. **Example 1:** **Input:** intervals = \[\[1,2\],\[2,3\],\[3,4\],\[1,3\]\] **Output:** 1 **Explanation:** \[1,3\] can be removed ...
null
Array,Dynamic Programming,Greedy,Sorting
Medium
452
155
hey guys Greg here let's solve minack which is leak code problem 155 it is a very interesting problem where I think it's super clever once you know the answer and it feels like you can get to that answer but sometimes you just don't quite get it and here you are so let's check it out so this is one of those questions w...
Min Stack
min-stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the `MinStack` class: * `MinStack()` initializes the stack object. * `void push(int val)` pushes the element `val` onto the stack. * `void pop()` removes the element on the top of the stack. * `int top(...
Consider each node in the stack having a minimum value. (Credits to @aakarshmadhavan)
Stack,Design
Easy
239,716
299
Jhaal Hello Hi Guys Welcome to Code West Today's Question is Gold and Tons in This Will Play a Game with Her Friend to Write the Number and Ask and Guess What the Number Subscribe Video Subscribe Jaitly in Both Its Position and Humid Number Locator Different Positions on a View To Return How Many Times Hit And Hit The ...
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
51
all right guys now we are going to do the next problem with lead code problem 51st and queens the N Queens puzzle is a problem of placing and queens on an any length s Porter says no to Queens attack each other ok when an integer and returns return all the solution to the N Queens prappas it each solution contains a di...
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
392
today's problem is very simple we are given two strings one is a smaller string or it can be larger and another string is the bigger string and we have to check whether s is a subsequence of t or not so subsequence is uh means that you pick some characters from a sentence from a string or maintaining their order for ex...
Is Subsequence
is-subsequence
Given two strings `s` and `t`, return `true` _if_ `s` _is a **subsequence** of_ `t`_, or_ `false` _otherwise_. A **subsequence** of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i...
null
Two Pointers,String,Dynamic Programming
Easy
808,1051
507
Hello everyone, my name is Adarsh ​​Mishra, Hello everyone, my name is Adarsh ​​Mishra, Hello everyone, my name is Adarsh ​​Mishra, you are watching this Dress to the Nation, today we are going to talk about the problem named Get Perfect Number. The problem statement is here divided into three lines, so before reading ...
Perfect Number
perfect-number
A [**perfect number**](https://en.wikipedia.org/wiki/Perfect_number) is a **positive integer** that is equal to the sum of its **positive divisors**, excluding the number itself. A **divisor** of an integer `x` is an integer that can divide `x` evenly. Given an integer `n`, return `true` _if_ `n` _is a perfect number,...
null
Math
Easy
728
133
in this video we're going to take a look at a legal problem called clone graph so given a reference of a node that is connected undirected graph so undirected graph basically means that if node a is connected to node b that means that no b is also connected to no a right and then we want to return a deep copy clone of ...
Clone Graph
clone-graph
Given a reference of a node in a **[connected](https://en.wikipedia.org/wiki/Connectivity_(graph_theory)#Connected_graph)** undirected graph. Return a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) (clone) of the graph. Each node in the graph contains a value (`int`) and a list (`List[Node]`)...
null
Hash Table,Depth-First Search,Breadth-First Search,Graph
Medium
138,1624,1634
1,830
hey everybody this is larry this is me going with q4 of the bi-weekly me going with q4 of the bi-weekly me going with q4 of the bi-weekly contest 50 minimum number of operations to make strings sorted so this is uh to be short you know uh hit the like button to subscribe and join me on discord before i forget and yeah ...
Minimum Number of Operations to Make String Sorted
count-good-meals
You are given a string `s` (**0-indexed**)​​​​​​. You are asked to perform the following operation on `s`​​​​​​ until you get a sorted string: 1. Find **the largest index** `i` such that `1 <= i < s.length` and `s[i] < s[i - 1]`. 2. Find **the largest index** `j` such that `i <= j < s.length` and `s[k] < s[i - 1]` f...
Note that the number of powers of 2 is at most 21 so this turns the problem to a classic find the number of pairs that sum to a certain value but for 21 values You need to use something fasters than the NlogN approach since there is already the log of iterating over the powers so one idea is two pointers
Array,Hash Table
Medium
1,1798,2220
79
hey hello there let's talk about today's recording challenge question word search given a two-dimensional board of given a two-dimensional board of given a two-dimensional board of characters and also a search word we want to determine whether we can construct the word by sequentially connecting adjacent letters on the...
Word Search
word-search
Given an `m x n` grid of characters `board` and a string `word`, return `true` _if_ `word` _exists in the grid_. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once. **Example 1:**...
null
Array,Backtracking,Matrix
Medium
212
208
hello all welcome to netset os today in this video we will know about dry data structure before going for any data structure array binary linked list heap data structure and also stack we have seen pros and cons of each structure in an effort to make it easier to see what type of problems that structure was created to ...
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
202
hey guys persistent programmer here and welcome to my channel so in this channel we solve a lot of problems and today we're going to look at the problem happy number so let's go ahead and get started right away this problem states that write an algorithm to determine if a number n is happy so what does this mean if the...
Happy Number
happy-number
Write an algorithm to determine if a number `n` is happy. A **happy number** is a number defined by the following process: * Starting with any positive integer, replace the number by the sum of the squares of its digits. * Repeat the process until the number equals 1 (where it will stay), or it **loops endlessly ...
null
Hash Table,Math,Two Pointers
Easy
141,258,263,2076
753
hey guys welcome back uh today in this video we gonna solve a problem uh from lead code uh number 753 cracking the safe so this problem is from graph data structure and the solution we use is dfs or dipped first search and also google was the last company that had this problem in interview so let's go and learn more ab...
Cracking the Safe
open-the-lock
There is a safe protected by a password. The password is a sequence of `n` digits where each digit can be in the range `[0, k - 1]`. The safe has a peculiar way of checking the password. When you enter in a sequence, it checks the **most recent** `n` **digits** that were entered each time you type a digit. * For ex...
We can think of this problem as a shortest path problem on a graph: there are `10000` nodes (strings `'0000'` to `'9999'`), and there is an edge between two nodes if they differ in one digit, that digit differs by 1 (wrapping around, so `'0'` and `'9'` differ by 1), and if *both* nodes are not in `deadends`.
Array,Hash Table,String,Breadth-First Search
Medium
null
1,305
Hello Everybody Welcome To My Channel It's All The Record Problem All Elements In Two Remedies At Trees Should Give Into Binary Search Tree And Root To Return Ali Containing All India From Both Recited In Ascending Order Showcases 28500 Subscribe Combination Problems Like To Travel In To- Do List To- Do List To- Do Lis...
All Elements in Two Binary Search Trees
number-of-visible-people-in-a-queue
Given two binary search trees `root1` and `root2`, return _a list containing all the integers from both trees sorted in **ascending** order_. **Example 1:** **Input:** root1 = \[2,1,4\], root2 = \[1,0,3\] **Output:** \[0,1,1,2,3,4\] **Example 2:** **Input:** root1 = \[1,null,8\], root2 = \[8,1\] **Output:** \[1,1,8...
How to solve this problem in quadratic complexity ? For every subarray start at index i, keep finding new maximum values until a value larger than arr[i] is found. Since the limits are high, you need a linear solution. Use a stack to keep the values of the array sorted as you iterate the array from the end to the start...
Array,Stack,Monotonic Stack
Hard
1909,2227
1,981
Hello friends, in today's video we are going to discuss about delete list, question number three of 225, minimum tax, difference between target and suji, is the language problem, what is the problem of labs, what can you do, you have one element out of every two, you have to do CR. And you have to take a committee of a...
Minimize the Difference Between Target and Chosen Elements
maximum-transaction-each-day
You are given an `m x n` integer matrix `mat` and an integer `target`. Choose one integer from **each row** in the matrix such that the **absolute difference** between `target` and the **sum** of the chosen elements is **minimized**. Return _the **minimum absolute difference**_. The **absolute difference** between t...
null
Database
Medium
null
1,706
hey there flow coders welcome back to another episode on COD master sequest in today's episode we are dealing with a captivating physic based puzzle in a 2° captivating physic based puzzle in a 2° captivating physic based puzzle in a 2° so without any further delay let's find out the problem statement and Le code where...
Where Will the Ball Fall
min-cost-to-connect-all-points
You have a 2-D `grid` of size `m x n` representing a box, and you have `n` balls. The box is open on the top and bottom sides. Each cell in the box has a diagonal board spanning two corners of the cell that can redirect a ball to the right or to the left. * A board that redirects the ball to the right spans the top...
Connect each pair of points with a weighted edge, the weight being the manhattan distance between those points. The problem is now the cost of minimum spanning tree in graph with above edges.
Array,Union Find,Minimum Spanning Tree
Medium
2287
141
we're looking at leak code number 141 linked list cycle this is a classic linked list problem very classic pattern definitely one to know definitely shows up all the time highly recommend to be familiar with this pattern also once you know this pattern you can solve many other com questions that come up with linked lis...
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
144
hey everyone welcome back and let's write some more neat code today so today let's solve the problem binary tree pre-order traversal we're given the root pre-order traversal we're given the root pre-order traversal we're given the root of a binary tree and we want to return the pre-order traversal of all of its the pre...
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
146
hello friends I hope you and all your near and dear ones are safe and Hildy these are difficult and unprecedented times and among all the talks discussions and panic around Cove in nineteen I think the best I can do for you right now is to create a peaceful state of mind through distraction via education so over the ne...
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
79
welcome back to algojs today's question is leak code79 word search so given an m by n grid of characters board and a string word return true if word exists in the grid the word can be constructed from letters of sequentially adjacent cells where adjacent cells are horizontally or vertically neighboring the same letter ...
Word Search
word-search
Given an `m x n` grid of characters `board` and a string `word`, return `true` _if_ `word` _exists in the grid_. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once. **Example 1:**...
null
Array,Backtracking,Matrix
Medium
212
784
hey everybody this is larry this is day 16 of the february code daily challenge uh hit the like button hit the subscribe button join me on discord let me know what you think about today's prom ladder case permutation so i usually solve these live or attempt to and i go for my thought process but i'm and i just woke up ...
Letter Case Permutation
insert-into-a-binary-search-tree
Given a string `s`, you can transform every letter individually to be lowercase or uppercase to create another string. Return _a list of all possible strings we could create_. Return the output in **any order**. **Example 1:** **Input:** s = "a1b2 " **Output:** \[ "a1b2 ", "a1B2 ", "A1b2 ", "A1B2 "\] **Example 2:*...
null
Tree,Binary Search Tree,Binary Tree
Medium
783
1,832
so we need to check whether sentence is pan gram or not this is an easy level problem and we will understand step by step how we can solve this question also uh before moving forward if you haven't subscribed to this channel make sure to subscribe to learn about Pro for regular liquid videos like this the question uh f...
Check if the Sentence Is Pangram
minimum-operations-to-make-a-subsequence
A **pangram** is a sentence where every letter of the English alphabet appears at least once. Given a string `sentence` containing only lowercase English letters, return `true` _if_ `sentence` _is a **pangram**, or_ `false` _otherwise._ **Example 1:** **Input:** sentence = "thequickbrownfoxjumpsoverthelazydog " **O...
The problem can be reduced to computing Longest Common Subsequence between both arrays. Since one of the arrays has distinct elements, we can consider that these elements describe an arrangement of numbers, and we can replace each element in the other array with the index it appeared at in the first array. Then the pro...
Array,Hash Table,Binary Search,Greedy
Hard
null
272
hey what is up it is thursday april 14th 2022 and i am here again this morning for a new problem closest binary search tree value 2. uh welcome to coding with chef and thanks for joining and watching and if you like this video remember to like subscribe and um comment on the link below let me know how i'm doing and uh ...
Closest Binary Search Tree Value II
closest-binary-search-tree-value-ii
Given the `root` of a binary search tree, a `target` value, and an integer `k`, return _the_ `k` _values in the BST that are closest to the_ `target`. You may return the answer in **any order**. You are **guaranteed** to have only one unique set of `k` values in the BST that are closest to the `target`. **Example 1:*...
Consider implement these two helper functions: getPredecessor(N), which returns the next smaller node to N. getSuccessor(N), which returns the next larger node to N. Try to assume that each node has a parent pointer, it makes the problem much easier. Without parent pointer we just need to keep track of the path from ...
Two Pointers,Stack,Tree,Depth-First Search,Binary Search Tree,Heap (Priority Queue),Binary Tree
Hard
94,270
1,091
welcome to february's leeco challenge today's problem is shortest path in binary matrix in an n by n square grid each cell is either empty zero or blocked one a clear path from top left to bottom right has length k if and only if it is composed of cells inside of our grid now we can move in eight directions basically w...
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
498
hello guys welcome back to another video today we'll be talking about 498 diagonal traverse so it says given a matrix of M times and elements M rows and columns returned all elements of the matrix in diagonal order as shown in the image and the below image so I actually put this into this white board so it could be bet...
Diagonal Traverse
diagonal-traverse
Given an `m x n` matrix `mat`, return _an array of all the elements of the array in a diagonal order_. **Example 1:** **Input:** mat = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\] **Output:** \[1,2,4,7,5,3,6,8,9\] **Example 2:** **Input:** mat = \[\[1,2\],\[3,4\]\] **Output:** \[1,2,3,4\] **Constraints:** * `m == mat.leng...
null
Array,Matrix,Simulation
Medium
2197
1,905
Hello hi friends welcome back today we are going to solid problem 1905 account sub violence this problem voice of pay Google Facebook Amazon in the last interview sub let's go through this description of the problem you are you remember in binary matrices grade one and two containing only 0s and 1s Suzy Rose Water and ...
Count Sub Islands
design-authentication-manager
You are given two `m x n` binary matrices `grid1` and `grid2` containing only `0`'s (representing water) and `1`'s (representing land). An **island** is a group of `1`'s connected **4-directionally** (horizontal or vertical). Any cells outside of the grid are considered water cells. An island in `grid2` is considered ...
Using a map, track the expiry times of the tokens. When generating a new token, add it to the map with its expiry time. When renewing a token, check if it's on the map and has not expired yet. If so, update its expiry time. To count unexpired tokens, iterate on the map and check for each token if it's not expired yet.
Hash Table,Design
Medium
null
1,447
in this video we will look at lead code problem number one four seven and it's called simplified fractions and you can see a glimpse of the problem here if we are given a number four then what we have to do we have to find all the fractions between 0 and 1 but not including 0 and 1. so you can see that i write 1 by 2 1...
Simplified Fractions
jump-game-iv
Given an integer `n`, return _a list of all **simplified** fractions between_ `0` _and_ `1` _(exclusive) such that the denominator is less-than-or-equal-to_ `n`. You can return the answer in **any order**. **Example 1:** **Input:** n = 2 **Output:** \[ "1/2 "\] **Explanation:** "1/2 " is the only unique fraction wit...
Build a graph of n nodes where nodes are the indices of the array and edges for node i are nodes i+1, i-1, j where arr[i] == arr[j]. Start bfs from node 0 and keep distance. The answer is the distance when you reach node n-1.
Array,Hash Table,Breadth-First Search
Hard
2001
70
welcome to another one of my lead code videos in this one we will be doing lead code number 70 which is climbing stairs so the problem is you're climbing a staircase it takes there's a total of n steps to reach all the way to the top of the staircase and then there's two ways you can climb if you're at a given spot you...
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