id
int64
1
2k
content
stringlengths
272
88.9k
title
stringlengths
3
77
title_slug
stringlengths
3
79
question_content
stringlengths
230
5k
question_hints
stringclasses
695 values
tag
stringclasses
618 values
level
stringclasses
3 values
similar_question_ids
stringclasses
822 values
1,904
So this is welcome back acid problem present in it is defense weekly contest and superhit so let's discuss the problem statement on problem statement it's like doing and every 15 minutes guests and devotion of games 02140 and it's N X 202 people like this a Small And See The Cockroach Gautam Gambhir Virat Liquid Water ...
The Number of Full Rounds You Have Played
second-largest-digit-in-a-string
You are participating in an online chess tournament. There is a chess round that starts every `15` minutes. The first round of the day starts at `00:00`, and after every `15` minutes, a new round starts. * For example, the second round starts at `00:15`, the fourth round starts at `00:45`, and the seventh round star...
First of all, get the distinct characters since we are only interested in those Let's note that there might not be any digits.
Hash Table,String
Easy
null
35
hello everyone today we are working on lead code problem 35 which is search insert position it says 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 of n runt...
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
103
welcome back everyone we're gonna be solving Lee code 103 binary tree zigzag level order traversal so essentially what this problem wants us to do is just run a breadth first search on a tree and uh keep track of the current levels right so this tree has three levels starting at level one we go from left to right we Tr...
Binary Tree Zigzag Level Order Traversal
binary-tree-zigzag-level-order-traversal
Given the `root` of a binary tree, return _the zigzag level order traversal of its nodes' values_. (i.e., from left to right, then right to left for the next level and alternate between). **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[\[3\],\[20,9\],\[15,7\]\] **Example 2:** **Input:** roo...
null
Tree,Breadth-First Search,Binary Tree
Medium
102
1,239
hey what's up guys this is shown here and this time let's talk about another a lead code problem here 1239 maximum length of concatenated string with unique characters alright so you're given an array a list of strings and you need to pick up any of from any of those element in array and concatenate any of them to be a...
Maximum Length of a Concatenated String with Unique Characters
largest-1-bordered-square
You are given an array of strings `arr`. A string `s` is formed by the **concatenation** of a **subsequence** of `arr` that has **unique characters**. Return _the **maximum** possible length_ of `s`. A **subsequence** is an array that can be derived from another array by deleting some or no elements without changing ...
For each square, know how many ones are up, left, down, and right of this square. You can find it in O(N^2) using dynamic programming. Now for each square ( O(N^3) ), we can evaluate whether that square is 1-bordered in O(1).
Array,Dynamic Programming,Matrix
Medium
null
494
Hello guys welcome back door sign in this video you will see that some problem which is established at number 419 floor and a variation more than 90 the subscribe latest see problem list of winners from 2nd do you know you have two symbols plus and minus point To Choose From Plus and Minus You Know Where to Find Out Ho...
Target Sum
target-sum
You are given an integer array `nums` and an integer `target`. You want to build an **expression** out of nums by adding one of the symbols `'+'` and `'-'` before each integer in nums and then concatenate all the integers. * For example, if `nums = [2, 1]`, you can add a `'+'` before `2` and a `'-'` before `1` and ...
null
Array,Dynamic Programming,Backtracking
Medium
282
721
hey guys are doing this is Jay sir who's not good at algorithms in this video I'm going to take a look at seven to one account merge while there is a lot of description here we're given a list accounts each element is a list of strengths where the first one is a name and the rest are emails representing emails of that ...
Accounts Merge
accounts-merge
Given a list of `accounts` where each element `accounts[i]` is a list of strings, where the first element `accounts[i][0]` is a name, and the rest of the elements are **emails** representing emails of the account. Now, we would like to merge these accounts. Two accounts definitely belong to the same person if there is...
For every pair of emails in the same account, draw an edge between those emails. The problem is about enumerating the connected components of this graph.
Array,String,Depth-First Search,Breadth-First Search,Union Find
Medium
684,734,737
382
Hello Everyone Welcome To The Second All You Need Instructions Question No Link Electronic Node In This Question Giving Free Little Interest Earned Enough To Do Mode Wali From List Services Nude Cycle Probability Of Insurance Very Simple Question Very Simple Description And Till Us The Question Is Best Dam The problem ...
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
519
That Akshay Snacks Question Raw Random Clip Matrix Morning Tweet On Twitter Also Provide Number Of Romance And Problem Form 2018 Matric And Porn All Dresses For Example Benefit 12323 That Half Test Match Ajay New Delhi Corrupt Call Just Function Suit Function Dip Equal Randomly E Am what will give water de venta league...
Random Flip Matrix
widest-pair-of-indices-with-equal-range-sum
There is an `m x n` binary grid `matrix` with all the values set `0` initially. Design an algorithm to randomly pick an index `(i, j)` where `matrix[i][j] == 0` and flips it to `1`. All the indices `(i, j)` where `matrix[i][j] == 0` should be equally likely to be returned. Optimize your algorithm to minimize the numbe...
Keep prefix sums of both arrays. Can the difference between the prefix sums at an index help us? What happens if the difference between the two prefix sums at an index a is x, and x again at a different index b? This means that the sum of nums1 from index a + 1 to index b is equal to the sum of nums2 from index a + 1 t...
Array,Hash Table,Prefix Sum
Medium
null
215
hey guys how's their horror you're doing this is chaser who is not good at algorithms today I'm going to take a look at number two one five case largest element in an array we need to find the kate largest element in an unsorted array mmm answer it know that it is the kate largest element in the sorted order not that k...
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
104
hey there welcome back to lead coding today we are solving maximum depth of a binary tree given the binary tree find its maximum depth the maximum depth is the number of nodes along the longest path from root node down to the furthest leaf node a leaf node is a node with no children first of all we should try understan...
Maximum Depth of Binary Tree
maximum-depth-of-binary-tree
Given the `root` of a binary tree, return _its maximum depth_. A binary tree's **maximum depth** is the number of nodes along the longest path from the root node down to the farthest leaf node. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** 3 **Example 2:** **Input:** root = \[1,null,2\] **...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
110,111,774,1492
970
hi guys this is khushboo and welcome to algorithms made easy in this video we will see the question powerful integers given three integers x y and bounds return a list of all the powerful integers that have a value less than or equal to bound an integer is powerful if it can be represented as x raised to i plus y raise...
Powerful Integers
powerful-integers
Given three integers `x`, `y`, and `bound`, return _a list of all the **powerful integers** that have a value less than or equal to_ `bound`. An integer is **powerful** if it can be represented as `xi + yj` for some integers `i >= 0` and `j >= 0`. You may return the answer in **any order**. In your answer, each value...
null
null
Medium
null
307
her friends today less sovereignty sound query mutable given integer array numbers find the sum of their elements between indexes I and J inclusive the update function modifies numbers by updating the element and index I to value this question is very similar we use the to solve some question related that you get the s...
Range Sum Query - Mutable
range-sum-query-mutable
Given an integer array `nums`, handle multiple queries of the following types: 1. **Update** the value of an element in `nums`. 2. Calculate the **sum** of the elements of `nums` between indices `left` and `right` **inclusive** where `left <= right`. Implement the `NumArray` class: * `NumArray(int[] nums)` Initi...
null
Array,Design,Binary Indexed Tree,Segment Tree
Medium
303,308
13
in this video we'll be going over the solution to lead code question number 13 Roman to integer in this question we are given a Roman numeral as a string and must return the corresponding integer for those of you who aren't familiar with Roman numerals I'll do a quick recap so Roman numerals consist of seven different ...
Roman to Integer
roman-to-integer
Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`. **Symbol** **Value** I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, `2` is written as `II` in Roman numeral, just two ones added...
Problem is simpler to solve by working the string from back to front and using a map.
Hash Table,Math,String
Easy
12
1,008
let's talk about the construct binary surgery from pre-order traversal surgery from pre-order traversal surgery from pre-order traversal so you're given a regulator pre-order so you're given a regulator pre-order so you're given a regulator pre-order so which represent the order of period traversal and you want to cont...
Construct Binary Search Tree from Preorder Traversal
binary-tree-cameras
Given an array of integers preorder, which represents the **preorder traversal** of a BST (i.e., **binary search tree**), construct the tree and return _its root_. It is **guaranteed** that there is always possible to find a binary search tree with the given requirements for the given test cases. A **binary search tr...
null
Dynamic Programming,Tree,Depth-First Search,Binary Tree
Hard
1021
940
hi everyone so today we'll be solving another lead code hard problem testing subsequences too so i already have a video on distinct subsequences so you can find the link to that video on the top right of the video and uh yeah let's get started so there is a string s and uh we need to return the number of distinct non-e...
Distinct Subsequences II
fruit-into-baskets
Given a string s, return _the number of **distinct non-empty subsequences** of_ `s`. Since the answer may be very large, return it **modulo** `109 + 7`. 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...
null
Array,Hash Table,Sliding Window
Medium
null
792
That even today Iodine Solid is called Dairy Challenge Problem 7921. First of all let's understand the problem. In the problem it is basically being said that we have got two inputs, one stringer, send one deep what and we have to commit suicide to account and see all such awards which are subscribed. Have you been sub...
Number of Matching Subsequences
binary-search
Given a string `s` and an array of strings `words`, return _the number of_ `words[i]` _that is a subsequence of_ `s`. A **subsequence** of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters. * For exa...
null
Array,Binary Search
Easy
786
1,337
welcome to february's legal challenge today's problem is the k weakest rows in a matrix given an m times n matrix of ones and zeros representing soldiers and civilians we turn the indexes of the k weakest rows in the matrix ordered from weakest to the strongest now row is weaker if the number of soldiers in row is less...
The K Weakest Rows in a Matrix
design-skiplist
You are given an `m x n` binary matrix `mat` of `1`'s (representing soldiers) and `0`'s (representing civilians). The soldiers are positioned **in front** of the civilians. That is, all the `1`'s will appear to the **left** of all the `0`'s in each row. A row `i` is **weaker** than a row `j` if one of the following is...
null
Linked List,Design
Hard
816,817,838
24
hello everyone welcome or welcome back to my channel so today we are going to discuss another problem but before going forward if you not like 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 so probl...
Swap Nodes in Pairs
swap-nodes-in-pairs
Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.) **Example 1:** **Input:** head = \[1,2,3,4\] **Output:** \[2,1,4,3\] **Example 2:** **Input:** head = \[\] **Output:** \[\...
null
Linked List,Recursion
Medium
25,528
442
hey what's up guys think white here I do Tecna coding stuff on twitch and YouTube check the description for all my information I do the Premium Lee code problem solutions on my patreon and if you want to reach out to me you can hit me up on discord I try to get back to everyone this problem is called find all duplicate...
Find All Duplicates in an Array
find-all-duplicates-in-an-array
Given an integer array `nums` of length `n` where all the integers of `nums` are in the range `[1, n]` and each integer appears **once** or **twice**, return _an array of all the integers that appears **twice**_. You must write an algorithm that runs in `O(n)` time and uses only constant extra space. **Example 1:** ...
null
Array,Hash Table
Medium
448
1,224
hi today we'll be solving this question maximum equal frequency so this question is basically a problem in which we are given with a array nums and we need to figure out the length of the longest possible prefix such that if you remove exactly one element from the prefix we will be getting a resultant array that has el...
Maximum Equal Frequency
minimum-falling-path-sum-ii
Given an array `nums` of positive integers, return the longest possible length of an array prefix of `nums`, such that it is possible to remove **exactly one** element from this prefix so that every number that has appeared in it will have the same number of occurrences. If after removing one element there are no rema...
Use dynamic programming. Let dp[i][j] be the answer for the first i rows such that column j is chosen from row i. Use the concept of cumulative array to optimize the complexity of the solution.
Array,Dynamic Programming,Matrix
Hard
967
77
today I'm gonna solve the core problem 77 combinations a question is given two integers and gay we need to with all possible combinations of K numbers out of one to n combination is basically a number of ways of picking K elements from engine elements and we don't care about the order in which we pick the numbers let's...
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
250
today we're looking at leap code number 250. it's a question called count unit value subtrees and so here we're given a root of a binary tree and we want to return the number of unit value subtrees the unit value subtree means all nodes of the subtree have the same value all right so here we have a tree and we can see ...
Count Univalue Subtrees
count-univalue-subtrees
Given the `root` of a binary tree, return _the number of **uni-value**_ _subtrees_. A **uni-value subtree** means all nodes of the subtree have the same value. **Example 1:** **Input:** root = \[5,1,5,5,5,null,5\] **Output:** 4 **Example 2:** **Input:** root = \[\] **Output:** 0 **Example 3:** **Input:** root = ...
null
Tree,Depth-First Search,Binary Tree
Medium
572,687
1,857
hey so welcome back and this is another daily code problem so this one was called largest color value in a directed graph so let's take a look at it so it's a hard problem and you're given a directed graph here with different colors and different numbers now the numbers aren't really important they just indicate the ki...
Largest Color Value in a Directed Graph
largest-color-value-in-a-directed-graph
There is a **directed graph** of `n` colored nodes and `m` edges. The nodes are numbered from `0` to `n - 1`. You are given a string `colors` where `colors[i]` is a lowercase English letter representing the **color** of the `ith` node in this graph (**0-indexed**). You are also given a 2D array `edges` where `edges[j]...
null
null
Hard
null
852
hey what's up guys Nick white I do tech and coding stuff on twitch and YouTube so if you want to check anything out it's all in the description I do all the Waco problems I got a super long playlist of explanations so if you want to check that it's a playlist on my channel I got them and they're like 50 now this one's ...
Peak Index in a Mountain Array
friends-of-appropriate-ages
An array `arr` a **mountain** if the following properties hold: * `arr.length >= 3` * There exists some `i` 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 a mountain array `arr`, return the index `i` su...
null
Array,Two Pointers,Binary Search,Sorting
Medium
null
1,642
it has been asked by Amazon Google Microsoft Bloomberg Apple miret hi guys good morning welcome back to a new video in this we going to see a problem Fest building you can reach again this is not like other videos which means not like other channels in which you will just discuss only the most optimal approach n we wil...
Furthest Building You Can Reach
water-bottles
You are given an integer array `heights` representing the heights of buildings, some `bricks`, and some `ladders`. You start your journey from building `0` and move to the next building by possibly using bricks or ladders. While moving from building `i` to building `i+1` (**0-indexed**), * If the current building'...
Simulate the process until there are not enough empty bottles for even one full bottle of water.
Math,Simulation
Easy
null
387
hey guys welcome to another episode of the algorithm that go straighter in this particular exam episode we're gonna go over a very simple problem it's pretty easy leak code 3d7 which is to find the first unique character that occurs in a given stream okay so given a particular string you want to find the first non repe...
First Unique Character in a String
first-unique-character-in-a-string
Given a string `s`, _find the first non-repeating character in it and return its index_. If it does not exist, return `-1`. **Example 1:** **Input:** s = "leetcode" **Output:** 0 **Example 2:** **Input:** s = "loveleetcode" **Output:** 2 **Example 3:** **Input:** s = "aabb" **Output:** -1 **Constraints:** * `...
null
Hash Table,String,Queue,Counting
Easy
451
189
Hello everyone, I welcome you guys to Azamgarh, you will see a very good question, next day you will see a better collection every time and in the eyes of many people, I am good, this question is basically rotation of a girl, okay, this topic is enough. It is easy to hear, easy to think, very easy to do, but then I am ...
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
206
now let's take a look at a legal problem called reverse linked list so given the endnote of the singly linked list the goal is we want to reverse the entire sinclair link list and return the root note or the head node of the linked list so here you see we have a linked list right singly linked list and we have one two ...
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
270
welcome to interview Pro in this video let's try to solve another lead code problem to find the closest binary search stream value this question was also asked in a number of interviews you can see the companies listed here so coming to the problem statement a binary search stream will be given to us and a Target value...
Closest Binary Search Tree Value
closest-binary-search-tree-value
Given the `root` of a binary search tree and a `target` value, return _the value in the BST that is closest to the_ `target`. If there are multiple answers, print the smallest. **Example 1:** **Input:** root = \[4,2,5,1,3\], target = 3.714286 **Output:** 4 **Example 2:** **Input:** root = \[1\], target = 4.428571 *...
null
Binary Search,Tree,Depth-First Search,Binary Search Tree,Binary Tree
Easy
222,272,783
219
all right this lead code question is called contains duplicate two it says given an array of integers and an integer K find out whether there are two distinct indices I and J in the array such that nums I equals nums J and the absolute difference between I and J is at most K all right the silence is confusing but all i...
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
72
That in this video will see how to find a distance between two strings and what is meant by addition to streams after first and 2nd tasks to convert s12 pleasant acid subscribe servi liquid subscribe tomorrow morning camera replace which is 1000 words vikram r So RSS Chief Then Operation Next Id Yaar Do It Norms And Oy...
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,566
hey guys today we're going to solve lead code 1566 detect pattern of length m repeated k times so this problem was the easy problem of today's contest and we're given an array of integers and we need to find a pattern of length m repeated k times so the way we're going to do this is with a for loop we're going to write...
Detect Pattern of Length M Repeated K or More Times
check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence
Given an array of positive integers `arr`, find a pattern of length `m` that is repeated `k` or more times. A **pattern** is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times **consecutively** without overlapping. A pattern is defined by its length and the number of rep...
First extract the words of the sentence. Check for each word if searchWord occurs at index 0, if so return the index of this word (1-indexed) If searchWord doesn't exist as a prefix of any word return the default value (-1).
String,String Matching
Easy
2292
31
Hello Hi Everyone Subscribe Ya Chutney Ya Going To Discuss The Problem Next Permission From SD Sheet All Problems Previous Festival Teacher's Day In The Next Time You Understand What Is This What You Want To Write All Possible Dictionary Of This 732 All Possible Dictionary Can One Two Three Little Come Price Of All Ele...
Next Permutation
next-permutation
A **permutation** of an array of integers is an arrangement of its members into a sequence or linear order. * For example, for `arr = [1,2,3]`, the following are all the permutations of `arr`: `[1,2,3], [1,3,2], [2, 1, 3], [2, 3, 1], [3,1,2], [3,2,1]`. The **next permutation** of an array of integers is the next le...
null
Array,Two Pointers
Medium
46,47,60,267,1978
1,948
hey everybody this is larry this is me from q4 the weekly contest 251 delete duplicate photos and system so this one was a very hard problem as you can see not that many people got it relatively um it took me about was it 40 minutes plus a penalty to do it um but i think i to be honest the idea is pretty str like you p...
Delete Duplicate Folders in System
rearrange-products-table
Due to a bug, there are many duplicate folders in a file system. You are given a 2D array `paths`, where `paths[i]` is an array representing an absolute path to the `ith` folder in the file system. * For example, `[ "one ", "two ", "three "]` represents the path `"/one/two/three "`. Two folders (not necessarily on ...
null
Database
Easy
1926
921
hey everybody this is Larry this is March 11th here in New York City uh I'm going to do an R prom uh even though I really spend an hour in the other one but I have to redeem myself you know and this one isn't even uh a premium prom so hope you know do it with me today's extra prom is 921 minimum add to make par RIT aar...
Minimum Add to Make Parentheses Valid
spiral-matrix-iii
A parentheses string is valid if and only if: * It is the empty string, * It can be written as `AB` (`A` concatenated with `B`), where `A` and `B` are valid strings, or * It can be written as `(A)`, where `A` is a valid string. You are given a parentheses string `s`. In one move, you can insert a parenthesis at...
null
Array,Matrix,Simulation
Medium
54,59
304
hello everyone so in this video let us talk about another problem from lead code the problem name is range sum query 2D in an immutable grid so let us talk about the problem statement first it states that you given a 2d Matrix named at Matrix which is used to handle multiple queries or different types now what is the d...
Range Sum Query 2D - Immutable
range-sum-query-2d-immutable
Given a 2D matrix `matrix`, handle multiple queries of the following type: * Calculate the **sum** of the elements of `matrix` inside the rectangle defined by its **upper left corner** `(row1, col1)` and **lower right corner** `(row2, col2)`. Implement the `NumMatrix` class: * `NumMatrix(int[][] matrix)` Initial...
null
Array,Design,Matrix,Prefix Sum
Medium
303,308
207
everyone welcome back and let's write some more neat code today so today let's look at a graph problem actually it's called course schedule we're given a total number of courses and these are our nodes and they're labeled from zero to n minus 1 basically so some courses have prerequisites for example if you want to tak...
Course Schedule
course-schedule
There are a total of `numCourses` courses you have to take, labeled from `0` to `numCourses - 1`. You are given an array `prerequisites` where `prerequisites[i] = [ai, bi]` indicates that you **must** take course `bi` first if you want to take course `ai`. * For example, the pair `[0, 1]`, indicates that to take cou...
This problem is equivalent to finding if a cycle exists in a directed graph. If a cycle exists, no topological ordering exists and therefore it will be impossible to take all courses. Topological Sort via DFS - A great video tutorial (21 minutes) on Coursera explaining the basic concepts of Topological Sort. Topologica...
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Medium
210,261,310,630
724
hi everyone it's Orin today we have a problem when we are given an array and we need to find the pivot index what's the peot index is the index the elements from the right left of it and the elements from the right of it are the are equal so for example in this case the pivot index is the index of 01 2 3 right so this ...
Find Pivot Index
find-pivot-index
Given an array of integers `nums`, calculate the **pivot index** of this array. The **pivot index** is the index where the sum of all the numbers **strictly** to the left of the index is equal to the sum of all the numbers **strictly** to the index's right. If the index is on the left edge of the array, then the left...
We can precompute prefix sums P[i] = nums[0] + nums[1] + ... + nums[i-1]. Then for each index, the left sum is P[i], and the right sum is P[P.length - 1] - P[i] - nums[i].
Array,Prefix Sum
Easy
560,2102,2369
637
hello everyone uh welcome to this question average of levels in minority we're going to solve this uh question uh using the q method and let us now look into the question what it is about so we have this question non empty binary tree which means the binary tree is not empty it will be having something at least like on...
Average of Levels in Binary Tree
average-of-levels-in-binary-tree
Given the `root` of a binary tree, return _the average value of the nodes on each level in the form of an array_. Answers within `10-5` of the actual answer will be accepted. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[3.00000,14.50000,11.00000\] Explanation: The average value of nodes on...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
102,107
39
hello boys and girls and welcome to another episode of your favorite algorithms channel my name is Ryan powers and today I'm gonna be taking you through elite code 39 combination Sun so let's introduce the problem given a set of candidate numbers candidates without duplicates and a target number target find all unique ...
Combination Sum
combination-sum
Given an array of **distinct** integers `candidates` and a target integer `target`, return _a list of all **unique combinations** of_ `candidates` _where the chosen numbers sum to_ `target`_._ You may return the combinations in **any order**. The **same** number may be chosen from `candidates` an **unlimited number of...
null
Array,Backtracking
Medium
17,40,77,216,254,377
963
hello friends today is the one-year hello friends today is the one-year hello friends today is the one-year anniversary for my youtube channel I post either the first video one year ago okay today let's solve a geometry problem this is a code minimum area rectangle - given set of points in the rectangle - given set of ...
Minimum Area Rectangle II
three-equal-parts
You are given an array of points in the **X-Y** plane `points` where `points[i] = [xi, yi]`. Return _the minimum area of any rectangle formed from these points, with sides **not necessarily parallel** to the X and Y axes_. If there is not any such rectangle, return `0`. Answers within `10-5` of the actual answer will...
null
Array,Math
Hard
null
1,441
Hello viewers welcome back to my channel Homeshop18 Grade Third subscribe To My Channel Please like Share And subscribe The Amazing Place for Various Categories of Problems which is Beneficial for Programming Binary Search Tree Subscribe Please subscribe this dish if the problem is reported from obscurity mode Bill Ene...
Build an Array With Stack Operations
minimum-flips-to-make-a-or-b-equal-to-c
You are given an integer array `target` and an integer `n`. You have an empty stack with the two following operations: * **`"Push "`**: pushes an integer to the top of the stack. * **`"Pop "`**: removes the integer on the top of the stack. You also have a stream of the integers in the range `[1, n]`. Use the tw...
Check the bits one by one whether they need to be flipped.
Bit Manipulation
Medium
2323
910
Done Fire Hot Sunidhi Today Will Solve Question Small Streams Part Two Possible Difference Between The Maximum Volume Minimum And Maximum Minimum Nine Two Second Please Mark 30 Please And Distance Between The Best Bollywood Subscribe Now To All So Much Mehndi Considered In The Maximum Volume Also Id K And Plus B Plus A...
Smallest Range II
nth-magical-number
You are given an integer array `nums` and an integer `k`. For each index `i` where `0 <= i < nums.length`, change `nums[i]` to be either `nums[i] + k` or `nums[i] - k`. The **score** of `nums` is the difference between the maximum and minimum elements in `nums`. Return _the minimum **score** of_ `nums` _after changi...
null
Math,Binary Search
Hard
null
851
Hello Everyone Welcome Back To Back Appointed Her Another Very Interesting Problem And Liquid Witch Lord And Witch Language Problem Given In Number Of People Number 202 - 999 Give The Information About The Number 202 - 999 Give The Information About The Number 202 - 999 Give The Information About The First World Immigr...
Loud and Rich
goat-latin
There is a group of `n` people labeled from `0` to `n - 1` where each person has a different amount of money and a different level of quietness. You are given an array `richer` where `richer[i] = [ai, bi]` indicates that `ai` has more money than `bi` and an integer array `quiet` where `quiet[i]` is the quietness of th...
null
String
Easy
null
824
hey what's up guys an egg white here I detect encoding stuff on twitch in YouTube you can check the description for all of my information I do patreon premium problems on patreon and I have a discord if you want to check it out so this problem is called goat latin some dislikes here since s is given composed of words s...
Goat Latin
number-of-lines-to-write-string
You are given a string `sentence` that consist of words separated by spaces. Each word consists of lowercase and uppercase letters only. We would like to convert the sentence to "Goat Latin " (a made-up language similar to Pig Latin.) The rules of Goat Latin are as follows: * If a word begins with a vowel (`'a'`, `...
null
Array,String
Easy
null
451
hey guys welcome back to Hustler's algorithm today we are going to be solving this today's lead code challenge which is sort characters by frequency so here we are given a string and we have to sort the string based on the frequency of characters in The decreasing order so let's see with an example so we are given a st...
Sort Characters By Frequency
sort-characters-by-frequency
Given a string `s`, sort it in **decreasing order** based on the **frequency** of the characters. The **frequency** of a character is the number of times it appears in the string. Return _the sorted string_. If there are multiple answers, return _any of them_. **Example 1:** **Input:** s = "tree " **Output:** "eer...
null
Hash Table,String,Sorting,Heap (Priority Queue),Bucket Sort,Counting
Medium
347,387,1741
133
um hello so today continuing on lead code daily problems to continue our streak of day 8 in April um so clone graph what this problem says is we get a reference to a node in a connected undirected graph so what we mean by indirected here is that let's say we have node one right and then we have node two so we have an e...
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
239
Hello Hello Hello Hello Everyone Welcome Back To My Channel Suggestion Or Two International Problem Is Sliding Window Maximum 100 Is Very Important Problem And This Concept Using Various Rate Problems Growth Of OLX Problems Inter Problem Advertisement Darkness And Jab K Find Maximum For Each And Every Contigo savere of...
Sliding Window Maximum
sliding-window-maximum
You are given an array of integers `nums`, there is a sliding window of size `k` which is moving from the very left of the array to the very right. You can only see the `k` numbers in the window. Each time the sliding window moves right by one position. Return _the max sliding window_. **Example 1:** **Input:** nums...
How about using a data structure such as deque (double-ended queue)? The queue size need not be the same as the window’s size. Remove redundant elements and the queue should store only elements that need to be considered.
Array,Queue,Sliding Window,Heap (Priority Queue),Monotonic Queue
Hard
76,155,159,265,1814
1,566
uh hey everybody this is larry this is weekly contest 204. i'm going to go over q1 to finish 38 this one uh detect pattern of length m repeated k or more times uh so this one um there really isn't tricky things any tricky about it because the big thing to notice as there's a lot a little bit of breathing but it's notic...
Detect Pattern of Length M Repeated K or More Times
check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence
Given an array of positive integers `arr`, find a pattern of length `m` that is repeated `k` or more times. A **pattern** is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times **consecutively** without overlapping. A pattern is defined by its length and the number of rep...
First extract the words of the sentence. Check for each word if searchWord occurs at index 0, if so return the index of this word (1-indexed) If searchWord doesn't exist as a prefix of any word return the default value (-1).
String,String Matching
Easy
2292
105
hi guys hope you're doing trade our today's question is construct binary tree from pre-order and inorder tree from pre-order and inorder tree from pre-order and inorder traversal given pre-order and inorder traversal given pre-order and inorder traversal given pre-order and inorder traversal of a tree construct the bin...
Construct Binary Tree from Preorder and Inorder Traversal
construct-binary-tree-from-preorder-and-inorder-traversal
Given two integer arrays `preorder` and `inorder` where `preorder` is the preorder traversal of a binary tree and `inorder` is the inorder traversal of the same tree, construct and return _the binary tree_. **Example 1:** **Input:** preorder = \[3,9,20,15,7\], inorder = \[9,3,15,20,7\] **Output:** \[3,9,20,null,null,...
null
Array,Hash Table,Divide and Conquer,Tree,Binary Tree
Medium
106
138
hey guys Greg here and let's solve copy list with random pointer Le code 138 now there's a lot to read here so we're not going to read all of it but a linked list of length n is given such that each node contains an additional random pointer and that could point to any node in the list or it could point to null so we w...
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
419
cool for nineteen battleships on a board or in the board given into the board count how many battleships are in it the battleships are represented by with X's empty startup website of periods you may assume the fine was here we survived were made of the battleships or empty slots our ships can only be placed horizontal...
Battleships in a Board
battleships-in-a-board
Given an `m x n` matrix `board` where each cell is a battleship `'X'` or empty `'.'`, return _the number of the **battleships** on_ `board`. **Battleships** can only be placed horizontally or vertically on `board`. In other words, they can only be made of the shape `1 x k` (`1` row, `k` columns) or `k x 1` (`k` rows, ...
null
Array,Depth-First Search,Matrix
Medium
null
1,026
hello everyone welcome to my channel so today we are going to do lead code daily challenge maximum difference between node and ancestor as it is medium level question so some tricks would be there even in the question but we can solve it now here about the constraint so the number of nodes in the tree are in range 2 to...
Maximum Difference Between Node and Ancestor
string-without-aaa-or-bbb
Given the `root` of a binary tree, find the maximum value `v` for which there exist **different** nodes `a` and `b` where `v = |a.val - b.val|` and `a` is an ancestor of `b`. A node `a` is an ancestor of `b` if either: any child of `a` is equal to `b` or any child of `a` is an ancestor of `b`. **Example 1:** **Input...
null
String,Greedy
Medium
null
64
Hello hello guys welcome back to back door and this video will see the minimum 5 some problems which also see minimum cost for solar system list to date of the world is gold channel latest problem no problem yes-yes negative numbers from top to bottom which is The longest river in the right direction from giving exampl...
Minimum Path Sum
minimum-path-sum
Given a `m x n` `grid` filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. **Note:** You can only move either down or right at any point in time. **Example 1:** **Input:** grid = \[\[1,3,1\],\[1,5,1\],\[4,2,1\]\] **Output:** 7 **Explanat...
null
Array,Dynamic Programming,Matrix
Medium
62,174,741,2067,2192
1,331
welcome back to another video today we're looking at question 1331 a rank transformation of an array the way we'll be approaching this problem is by using a tree map so basically what we're going to do is we're going to add all the values that we see in the array into the tree map and then after that uh we looked at al...
Rank Transform of an Array
path-with-maximum-gold
Given an array of integers `arr`, replace each element with its rank. The rank represents how large the element is. The rank has the following rules: * Rank is an integer starting from 1. * The larger the element, the larger the rank. If two elements are equal, their rank must be the same. * Rank should be as s...
Use recursion to try all such paths and find the one with the maximum value.
Array,Backtracking,Matrix
Medium
null
593
this is a very simple problem where we are given four points in a 2d space and in a 2d space we have x and y coordinates and a point is represented by two values x 1 x and y so this x denotes distance from origin in x direction and this one denotes distance in y direction so we will have four such pairs corresponding t...
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
309
all right let's talk about the baseline to buy and sell stock with codon so you are given a rate and then you want to find out the maximum profit um basically this uh basically there is a rate and you want to buy uh buy a stock and then at one point you want to sell it right and then somehow you want to have a cooldown...
Best Time to Buy and Sell Stock with Cooldown
best-time-to-buy-and-sell-stock-with-cooldown
You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day. Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times) with the following restrictions: * After you sell your stock, yo...
null
Array,Dynamic Programming
Medium
121,122
826
for everyone today we're going to solve an our C problem today we have Cod problem number 826 most profit assigning work it's a medium problem uh we have jobs and M workers we are given three Aras uh difficulty profit and worker where some difficulty and profit are the difficulty and the profit of the I shop and worker...
Most Profit Assigning Work
soup-servings
You have `n` jobs and `m` workers. You are given three arrays: `difficulty`, `profit`, and `worker` where: * `difficulty[i]` and `profit[i]` are the difficulty and the profit of the `ith` job, and * `worker[j]` is the ability of `jth` worker (i.e., the `jth` worker can only complete a job with difficulty at most `...
null
Math,Dynamic Programming,Probability and Statistics
Medium
null
513
hi guys welcome to the tech grants today's lead code problem is find bottom left tree value so the problem statement here says that given a binary tree find the leftmost value in the last row of the tree it means for this tree this is the last row and we need to get the left most value so here the value is one for this...
Find Bottom Left Tree Value
find-bottom-left-tree-value
Given the `root` of a binary tree, return the leftmost value in the last row of the tree. **Example 1:** **Input:** root = \[2,1,3\] **Output:** 1 **Example 2:** **Input:** root = \[1,2,3,4,null,5,6,null,null,7\] **Output:** 7 **Constraints:** * The number of nodes in the tree is in the range `[1, 104]`. * `-...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
1,658
hey everyone welcome back and let's write some more neat code today so today I'll solve the problem minimum operations to reduce X to Zero so the problem statement is actually pretty simple we're given an array of numbers integers like this and an integer X we are able to perform a couple operations we can either remov...
Minimum Operations to Reduce X to Zero
minimum-swaps-to-arrange-a-binary-grid
You are given an integer array `nums` and an integer `x`. In one operation, you can either remove the leftmost or the rightmost element from the array `nums` and subtract its value from `x`. Note that this **modifies** the array for future operations. Return _the **minimum number** of operations to reduce_ `x` _to **e...
For each row of the grid calculate the most right 1 in the grid in the array maxRight. To check if there exist answer, sort maxRight and check if maxRight[i] ≤ i for all possible i's. If there exist an answer, simulate the swaps.
Array,Greedy,Matrix
Medium
null
1,048
hello everyone welcome to quartus camp we are the seventeenth day of mail equal challenge and the problem we are going to cover is longest string chain the input given here is a list of words and we have to return the longest possible length of word chain with words chosen from the given list of words and the word chan...
Longest String Chain
clumsy-factorial
You are given an array of `words` where each word consists of lowercase English letters. `wordA` is a **predecessor** of `wordB` if and only if we can insert **exactly one** letter anywhere in `wordA` **without changing the order of the other characters** to make it equal to `wordB`. * For example, `"abc "` is a **...
null
Math,Stack,Simulation
Medium
null
1,239
Hello friends, how are you all, my name is Amit Tiwari, you are watching college brother channel, so today we are going to talk about the problem of lead code, maximum length of concated string with unique characters, so the question is saying that you have to get a vector and a string. Given means you will be given an...
Maximum Length of a Concatenated String with Unique Characters
largest-1-bordered-square
You are given an array of strings `arr`. A string `s` is formed by the **concatenation** of a **subsequence** of `arr` that has **unique characters**. Return _the **maximum** possible length_ of `s`. A **subsequence** is an array that can be derived from another array by deleting some or no elements without changing ...
For each square, know how many ones are up, left, down, and right of this square. You can find it in O(N^2) using dynamic programming. Now for each square ( O(N^3) ), we can evaluate whether that square is 1-bordered in O(1).
Array,Dynamic Programming,Matrix
Medium
null
922
what's up guys it's Nick white here and I do all of the hacker achingly code problem solutions I playlist for both of those on my channel and everything else description this is sorta way by parity to we've done this problem before let me make sure we recording yeah we've done an array sort by parity one this one's a l...
Sort Array By Parity II
possible-bipartition
Given an array of integers `nums`, half of the integers in `nums` are **odd**, and the other half are **even**. Sort the array so that whenever `nums[i]` is odd, `i` is **odd**, and whenever `nums[i]` is even, `i` is **even**. Return _any answer array that satisfies this condition_. **Example 1:** **Input:** nums =...
null
Depth-First Search,Breadth-First Search,Union Find,Graph
Medium
null
1,507
yeahyeah Hello everyone, I'm a programmer. Today I'm going to solve the problem of Reformatting a date string. This is a pretty easy problem to understand. Our problem will provide a solution. The string of dates follows the format of the day before the month in the middle and the year at the end A and separated by a s...
Reformat Date
check-if-there-is-a-valid-path-in-a-grid
Given a `date` string in the form `Day Month Year`, where: * `Day` is in the set `{ "1st ", "2nd ", "3rd ", "4th ", ..., "30th ", "31st "}`. * `Month` is in the set `{ "Jan ", "Feb ", "Mar ", "Apr ", "May ", "Jun ", "Jul ", "Aug ", "Sep ", "Oct ", "Nov ", "Dec "}`. * `Year` is in the range `[1900, 2100]`. Conve...
Start DFS from the node (0, 0) and follow the path till you stop. When you reach a cell and cannot move anymore check that this cell is (m - 1, n - 1) or not.
Array,Depth-First Search,Breadth-First Search,Union Find,Matrix
Medium
null
1,362
hey everybody this is larry this is me doing a bonus question for this problem hopeful uh on august 4 ish august 3rd 2022. uh hit the like button to subscribe and join me on discord let me know what you think about today's or this problem this bonus problem is i try to do one that i haven't done before and i let the pi...
Closest Divisors
airplane-seat-assignment-probability
Given an integer `num`, find the closest two integers in absolute difference whose product equals `num + 1` or `num + 2`. Return the two integers in any order. **Example 1:** **Input:** num = 8 **Output:** \[3,3\] **Explanation:** For num + 1 = 9, the closest divisors are 3 & 3, for num + 2 = 10, the closest divisor...
Let f(n) denote the probability of the n-th person getting correct seat in n-person case, then: f(1) = 1 (base case, trivial) f(2) = 1/2 (also trivial) Try to calculate f(3), f(4), and f(5) using the base cases. What if the value of them? f(i) for i >= 2 will also be 1/2. Try to proof why f(i) = 1/2 for i >= 2.
Math,Dynamic Programming,Brainteaser,Probability and Statistics
Medium
null
1,762
everyone today we are going to solve buildings with an ocean view and this is lead code number 1762 and it's a medium difficulty problem so for this question we have n buildings in a line and we are given a integer array that contains the height of each building the ocean is to the right of all the buildings and we wan...
Buildings With an Ocean View
furthest-building-you-can-reach
There are `n` buildings in a line. You are given an integer array `heights` of size `n` that represents the heights of the buildings in the line. The ocean is to the right of the buildings. A building has an ocean view if the building can see the ocean without obstructions. Formally, a building has an ocean view if al...
Assume the problem is to check whether you can reach the last building or not. You'll have to do a set of jumps, and choose for each one whether to do it using a ladder or bricks. It's always optimal to use ladders in the largest jumps. Iterate on the buildings, maintaining the largest r jumps and the sum of the remain...
Array,Greedy,Heap (Priority Queue)
Medium
null
1,475
hello welcome back today I will solve the call 1475 Final prices with a special discount in the shop we're given list of prices for items in the shop this list is in the form of Pisces array such that prices sub I is the price for the if item it is possible to get discount for each item the next item you buy that's che...
Final Prices With a Special Discount in a Shop
maximum-sum-bst-in-binary-tree
You are given an integer array `prices` where `prices[i]` is the price of the `ith` item in a shop. There is a special discount for items in the shop. If you buy the `ith` item, then you will receive a discount equivalent to `prices[j]` where `j` is the minimum index such that `j > i` and `prices[j] <= prices[i]`. Oth...
Create a datastructure with 4 parameters: (sum, isBST, maxLeft, minLeft). In each node compute theses parameters, following the conditions of a Binary Search Tree.
Dynamic Programming,Tree,Depth-First Search,Binary Search Tree,Binary Tree
Hard
null
1,382
okay so lead code practice time um in this video the two goals uh first goal is to see how to solve this problem and then we are going to put some code for the solution and then the second goal is to see how it should behave during a real interview so let's get started so remember the first step in the real interview i...
Balance a Binary Search Tree
balance-a-binary-search-tree
Given the `root` of a binary search tree, return _a **balanced** binary search tree with the same node values_. If there is more than one answer, return **any of them**. A binary search tree is **balanced** if the depth of the two subtrees of every node never differs by more than `1`. **Example 1:** **Input:** root ...
null
null
Medium
null
532
what's up everyone today we're gonna go over leak code 532 k diff pairs in an array first we're gonna go over what the question is asking then we'll go over a solution from leak code user tank is etc' and then we'll look at the code and etc' and then we'll look at the code and etc' and then we'll look at the code and c...
K-diff Pairs in an Array
k-diff-pairs-in-an-array
Given an array of integers `nums` and an integer `k`, return _the number of **unique** k-diff pairs in the array_. A **k-diff** pair is an integer pair `(nums[i], nums[j])`, where the following are true: * `0 <= i, j < nums.length` * `i != j` * `nums[i] - nums[j] == k` **Notice** that `|val|` denotes the absol...
null
Array,Hash Table,Two Pointers,Binary Search,Sorting
Medium
530,2116,2150
1,921
hey guys uh so today we are seeing the today's lead code question daily one so uh I think you should read the question so that you can understand what the question is asking for so let's see uh eliminate maximum number of monsters so I will tell you in short like what this question is saying suppose this is a person or...
Eliminate Maximum Number of Monsters
eliminate-maximum-number-of-monsters
You are playing a video game where you are defending your city from a group of `n` monsters. You are given a **0-indexed** integer array `dist` of size `n`, where `dist[i]` is the **initial distance** in kilometers of the `ith` monster from the city. The monsters walk toward the city at a **constant** speed. The speed...
null
null
Medium
null
154
Hello Guys Welcome To Gautam EDC Today We Will Go Through The 805 Problem July Lettering Challenge Find Minimum Interested Sonth To Please Like This Video And Don't Forget To Subscribe To This Channel Subha Never Miss Any Update On Ki Sapoch Lahari Spotted In Ascending Order Recruited At Some Point Unknown to You Befor...
Find Minimum in Rotated Sorted Array II
find-minimum-in-rotated-sorted-array-ii
Suppose an array of length `n` sorted in ascending order is **rotated** between `1` and `n` times. For example, the array `nums = [0,1,4,4,5,6,7]` might become: * `[4,5,6,7,0,1,4]` if it was rotated `4` times. * `[0,1,4,4,5,6,7]` if it was rotated `7` times. Notice that **rotating** an array `[a[0], a[1], a[2], ....
null
Array,Binary Search
Hard
153
1,541
Ok ok then comeback today happened without rate problems from parent category own problem statement hair's key 110 cc string contains only characters open wicket and west indies string into closing ranks of treated s closing balance sic you have one opening back to back subscribe in The Opening Reddy Always Comes Befor...
Minimum Insertions to Balance a Parentheses String
top-travellers
Given a parentheses string `s` containing only the characters `'('` and `')'`. A parentheses string is **balanced** if: * Any left parenthesis `'('` must have a corresponding two consecutive right parenthesis `'))'`. * Left parenthesis `'('` must go before the corresponding two consecutive right parenthesis `'))'`...
null
Database
Easy
null
1,296
hello so today we are going to look at the contest 168 the problem were looking at right now is divide array in sets of K consecutive numbers and the problem says that we get an array of integers noms and the positive integer K and we want to find whether it's possible to divide this array into as sets of cake consecut...
Divide Array in Sets of K Consecutive Numbers
kth-ancestor-of-a-tree-node
Given an array of integers `nums` and a positive integer `k`, check whether it is possible to divide this array into sets of `k` consecutive numbers. Return `true` _if it is possible_. Otherwise, return `false`. **Example 1:** **Input:** nums = \[1,2,3,3,4,4,5,6\], k = 4 **Output:** true **Explanation:** Array can b...
The queries must be answered efficiently to avoid time limit exceeded verdict. Use sparse table (dynamic programming application) to travel the tree upwards in a fast way.
Binary Search,Dynamic Programming,Tree,Depth-First Search,Breadth-First Search,Design
Hard
null
843
hey what's up guys so here again so this time I want to talk about this very interesting interactive problem here number 400 sorry number 843 gasps the world okay so you're given like a word of list of unique words each of word is six letters long and one not among all those words one of them is chosen to be the secret...
Guess the Word
binary-trees-with-factors
You are given an array of unique strings `words` where `words[i]` is six letters long. One word of `words` was chosen as a secret word. You are also given the helper object `Master`. You may call `Master.guess(word)` where `word` is a six-letter-long string, and it must be from `words`. `Master.guess(word)` returns: ...
null
Array,Hash Table,Dynamic Programming
Medium
null
720
they how their so today I'm looking at question 720 how long is the word in dictionary given you a list of words we want to find the longest word in words such that the word can be built one character at a time by the other words inside the word list now if there are more than one answer we can find the lexical graphic...
Longest Word in Dictionary
longest-word-in-dictionary
Given an array of strings `words` representing an English Dictionary, return _the longest word in_ `words` _that can be built one character at a time by other words in_ `words`. If there is more than one possible answer, return the longest word with the smallest lexicographical order. If there is no answer, return the...
For every word in the input list, we can check whether all prefixes of that word are in the input list by using a Set.
Array,Hash Table,String,Trie,Sorting
Medium
524,676,2009
392
Hello everyone welcome to my channel technical factor today we will ask the name is this sub sequence ok and this is the top interview question of lead code so this will be asked by many companies or and we will see level problem like meaning not so typical But if someone asks in an interview, how do you want to answer...
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
316
hey everybody this is larry this is day 11 of the league code daily challenge hit the like button hit the subscribe button drama discord and let me know what you think about today's forum today's problem being uh remove duplicate letters okay this seems straightforward if it is if the name is what it is given a string ...
Remove Duplicate Letters
remove-duplicate-letters
Given a string `s`, remove duplicate letters so that every letter appears once and only once. You must make sure your result is **the smallest in lexicographical order** among all possible results. **Example 1:** **Input:** s = "bcabc " **Output:** "abc " **Example 2:** **Input:** s = "cbacdcbc " **Output:** "a...
Greedily try to add one missing character. How to check if adding some character will not cause problems ? Use bit-masks to check whether you will be able to complete the sub-sequence if you add the character at some index i.
String,Stack,Greedy,Monotonic Stack
Medium
2157
789
waiting for their friend to you're putting a simplified pac-man game you putting a simplified pac-man game you putting a simplified pac-man game you start at the point zero and your destination is target so target one so target is it's basically an ex-wife so target is it's basically an ex-wife so target is it's basica...
Escape The Ghosts
kth-largest-element-in-a-stream
You are playing a simplified PAC-MAN game on an infinite 2-D grid. You start at the point `[0, 0]`, and you are given a destination point `target = [xtarget, ytarget]` that you are trying to get to. There are several ghosts on the map with their starting positions given as a 2D array `ghosts`, where `ghosts[i] = [xi, y...
null
Tree,Design,Binary Search Tree,Heap (Priority Queue),Binary Tree,Data Stream
Easy
215,1953,2207
633
hey everybody this is larry this is day 25th of the august nico daily challenge hit the like button in the subscriber and join me on discord let me know what you think about this problem other problems whatever you like to do and i usually solve these lives so if it's a little bit slow just skip ahead fast forward what...
Sum of Square Numbers
sum-of-square-numbers
Given a non-negative integer `c`, decide whether there're two integers `a` and `b` such that `a2 + b2 = c`. **Example 1:** **Input:** c = 5 **Output:** true **Explanation:** 1 \* 1 + 2 \* 2 = 5 **Example 2:** **Input:** c = 3 **Output:** false **Constraints:** * `0 <= c <= 231 - 1`
null
Math,Two Pointers,Binary Search
Medium
367
1,947
so hello everyone so in this video i will be explaining the problem 1947 maximum compatibility score sum which is not that difficult problem it is a basic dynamic backtracking problem so we will understand that why it is a backtracking problem and we will understand our level up our thought process and approach and the...
Maximum Compatibility Score Sum
number-of-different-subsequences-gcds
There is a survey that consists of `n` questions where each question's answer is either `0` (no) or `1` (yes). The survey was given to `m` students numbered from `0` to `m - 1` and `m` mentors numbered from `0` to `m - 1`. The answers of the students are represented by a 2D integer array `students` where `students[i]`...
Think of how to check if a number x is a gcd of a subsequence. If there is such subsequence, then all of it will be divisible by x. Moreover, if you divide each number in the subsequence by x , then the gcd of the resulting numbers will be 1. Adding a number to a subsequence cannot increase its gcd. So, if there is a v...
Array,Math,Counting,Number Theory
Hard
2106
443
so the unit problem is given an array of characters I have placed into this yeah even an array of characters cats complicit using the following algorithm so they have given the steps to do in the algorithm you're not using any already existing algorithm here so the given array of characters there is an array that conta...
String Compression
string-compression
Given an array of characters `chars`, compress it using the following algorithm: Begin with an empty string `s`. For each group of **consecutive repeating characters** in `chars`: * If the group's length is `1`, append the character to `s`. * Otherwise, append the character followed by the group's length. The co...
How do you know if you are at the end of a consecutive group of characters?
Two Pointers,String
Medium
38,271,604,1241
1,326
hello hi guys good morning welcome back to the new video uh so basically in this video we're gonna see the problem minimum number of tabs to open to water a garden it's uh like not easy one especially like to think what algorithm is going to be applied maybe easy but to actually write it and code it down or maybe just ...
Minimum Number of Taps to Open to Water a Garden
sum-of-floored-pairs
There is a one-dimensional garden on the x-axis. The garden starts at the point `0` and ends at the point `n`. (i.e The length of the garden is `n`). There are `n + 1` taps located at points `[0, 1, ..., n]` in the garden. Given an integer `n` and an integer array `ranges` of length `n + 1` where `ranges[i]` (0-index...
Find the frequency (number of occurrences) of all elements in the array. For each element, iterate through its multiples and multiply frequencies to find the answer.
Array,Math,Binary Search,Prefix Sum
Hard
null
779
hello guys welcome back to L code today let's practice a Lal question C symbol in grammar so we build okay we build a table of n row so that is a one index rules and we start by writing zero in the first rule and now in every subsequence rule we look at the previous Rule and replace each occurrence of zero with 01 and ...
K-th Symbol in Grammar
max-chunks-to-make-sorted-ii
We build a table of `n` rows (**1-indexed**). We start by writing `0` in the `1st` row. Now in every subsequent row, we look at the previous row and replace each occurrence of `0` with `01`, and each occurrence of `1` with `10`. * For example, for `n = 3`, the `1st` row is `0`, the `2nd` row is `01`, and the `3rd` r...
Each k for which some permutation of arr[:k] is equal to sorted(arr)[:k] is where we should cut each chunk.
Array,Stack,Greedy,Sorting,Monotonic Stack
Hard
780
3
hello friends welcome to good hair curly the Coco Dean tutorial here we are going to solve lead cocconi problem longest substring without repeating characters here is a problem description Kumar string find the length of the longest substring without repeating characters so for example kumanyika string ABC PB the answe...
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
375
um hello warning this thing on i think so hello welcome we're gonna go ahead and begin we're gonna pick up where we left off before to pick up where we left off before and that is we were looking at this problem here guess number higher lower also happy good friday see how far we get today with these problems so we wer...
Guess Number Higher or Lower II
guess-number-higher-or-lower-ii
We are playing the Guessing Game. The game will work as follows: 1. I pick a number between `1` and `n`. 2. You guess a number. 3. If you guess the right number, **you win the game**. 4. If you guess the wrong number, then I will tell you whether the number I picked is **higher or lower**, and you will continue gu...
The best strategy to play the game is to minimize the maximum loss you could possibly face. Another strategy is to minimize the expected loss. Here, we are interested in the first scenario. Take a small example (n = 3). What do you end up paying in the worst case? Check out this article if you're still stuck. The purel...
Math,Dynamic Programming,Game Theory
Medium
294,374,464,658
153
hey everyone today we are going to solve the reticle question find the minimum in rotated sorted array so it looks like this is a very famous question so we should try it so suppose array of links and sorted in ascending order is rotated between one and N times for example the array is like this might become so array i...
Find Minimum in Rotated Sorted Array
find-minimum-in-rotated-sorted-array
Suppose an array of length `n` sorted in ascending order is **rotated** between `1` and `n` times. For example, the array `nums = [0,1,2,4,5,6,7]` might become: * `[4,5,6,7,0,1,2]` if it was rotated `4` times. * `[0,1,2,4,5,6,7]` if it was rotated `7` times. Notice that **rotating** an array `[a[0], a[1], a[2], ....
Array was originally in ascending order. Now that the array is rotated, there would be a point in the array where there is a small deflection from the increasing sequence. eg. The array would be something like [4, 5, 6, 7, 0, 1, 2]. You can divide the search space into two and see which direction to go. Can you think ...
Array,Binary Search
Medium
33,154
509
hi everyone mrs. Fisher - over here hi everyone mrs. Fisher - over here hi everyone mrs. Fisher - over here today we're going through a legal problem 509 table matching Fibonacci number before we dive in case do me a favor and hit that thumbs up button hit that like button and don't forget to subscribe to our channel w...
Fibonacci Number
inorder-successor-in-bst-ii
The **Fibonacci numbers**, commonly denoted `F(n)` form a sequence, called the **Fibonacci sequence**, such that each number is the sum of the two preceding ones, starting from `0` and `1`. That is, F(0) = 0, F(1) = 1 F(n) = F(n - 1) + F(n - 2), for n > 1. Given `n`, calculate `F(n)`. **Example 1:** **Input:** n = ...
null
Tree,Binary Search Tree,Binary Tree
Medium
285
1,269
hey everyone welcome back and let's write some more neat code today so today let's solve the problem number of ways to stay in the same place after some steps this is an interesting problem we're given a pointer which starts at index zero and we're also given an array of this length but we're not actually given an arra...
Number of Ways to Stay in the Same Place After Some Steps
market-analysis-ii
You have a pointer at index `0` in an array of size `arrLen`. At each step, you can move 1 position to the left, 1 position to the right in the array, or stay in the same place (The pointer should not be placed outside the array at any time). Given two integers `steps` and `arrLen`, return the number of ways such that...
null
Database
Hard
null
1,876
hey everybody this is larry this is me going over q1 of the bi-weekly contest uh 53 bi-weekly contest uh 53 bi-weekly contest uh 53 uh sub strings of size 3 with distinct characters so yeah so string is good if there's no repeated characters so basically you just have to look at every uh because substring you just look...
Substrings of Size Three with Distinct Characters
map-of-highest-peak
A string is **good** if there are no repeated characters. Given a string `s`​​​​​, return _the number of **good substrings** of length **three** in_ `s`​​​​​​. Note that if there are multiple occurrences of the same substring, every occurrence should be counted. A **substring** is a contiguous sequence of characters...
Set each water cell to be 0. The height of each cell is limited by its closest water cell. Perform a multi-source BFS with all the water cells as sources.
Array,Breadth-First Search,Matrix
Medium
null
1,773
hello guys my name is ASLA and welcome back to my channel and today we are going to solve a new lead code question that is Count items matching a rule we will be solving this question with the help of python so just before starting to solve this question guys do subscribe to the channel hit the like button press the Be...
Count Items Matching a Rule
percentage-of-users-attended-a-contest
You are given an array `items`, where each `items[i] = [typei, colori, namei]` describes the type, color, and name of the `ith` item. You are also given a rule represented by two strings, `ruleKey` and `ruleValue`. The `ith` item is said to match the rule if **one** of the following is true: * `ruleKey == "type "` ...
null
Database
Easy
1338
124
So Hi Gas Welcome Tu Code Off So in today's video we will see a question which is Maximum Path Sam in Binary Tree which is a very important question from the gas interview point of view, I have seen this asked in many interviews. This is a very important question from the interference point of view. So let's see what t...
Binary Tree Maximum Path Sum
binary-tree-maximum-path-sum
A **path** in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence **at most once**. Note that the path does not need to pass through the root. The **path sum** of a path is the sum of the node's values in the path. ...
null
Dynamic Programming,Tree,Depth-First Search,Binary Tree
Hard
112,129,666,687,1492
657
hello everyone in this lecture i am going to explain you about robot return to origin here in this question they are given there is a robot starting at position 0 the origin on a 2d plane given a sequence of its moves just if this robot ends up at 0 after it completes its moves the move sequence is represented by a str...
Robot Return to Origin
robot-return-to-origin
There is a robot starting at the position `(0, 0)`, the origin, on a 2D plane. Given a sequence of its moves, judge if this robot **ends up at** `(0, 0)` after it completes its moves. You are given a string `moves` that represents the move sequence of the robot where `moves[i]` represents its `ith` move. Valid moves a...
null
String,Simulation
Easy
547,2239
146
hey how's it going guys so in this video we'll discuss about this problem I'll add you cash so design and implement a data structure for least recently used cash it should support the following operation get input so get means get the value will always be positive of the key exists in the cache otherwise it n minus 1 p...
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
220
hello everyone today's lead code question is contains duplicate 3 the question says that we are given an array of integers and we have to find out whether there are two distinct indices i and j in the array such that the absolute difference between the nums i and of j is at most t and the absolute difference between i ...
Contains Duplicate III
contains-duplicate-iii
You are given an integer array `nums` and two integers `indexDiff` and `valueDiff`. Find a pair of indices `(i, j)` such that: * `i != j`, * `abs(i - j) <= indexDiff`. * `abs(nums[i] - nums[j]) <= valueDiff`, and Return `true` _if such pair exists or_ `false` _otherwise_. **Example 1:** **Input:** nums = \[1...
Time complexity O(n logk) - This will give an indication that sorting is involved for k elements. Use already existing state to evaluate next state - Like, a set of k sorted numbers are only needed to be tracked. When we are processing the next number in array, then we can utilize the existing sorted state and it is...
Array,Sliding Window,Sorting,Bucket Sort,Ordered Set
Medium
217,219
55
okay so question 55 leak code jump game so you're given an integer array nums you're 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 so off the bat it seems like a pretty str...
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
56
hello so today we are doing this problem called marriage intervals and so the problem says we get a collection of intervals and we want to merge all overlapping intervals and so for example we get this list of intervals and so this here is the first element is the start of the interval the second element is the end of ...
Merge Intervals
merge-intervals
Given an array of `intervals` where `intervals[i] = [starti, endi]`, merge all overlapping intervals, and return _an array of the non-overlapping intervals that cover all the intervals in the input_. **Example 1:** **Input:** intervals = \[\[1,3\],\[2,6\],\[8,10\],\[15,18\]\] **Output:** \[\[1,6\],\[8,10\],\[15,18\]\...
null
Array,Sorting
Medium
57,252,253,495,616,715,761,768,1028,2297,2319
71
hello everyone so today in this video we are going to solve a question of fleet code that is simplify path it is 71 question only code and it comes under medium category all right so let's start with the problem statement given a string path which in which is an absolute path starting with slash to a file or a director...
Simplify Path
simplify-path
Given a string `path`, which is an **absolute path** (starting with a slash `'/'`) to a file or directory in a Unix-style file system, convert it to the simplified **canonical path**. In a Unix-style file system, a period `'.'` refers to the current directory, a double period `'..'` refers to the directory up a level,...
null
String,Stack
Medium
null
286
welcome back to algojs today's question is leak code 286 walls and gates so you're given an m by n grid rooms initialized with these three possible values minus one indicates a wall zero a gate and then inf which indicates an integer a value 2 to the power of 31 minus 1 and you may assume that the distance to a gate is...
Walls and Gates
walls-and-gates
You are given an `m x n` grid `rooms` initialized with these three possible values. * `-1` A wall or an obstacle. * `0` A gate. * `INF` Infinity means an empty room. We use the value `231 - 1 = 2147483647` to represent `INF` as you may assume that the distance to a gate is less than `2147483647`. Fill each empt...
null
Array,Breadth-First Search,Matrix
Medium
130,200,317,865,1036
12
so the approach we'll be using is the hashmap we'll take the collector as a symbol and value as an integer put the symbol and the respective value in the hash map so map.put and hash map so map.put and hash map so map.put and we'll make an integer as a result that would be keeping that most last recent value of it keep...
Integer to Roman
integer-to-roman
Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`. **Symbol** **Value** I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, `2` is written as `II` in Roman numeral, just two one's adde...
null
Hash Table,Math,String
Medium
13,273
315
hello friends to the length of the couch of smaller numbers after self you are given an integer array numbers and you have to return a new couch array the count of the count array has a property where house is the number of smaller elements to the right of numbers I see this Dumbo if the input is 5 to 6 1 we will retur...
Count of Smaller Numbers After Self
count-of-smaller-numbers-after-self
Given an integer array `nums`, return _an integer array_ `counts` _where_ `counts[i]` _is the number of smaller elements to the right of_ `nums[i]`. **Example 1:** **Input:** nums = \[5,2,6,1\] **Output:** \[2,1,1,0\] **Explanation:** To the right of 5 there are **2** smaller elements (2 and 1). To the right of 2 the...
null
Array,Binary Search,Divide and Conquer,Binary Indexed Tree,Segment Tree,Merge Sort,Ordered Set
Hard
327,406,493,1482,2280