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
879
um hello So today we're going to do this problem which is part of Fleet code daily challenge uh profitable schemes so basically um in this problem we have a group of n members okay and we have a list of crimes they sh they could commit okay um and then the ice crime generates profit I so um but I'll say crime zero gene...
Profitable Schemes
maximize-distance-to-closest-person
There is a group of `n` members, and a list of various crimes they could commit. The `ith` crime generates a `profit[i]` and requires `group[i]` members to participate in it. If a member participates in one crime, that member can't participate in another crime. Let's call a **profitable scheme** any subset of these cr...
null
Array
Medium
885
84
hello friends today less of largest rectangle in histogram as first thing about the proof of solution we just iterate all the bars from left to right and we come by the current bar with preceding bars to get new rectangles for example if the current bar is 5 we know the 5 times 1 is a rectangle and we try to come by th...
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
35
welcome back to algo jest today's question is leak code 35 search insert position so 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 so ...
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
211
Hello guys welcome oil hot media live today episode 235 problem on August late coding challenge data structure design please like this video fuel forget to subscribe our Channel morning renewal mission update designer data center approach fall into operation from Edward and search and show Su Little Board and Regular E...
Design Add and Search Words Data Structure
design-add-and-search-words-data-structure
Design a data structure that supports adding new words and finding if a string matches any previously added string. Implement the `WordDictionary` class: * `WordDictionary()` Initializes the object. * `void addWord(word)` Adds `word` to the data structure, it can be matched later. * `bool search(word)` Returns ...
You should be familiar with how a Trie works. If not, please work on this problem: Implement Trie (Prefix Tree) first.
String,Depth-First Search,Design,Trie
Medium
208,746
146
hey everyone welcome back and let's write some more neat code today let's take a look at a really popular interview question lru cash it's even asked by twitch tv it's one of their most popular interview questions and also don't forget to like the video it supports the channel a lot so this is definitely more of a desi...
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
653
welcome to august leco challenge today's problem is two sum four input is a bst given the root of a binary search tree any target number k return true if there exists two elements in the bst such that their sum is equal to the given target so it's a typical two-sum problem we so it's a typical two-sum problem we so it'...
Two Sum IV - Input is a BST
two-sum-iv-input-is-a-bst
Given the `root` of a binary search tree and an integer `k`, return `true` _if there exist two elements in the BST such that their sum is equal to_ `k`, _or_ `false` _otherwise_. **Example 1:** **Input:** root = \[5,3,6,2,4,null,7\], k = 9 **Output:** true **Example 2:** **Input:** root = \[5,3,6,2,4,null,7\], k = ...
null
Hash Table,Two Pointers,Tree,Depth-First Search,Breadth-First Search,Binary Search Tree,Binary Tree
Easy
1,167,170,1150
373
Adam is back again with his daily news challenge and today's question is a medium level problem, this question is already sorted and what we have to do is to create an element which will give us number one. We have to take from and one elements and that leg should be such that the one which is equal to it is the minimu...
Find K Pairs with Smallest Sums
find-k-pairs-with-smallest-sums
You are given two integer arrays `nums1` and `nums2` sorted in **ascending order** and an integer `k`. Define a pair `(u, v)` which consists of one element from the first array and one element from the second array. Return _the_ `k` _pairs_ `(u1, v1), (u2, v2), ..., (uk, vk)` _with the smallest sums_. **Example 1:**...
null
Array,Heap (Priority Queue)
Medium
378,719,2150
298
because it is called banares chilangas cannes and tips and queens it is a super simple thing they ask us is that they are going to give us a tree with the node of a tree and we have to find what is the most realistic list of consecutive numbers and a high amount of consecutive numbers that we can join with the new ones...
Binary Tree Longest Consecutive Sequence
binary-tree-longest-consecutive-sequence
Given the `root` of a binary tree, return _the length of the longest **consecutive sequence path**_. A **consecutive sequence path** is a path where the values **increase by one** along the path. Note that the path can start **at any node** in the tree, and you cannot go from a node to its parent in the path. **Exam...
null
Tree,Depth-First Search,Binary Tree
Medium
128,549,1416
219
contains duplicate part two so given an integer elements and integer K written through if there are two distinct indices I and J in the array such that number is equal to num sub J and the absolute difference between the I and J is lesser than or equal to K so what do they mean by the question um let's say the array cu...
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
299
In the second question of 13, let's see it in this, as if here we have got the input, then what do we have to do in this [ then what do we have to do in this [ then what do we have to do in this This is an example, give this example, so as if this is our secret string, this is our gas string. In this, we have to tell h...
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
328
hey how's it going so today we are going over leeco's 328 question not even link list given a single linked list group all odd nodes together followed by the evenness please note that there are we are talking about the nodes number and not the value in the nodes we should try to do it in place uh the program should run...
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
34
hello welcome to my channel today we have leeco 34 find first and last position of element in sorted array so given an array of integer nums sorted in ascending order find the starting and ending position of the given target value so if the target is not found in an array so we turn negative one and negative one so um ...
Find First and Last Position of Element in Sorted Array
find-first-and-last-position-of-element-in-sorted-array
Given an array of integers `nums` sorted in non-decreasing order, find the starting and ending position of a given `target` value. If `target` is not found in the array, return `[-1, -1]`. You must write an algorithm with `O(log n)` runtime complexity. **Example 1:** **Input:** nums = \[5,7,7,8,8,10\], target = 8 *...
null
Array,Binary Search
Medium
278,2165,2210
986
Hello hello guys welcome back to years in this video you will see how to find the interview list interactions with this from list co 23rd the match 2016 personal problem statement problems that were given to list playlist of interviews were pulled in water no need to the INTERSECTION OF INTERNAL subscribe to the Page i...
Interval List Intersections
largest-time-for-given-digits
You are given two lists of closed intervals, `firstList` and `secondList`, where `firstList[i] = [starti, endi]` and `secondList[j] = [startj, endj]`. Each list of intervals is pairwise **disjoint** and in **sorted order**. Return _the intersection of these two interval lists_. A **closed interval** `[a, b]` (with `a...
null
String,Enumeration
Medium
null
461
Hello Everyone Welcome To My Channel Today Solved 5MB Problem Having Stand All Mintu In Tears Is The Number Of Position Which Corresponds With Different Activities Hey Wow Calculate Distance Between 02351 Then Subscribe The Channel Different More Than 1000 Dravid And Virat For Example 0 Ki And 400 Support Him And Dista...
Hamming Distance
hamming-distance
The [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) between two integers is the number of positions at which the corresponding bits are different. Given two integers `x` and `y`, return _the **Hamming distance** between them_. **Example 1:** **Input:** x = 1, y = 4 **Output:** 2 **Explanation:** 1...
null
Bit Manipulation
Easy
191,477
1,544
welcome political JavaScript a channel where we solve every single little question using JavaScript today we have 1544 make the string grade this is an easy question so given a string pass of lower and uppercase letters a good string is defined as one that does not have two adjacent characters as I and a sub plus 1 wer...
Make The String Great
count-good-nodes-in-binary-tree
Given a string `s` of lower and upper case English letters. A good string is a string which doesn't have **two adjacent characters** `s[i]` and `s[i + 1]` where: * `0 <= i <= s.length - 2` * `s[i]` is a lower-case letter and `s[i + 1]` is the same letter but in upper-case or **vice-versa**. To make the string go...
Use DFS (Depth First Search) to traverse the tree, and constantly keep track of the current path maximum.
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
1,750
It is very much that Seervi Sagar will solve the question today. Medium length of thing after removing the similarity. Okay, first of all Govinda, let me explain the meaning. Ask the question. If you understand, it will be a lot of fun. It is true and never even by mistake, there will be ginger in the enter. They are t...
Minimum Length of String After Deleting Similar Ends
check-if-two-expression-trees-are-equivalent
Given a string `s` consisting only of characters `'a'`, `'b'`, and `'c'`. You are asked to apply the following algorithm on the string any number of times: 1. Pick a **non-empty** prefix from the string `s` where all the characters in the prefix are equal. 2. Pick a **non-empty** suffix from the string `s` where all...
Count for each variable how many times it appeared in the first tree. Do the same for the second tree and check if the count is the same for both tree.
Tree,Depth-First Search,Binary Tree
Medium
1736
363
The Whole World is Incomplete Channel Tweet Sunny And You Will Be Talking About Very Interesting Problem Maximum Sum of Practical Knowledge Bank Ki OK Flexible Like Share and Subscribe Button Subscribe Thank You Can Easily See Problem Mind Manch subscribe and subscribe this Video Equal Samiti Ki Report Subscribe Thank ...
Max Sum of Rectangle No Larger Than K
max-sum-of-rectangle-no-larger-than-k
Given an `m x n` matrix `matrix` and an integer `k`, return _the max sum of a rectangle in the matrix such that its sum is no larger than_ `k`. It is **guaranteed** that there will be a rectangle with a sum no larger than `k`. **Example 1:** **Input:** matrix = \[\[1,0,1\],\[0,-2,3\]\], k = 2 **Output:** 2 **Explana...
null
Array,Binary Search,Dynamic Programming,Matrix,Ordered Set
Hard
null
1,335
hey everyone welcome back and let's write some more neat code today so today let's solve the problem minimum difficulty of a job schedule kind of a confusing problem so I'm really going to focus on the example that we have here so the idea is that we have a bunch of jobs and we're given the difficulty of each job in th...
Minimum Difficulty of a Job Schedule
maximum-candies-allocated-to-k-children
You want to schedule a list of jobs in `d` days. Jobs are dependent (i.e To work on the `ith` job, you have to finish all the jobs `j` where `0 <= j < i`). You have to finish **at least** one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the `d` days. The difficulty of a da...
For a fixed number of candies c, how can you check if each child can get c candies? Use binary search to find the maximum c as the answer.
Array,Binary Search
Medium
907,1886,2000,2027,2188,2294
91
Tiger, in this video, I am asking you a question, very interesting, special type of shooting, completely successful, subscribe the channel. Okay, so you can do it one, two, three. Now on behalf of the school, tell me in how many ways the film can be folded. Okay. So if we have to do it in a small time then what happens...
Decode Ways
decode-ways
A message containing letters from `A-Z` can be **encoded** into numbers using the following mapping: 'A' -> "1 " 'B' -> "2 " ... 'Z' -> "26 " To **decode** an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For examp...
null
String,Dynamic Programming
Medium
639,2091
1,630
hey everybody this is Larry this is day 23 of the Cod d challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's F today I'm in kyaan this is the great Gates and I'm ready to explore it uh yeah back to the problem but also if you want to you know learn more abou...
Arithmetic Subarrays
count-odd-numbers-in-an-interval-range
A sequence of numbers is called **arithmetic** if it consists of at least two elements, and the difference between every two consecutive elements is the same. More formally, a sequence `s` is arithmetic if and only if `s[i+1] - s[i] == s[1] - s[0]` for all valid `i`. For example, these are **arithmetic** sequences: 1...
If the range (high - low + 1) is even, the number of even and odd numbers in this range will be the same. If the range (high - low + 1) is odd, the solution will depend on the parity of high and low.
Math
Easy
null
12
Hi gas welcome and welcome back to my channel so today our problem is wait you Roman so what have you given us in this problem statement, here we have been given a number wait number and what we have to do with it is to convert it into Roman number. You must be aware that what is a Roman number, what do we do, we conve...
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
4
hello and welcome to another Elite code solutions video this is problem number four median of two sorted arrays this problem is given two sorted arrays nums one and nums two of size M and N respectively return the median of the two sorted arrays the overall runtime complexity should be o of log M plus n example one for...
Median of Two Sorted Arrays
median-of-two-sorted-arrays
Given two sorted arrays `nums1` and `nums2` of size `m` and `n` respectively, return **the median** of the two sorted arrays. The overall run time complexity should be `O(log (m+n))`. **Example 1:** **Input:** nums1 = \[1,3\], nums2 = \[2\] **Output:** 2.00000 **Explanation:** merged array = \[1,2,3\] and median is ...
null
Array,Binary Search,Divide and Conquer
Hard
null
83
Hello everyone, Evgeniy Sulima here and today we are considering the solution to the problem years code number 83 removing duplicates from a sorted list and as the ambassador of this task we are given a sorted linked list and we must remove all duplicates in such a way that each element, that is, each value is repeated...
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
165
Ko Hi I am you Sherawat and welcome to my channel today we will discuss the temple jewelery no problem two numbers we live with 2012 - 09 nintendo character live with 2012 - 09 nintendo character live with 2012 - 09 nintendo character director point to point se 2.5 not to the return of the day quick revision number of ...
Compare Version Numbers
compare-version-numbers
Given two version numbers, `version1` and `version2`, compare them. Version numbers consist of **one or more revisions** joined by a dot `'.'`. Each revision consists of **digits** and may contain leading **zeros**. Every revision contains **at least one character**. Revisions are **0-indexed from left to right**, wit...
null
Two Pointers,String
Medium
null
133
hey everybody this is Larry this is day eighth of the league code daily challenge I believe yeah hit the like button in the Subscribe button join me on Discord let me know what you think about today's farm and of course there's gonna be a week two uh after that so definitely check that out as well um today's problem is...
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
31
hello and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem 31 next permutation before we get into the solution for this i just want to say i hate this problem hate this is my least favorite problem and i just want to say i know how to solve it i know the solution and i...
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
350
hello everyone so in this video let us do two problems fine so both of them are easy the problem name is intersection of two arrays one as well as intersection of two arrays two let us solve both of them in this video see so the problem statement goes like this that given two integer arrays nums1 and num2 return an arr...
Intersection of Two Arrays II
intersection-of-two-arrays-ii
Given two integer arrays `nums1` and `nums2`, return _an array of their intersection_. Each element in the result must appear as many times as it shows in both arrays and you may return the result in **any order**. **Example 1:** **Input:** nums1 = \[1,2,2,1\], nums2 = \[2,2\] **Output:** \[2,2\] **Example 2:** **I...
null
Array,Hash Table,Two Pointers,Binary Search,Sorting
Easy
349,1044,1392,2282
283
Hi guys hello welcome to the channel I am doing 90 days software engineering prep this is question 10 lead code 75 overall question lead code 283 move zeroes ok so before I start the question I would request you that Generalize your progress with me. I keep a daily journal on another channel to see what is going on and...
Move Zeroes
move-zeroes
Given an integer array `nums`, move all `0`'s to the end of it while maintaining the relative order of the non-zero elements. **Note** that you must do this in-place without making a copy of the array. **Example 1:** **Input:** nums = \[0,1,0,3,12\] **Output:** \[1,3,12,0,0\] **Example 2:** **Input:** nums = \[0\]...
In-place means we should not be allocating any space for extra array. But we are allowed to modify the existing array. However, as a first step, try coming up with a solution that makes use of additional space. For this problem as well, first apply the idea discussed using an additional array and the in-place solution ...
Array,Two Pointers
Easy
27
1,720
Hello viewers welcome to you quotes on in this video will be looking at the New Delhi to Swayam Record accept what are the a quadrilateral that is a problem statement piece rate of this software's one and interior and good show hotspot were given and the are endowed 120 300 first the first Slovenian to find the origina...
Decode XORed Array
crawler-log-folder
There is a **hidden** integer array `arr` that consists of `n` non-negative integers. It was encoded into another integer array `encoded` of length `n - 1`, such that `encoded[i] = arr[i] XOR arr[i + 1]`. For example, if `arr = [1,0,2,1]`, then `encoded = [1,2,3]`. You are given the `encoded` array. You are also give...
Simulate the process but don’t move the pointer beyond the main folder. Simulate the process but don’t move the pointer beyond the main folder.
Array,String,Stack
Easy
682,874
326
foreign with the lonely Dash and today we're going over leap code question number 326 power of three which states given an integer n returned true if it is a power of 3 otherwise return false an integer N is a power of three if there exists an integer X such that n equals 3 to the X so what does this mean well it just ...
Power of Three
power-of-three
Given an integer `n`, return _`true` if it is a power of three. Otherwise, return `false`_. An integer `n` is a power of three, if there exists an integer `x` such that `n == 3x`. **Example 1:** **Input:** n = 27 **Output:** true **Explanation:** 27 = 33 **Example 2:** **Input:** n = 0 **Output:** false **Explanat...
null
Math,Recursion
Easy
231,342,1889
167
hey guys Greg here and let's solve two sum 2 where the input array is sorted it's a really interesting problem I like it a lot so we're given a one index array of integers numbers doesn't really change anything it's just the way that they're expressing it in the problem that is already sorted in non-decreasing that is ...
Two Sum II - Input Array Is Sorted
two-sum-ii-input-array-is-sorted
Given a **1-indexed** array of integers `numbers` that is already **_sorted in non-decreasing order_**, find two numbers such that they add up to a specific `target` number. Let these two numbers be `numbers[index1]` and `numbers[index2]` where `1 <= index1 < index2 <= numbers.length`. Return _the indices of the two n...
null
Array,Two Pointers,Binary Search
Medium
1,653,1083
118
hey what's up guys so let's solve this pascal triangle so personal triangle i think everybody learns in the junior high school so one two one uh one two three one four uh six four one so it's very simple that's given an array right the next array will be uh each element will be sum of the previous uh row right so three...
Pascal's Triangle
pascals-triangle
Given an integer `numRows`, return the first numRows of **Pascal's triangle**. In **Pascal's triangle**, each number is the sum of the two numbers directly above it as shown: **Example 1:** **Input:** numRows = 5 **Output:** \[\[1\],\[1,1\],\[1,2,1\],\[1,3,3,1\],\[1,4,6,4,1\]\] **Example 2:** **Input:** numRows = ...
null
Array,Dynamic Programming
Easy
119
1,799
foreign this is me doing day 14 of the legal daily challenge hit the like button hit the Subscribe button join me on Discord uh totally clicked on it let me know what you think about today's vlog so what did I click on also as you can see my internet is very slow I don't even know how what happened but uh yeah clicking...
Maximize Score After N Operations
minimum-incompatibility
You are given `nums`, an array of positive integers of size `2 * n`. You must perform `n` operations on this array. In the `ith` operation **(1-indexed)**, you will: * Choose two elements, `x` and `y`. * Receive a score of `i * gcd(x, y)`. * Remove `x` and `y` from `nums`. Return _the maximum score you can rec...
The constraints are small enough for a backtrack solution but not any backtrack solution If we use a naive n^k don't you think it can be optimized
Array,Dynamic Programming,Bit Manipulation,Bitmask
Hard
null
1,481
welcome back to my channel today's lead code DCC question is least number of unique integers after K removal problem statement says given an array of integers ARR and an integer K find the least number of unique integers after removing exactly K elements the problem statement says so we will be given an array of intege...
Least Number of Unique Integers after K Removals
students-with-invalid-departments
Given an array of integers `arr` and an integer `k`. Find the _least number of unique integers_ after removing **exactly** `k` elements**.** **Example 1:** **Input:** arr = \[5,5,4\], k = 1 **Output:** 1 **Explanation**: Remove the single 4, only 5 is left. **Example 2:** **Input:** arr = \[4,3,1,1,3,3,2\], k = 3 *...
null
Database
Easy
null
270
foreign binary search tree problem I thought it has been a while since we have been doing the graph problem so why not to change the topic and tree is my favorite topic it is my favorite topic so the problem is 270 that is closest by the research tree value so in this problem we'll be given a binary search tree and a v...
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
120
welcome back to this video in this video we're going to solve this coordinative equation triangle in this problem we're giving a list of lists this is our list of lists in our first row we have just this list which is found in one of one item then this is our second list third list and fourth list these are row so firs...
Triangle
triangle
Given a `triangle` array, return _the minimum path sum from top to bottom_. For each step, you may move to an adjacent number of the row below. More formally, if you are on index `i` on the current row, you may move to either index `i` or index `i + 1` on the next row. **Example 1:** **Input:** triangle = \[\[2\],\[...
null
Array,Dynamic Programming
Medium
null
275
Hello guys welcome back to record degi team from June record challenge and toubro limited index in this problem will also go through the problem description and will try to understand with few examples and will explore different a solution approach for these problems and also will discuss time Complexity Wipro Chiffon ...
H-Index II
h-index-ii
Given an array of integers `citations` where `citations[i]` is the number of citations a researcher received for their `ith` paper and `citations` is sorted in **ascending order**, return _the researcher's h-index_. According to the [definition of h-index on Wikipedia](https://en.wikipedia.org/wiki/H-index): The h-ind...
Expected runtime complexity is in O(log n) and the input is sorted.
Array,Binary Search
Medium
274
108
hello guys today we will solve the question convert sorted array to binary search tree and the question number is 108 and the question type is easy and the question statement is given an integer array where the elements are sorted in ascending order convert it to a height balanced binary search tree so what is by heigh...
Convert Sorted Array to Binary Search Tree
convert-sorted-array-to-binary-search-tree
Given an integer array `nums` where the elements are sorted in **ascending order**, convert _it to a_ **_height-balanced_** _binary search tree_. **Example 1:** **Input:** nums = \[-10,-3,0,5,9\] **Output:** \[0,-3,9,-10,null,5\] **Explanation:** \[0,-10,5,null,-3,null,9\] is also accepted: **Example 2:** **Input...
null
Array,Divide and Conquer,Tree,Binary Search Tree,Binary Tree
Easy
109
6
Hare Krishna guys so welcome to my youtube1 day we are solving one or the other question of lead quote so today our question number is six which is we have to make zigzag conversion okay so we will be given a string we will have to make it in zigzag form. So if you have solved pattern questions, then you can think of m...
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
1,706
Hey Guy, today we will do our first question number 27. What is the question trying to say and what response do we have to send? Okay, you will have a 2D grid, this is your grade, okay, the values ​​in the grade will be only van your grade, okay, the values ​​in the grade will be only van your grade, okay, the values ​...
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
26
Hello Gas Myself Amrita Welcome Back To Our Channel Techno Says So Inner Court Series They Have Bin Solving Lip Code Problems Per En Wile No Or No They Are Going To Start Up With Top Interview Questions On Lead Code These Are One 150 Questions And Bill Be Solving Which D question one by one so I have already solved fir...
Remove Duplicates from Sorted Array
remove-duplicates-from-sorted-array
Given an integer array `nums` sorted in **non-decreasing order**, remove the duplicates [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm) such that each unique element appears only **once**. The **relative order** of the elements should be kept the **same**. Then return _the number of unique elements in_...
In this problem, the key point to focus on is the input array being sorted. As far as duplicate elements are concerned, what is their positioning in the array when the given array is sorted? Look at the image above for the answer. If we know the position of one of the elements, do we also know the positioning of all th...
Array,Two Pointers
Easy
27,80
279
Welcome back to our new video and today we are going to watch Perfect Square so as usual we will read the problem statement first because people have said that the solution lies in the problem itself so let's read the problem again. You will find your solution so you have been given an error and return the list number ...
Perfect Squares
perfect-squares
Given an integer `n`, return _the least number of perfect square numbers that sum to_ `n`. A **perfect square** is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, `1`, `4`, `9`, and `16` are perfect squares while `3` and `11` are not. **Example ...
null
Math,Dynamic Programming,Breadth-First Search
Medium
204,264
1,326
Hello friends, welcome question number 1360 number of text open two water garden, how many steps should be opened so that the entire garden is covered, let's see during plus one tap, basically the garden is from zero to the end, if the size is five, then the garden is ours. It is from zero to five and each index is a t...
Minimum Number of Taps to Open to Water a Garden
sum-of-floored-pairs
There is a one-dimensional garden on the x-axis. The garden starts at the point `0` and ends at the point `n`. (i.e The length of the garden is `n`). There are `n + 1` taps located at points `[0, 1, ..., n]` in the garden. Given an integer `n` and an integer array `ranges` of length `n + 1` where `ranges[i]` (0-index...
Find the frequency (number of occurrences) of all elements in the array. For each element, iterate through its multiples and multiply frequencies to find the answer.
Array,Math,Binary Search,Prefix Sum
Hard
null
1,486
my name is I am currently pursuing my bet degree from P School of Technology I am currently in my second semester and in my first semester I have donear some programming languages like Java JavaScript stml CSS to intermediate level and I'm currently solving some DSS DSA problem um in lead code and in this video I'm goi...
XOR Operation in an Array
find-the-distance-value-between-two-arrays
You are given an integer `n` and an integer `start`. Define an array `nums` where `nums[i] = start + 2 * i` (**0-indexed**) and `n == nums.length`. Return _the bitwise XOR of all elements of_ `nums`. **Example 1:** **Input:** n = 5, start = 0 **Output:** 8 **Explanation:** Array nums is equal to \[0, 2, 4, 6, 8\] w...
Sort 'arr2' and use binary search to get the closest element for each 'arr1[i]', it gives a time complexity of O(nlogn).
Array,Two Pointers,Binary Search,Sorting
Easy
null
111
yo what's up my little coders let's solve today delete called question 111 minimum depth of binary tree here's the example which they give if that's the case we just return to because the minimum depth is equal to 2 right so 1 plus 1 is equal to 2 and we return 2. um let's code it first of all let's check for the base ...
Minimum Depth of Binary Tree
minimum-depth-of-binary-tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. **Note:** A leaf is a node with no children. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** 2 **Example 2:** **Input:** root = \[2...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
102,104
146
hello and welcome to another Elite code prom today we're going to be doing lru cash and so in this problem we're trying to design a data structure that follows the constraints of a least recently used cache and it's going to have a size it's going to have a get and a put where it get will get the value of the key if it...
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
969
in this video we will look at pancake sorting algorithm so as the name says we have to do sorting we will be given a list of numbers and our task will be to sort them and this has been asked in facebook amazon microsoft and uber interviews so let's see an example so here we will be given one input array or list and the...
Pancake Sorting
number-of-recent-calls
Given an array of integers `arr`, sort the array by performing a series of **pancake flips**. In one pancake flip we do the following steps: * Choose an integer `k` where `1 <= k <= arr.length`. * Reverse the sub-array `arr[0...k-1]` (**0-indexed**). For example, if `arr = [3,2,1,4]` and we performed a pancake f...
null
Design,Queue,Data Stream
Easy
null
1,863
welcome ladies and gentlemen boys and girls today we're going to solve another coolest question which is sum of all subjects x or totals okay so basically what the question is saying if you look at over here they're saying like the extraordinary of an array is defined as a bitwise xor okay of all its element or zero if...
Sum of All Subset XOR Totals
sum-of-all-subset-xor-totals
The **XOR total** of an array is defined as the bitwise `XOR` of **all its elements**, or `0` if the array is **empty**. * For example, the **XOR total** of the array `[2,5,6]` is `2 XOR 5 XOR 6 = 1`. Given an array `nums`, return _the **sum** of all **XOR totals** for every **subset** of_ `nums`. **Note:** Subset...
null
null
Easy
null
104
when it comes to Binary trees more than a problem this is much more of a concept in itself so you're given a binary tree with a root right and you have to find me the maximum depth of a certain node right so this tree would have certain parts right from the root to all of the leaf nodes correct and you have to determin...
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
292
everyone this is programmer Mitch hope you're enjoying your last hour today with daylight savings day we're gonna do leak code number 292 which is MIM game it's got 147 likes 567 dislikes this will be a short one is kind of a blink and you miss if you're prepping for interview questions with this twitch stream I don't ...
Nim Game
nim-game
You are playing the following Nim Game with your friend: * Initially, there is a heap of stones on the table. * You and your friend will alternate taking turns, and **you go first**. * On each turn, the person whose turn it is will remove 1 to 3 stones from the heap. * The one who removes the last stone is the...
If there are 5 stones in the heap, could you figure out a way to remove the stones such that you will always be the winner?
Math,Brainteaser,Game Theory
Easy
294
211
Hello everyone welcome to my channel with Mike, so today we are going to see question number five of our data structure design playlist, medium level using an already used template, we have made a question from scratch, copy paste the code from the template and do it with this. A little bit will be solved, just the not...
Design Add and Search Words Data Structure
design-add-and-search-words-data-structure
Design a data structure that supports adding new words and finding if a string matches any previously added string. Implement the `WordDictionary` class: * `WordDictionary()` Initializes the object. * `void addWord(word)` Adds `word` to the data structure, it can be matched later. * `bool search(word)` Returns ...
You should be familiar with how a Trie works. If not, please work on this problem: Implement Trie (Prefix Tree) first.
String,Depth-First Search,Design,Trie
Medium
208,746
997
hey everybody this is Larry this is uh day 23 of delete code daily challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's poem and also uh yeah oh see the reason why I always sometimes click on here you are new to the channel is that there's uh you know this u...
Find the Town Judge
find-the-town-judge
In a town, there are `n` people labeled from `1` to `n`. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: 1. The town judge trusts nobody. 2. Everybody (except for the town judge) trusts the town judge. 3. There is exactly one person that satisfies properties **...
null
null
Easy
null
1,649
hi guys welcome to algorithms made easy today we will see the question create sorted array through instructions given integer array instructions you are asked to create a sorted array from the elements in it you start with an empty container and for each element from left and right in instructions insert that number in...
Create Sorted Array through Instructions
maximum-number-of-non-overlapping-subarrays-with-sum-equals-target
Given an integer array `instructions`, you are asked to create a sorted array from the elements in `instructions`. You start with an empty container `nums`. For each element from **left to right** in `instructions`, insert it into `nums`. The **cost** of each insertion is the **minimum** of the following: * The numb...
Keep track of prefix sums to quickly look up what subarray that sums "target" can be formed at each step of scanning the input array. It can be proved that greedily forming valid subarrays as soon as one is found is optimal.
Array,Hash Table,Greedy,Prefix Sum
Medium
null
142
hi everyone welcome back to the channel and today we install the group daily challenge problem number 142 linked list cycle two so it's a pretty straightforward problem so what half we do is we have to basically find out the node at which the cycling linked list starts from okay so what I'm going to do is I'm going to ...
Linked List Cycle II
linked-list-cycle-ii
Given the `head` of a linked list, return _the node where the cycle begins. If there is no cycle, return_ `null`. There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the `next` pointer. Internally, `pos` is used to denote the index of the node that ta...
null
Hash Table,Linked List,Two Pointers
Medium
141,287
389
hi guys now I'm going to solve the liquid problem find the difference uh it is an easy problem and we can solve this problem by using number of ways so this is the problem description uh in this programming description they have given like they are given two strings one string is s and the other string is e and the str...
Find the Difference
find-the-difference
You are given two strings `s` and `t`. String `t` is generated by random shuffling string `s` and then add one more letter at a random position. Return the letter that was added to `t`. **Example 1:** **Input:** s = "abcd ", t = "abcde " **Output:** "e " **Explanation:** 'e' is the letter that was added. **Exam...
null
Hash Table,String,Bit Manipulation,Sorting
Easy
136
292
hello everyone so in this video let us talk about a problem from lead code the problem name is name game so let's start so you're playing a game name that's your name game with your friend now initially there is a heap of stone in this game on the table now you and your friend will alternatively take turns and you go f...
Nim Game
nim-game
You are playing the following Nim Game with your friend: * Initially, there is a heap of stones on the table. * You and your friend will alternate taking turns, and **you go first**. * On each turn, the person whose turn it is will remove 1 to 3 stones from the heap. * The one who removes the last stone is the...
If there are 5 stones in the heap, could you figure out a way to remove the stones such that you will always be the winner?
Math,Brainteaser,Game Theory
Easy
294
847
hello everyone today we're going to be solving a programming question called the shortest path visiting unknowns this is a hard question and basically this question wants us to find the shortest path to visit all of the notes in a graph so over here I have an unweighted and undirected graph with the nodes 0 1 2 &amp; 3...
Shortest Path Visiting All Nodes
shortest-path-visiting-all-nodes
You have an undirected, connected graph of `n` nodes labeled from `0` to `n - 1`. You are given an array `graph` where `graph[i]` is a list of all the nodes connected with node `i` by an edge. Return _the length of the shortest path that visits every node_. You may start and stop at any node, you may revisit nodes mul...
null
null
Hard
null
528
hi all welcome back to cracking the fang interviews today we are going to be looking at lead code number 528 which is random pick with weight this is a very important problem and you can think of this problem as a random number generator which is very commonly used in software engineering and this problem again is popu...
Random Pick with Weight
swapping-nodes-in-a-linked-list
You are given a **0-indexed** array of positive integers `w` where `w[i]` describes the **weight** of the `ith` index. You need to implement the function `pickIndex()`, which **randomly** picks an index in the range `[0, w.length - 1]` (**inclusive**) and returns it. The **probability** of picking an index `i` is `w[i...
We can transform the linked list to an array this should ease things up After transforming the linked list to an array it becomes as easy as swapping two integers in an array then rebuilding the linked list
Linked List,Two Pointers
Medium
19,24,25
57
hey guys welcome back uh today we're going to be looking at insert interval which is a medium difficulty problem um so let's just look at the description you're given an array of non-overlapping you're given an array of non-overlapping you're given an array of non-overlapping intervals called intervals where intervals ...
Insert Interval
insert-interval
You are given an array of non-overlapping intervals `intervals` where `intervals[i] = [starti, endi]` represent the start and the end of the `ith` interval and `intervals` is sorted in ascending order by `starti`. You are also given an interval `newInterval = [start, end]` that represents the start and end of another i...
null
Array
Medium
56,715
1,928
hey everybody this is larry this is me going with q4 of the week of dubai weekly contest 56 minimum cost to reach destination in time so uh i feel really sad about this one because i knew how to do it and i tried in different ways but i was just being dumb to be honest um i really shot down this way earlier i had six w...
Minimum Cost to Reach Destination in Time
number-of-orders-in-the-backlog
There is a country of `n` cities numbered from `0` to `n - 1` where **all the cities are connected** by bi-directional roads. The roads are represented as a 2D integer array `edges` where `edges[i] = [xi, yi, timei]` denotes a road between cities `xi` and `yi` that takes `timei` minutes to travel. There may be multiple...
Store the backlog buy and sell orders in two heaps, the buy orders in a max heap by price and the sell orders in a min heap by price. Store the orders in batches and update the fields according to new incoming orders. Each batch should only take 1 "slot" in the heap.
Array,Heap (Priority Queue),Simulation
Medium
null
341
hey everybody this is Larry this is day 20th of the Friday well it is a Friday but the leco Friday daily challenge hit the like what Friday what am I talking about uh but yeah October 20th uh Leo daily challenge on the Friday uh I'm a little bit uh tired uh I say that a lot but uh my internet's a little bit slow today ...
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
137
okay so hello everyone this is L here and let us see the second question of our bit manipulation list today's question name is single number two and what's the difference from the last question we have done here is that each and every element here is repeating twice except one so we need to return that single element w...
Single Number II
single-number-ii
Given an integer array `nums` where every element appears **three times** except for one, which appears **exactly once**. _Find the single element and return it_. You must implement a solution with a linear runtime complexity and use only constant extra space. **Example 1:** **Input:** nums = \[2,2,3,2\] **Output:**...
null
Array,Bit Manipulation
Medium
136,260
1,335
Hi gas welcome and welcome back to my channel so today our problem is minimum difficulty office schedule so what is given to us in this problem statement what do we have to do here we have to schedule a list of jobs in these days ok and jobs depend here The date is main, if you want to work on a direct job, then what y...
Minimum Difficulty of a Job Schedule
maximum-candies-allocated-to-k-children
You want to schedule a list of jobs in `d` days. Jobs are dependent (i.e To work on the `ith` job, you have to finish all the jobs `j` where `0 <= j < i`). You have to finish **at least** one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the `d` days. The difficulty of a da...
For a fixed number of candies c, how can you check if each child can get c candies? Use binary search to find the maximum c as the answer.
Array,Binary Search
Medium
907,1886,2000,2027,2188,2294
886
Hello guys welcome back to take division in this video you will see the possible by partition problem wishes from list in day 27th challenge so let's not look at the problem statement the problem years but gives pain number five would like to positive way into Groups of a person like and not gone into liquidation like ...
Possible Bipartition
score-of-parentheses
We want to split a group of `n` people (labeled from `1` to `n`) into two groups of **any size**. Each person may dislike some other people, and they should not go into the same group. Given the integer `n` and the array `dislikes` where `dislikes[i] = [ai, bi]` indicates that the person labeled `ai` does not like the...
null
String,Stack
Medium
null
329
hey guys it's iran with another coding interview tutorial and this time we have longest increasing pass in a matrix it is able to delete code hard but as far as hard questions go it's more on the lighter side but if you couldn't solve this yourself don't worry it's a type of solutions that you only have to see once so ...
Longest Increasing Path in a Matrix
longest-increasing-path-in-a-matrix
Given an `m x n` integers `matrix`, return _the length of the longest increasing path in_ `matrix`. From each cell, you can either move in four directions: left, right, up, or down. You **may not** move **diagonally** or move **outside the boundary** (i.e., wrap-around is not allowed). **Example 1:** **Input:** matr...
null
Dynamic Programming,Depth-First Search,Breadth-First Search,Graph,Topological Sort,Memoization
Hard
null
706
hey everybody this is Larry this is day four probably of the Lego daily challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's problem and I don't know why my computer's loading so slow maybe I have to C some windows I don't know who knows how technology Works...
Design HashMap
design-hashmap
Design a HashMap without using any built-in hash table libraries. Implement the `MyHashMap` class: * `MyHashMap()` initializes the object with an empty map. * `void put(int key, int value)` inserts a `(key, value)` pair into the HashMap. If the `key` already exists in the map, update the corresponding `value`. * ...
null
null
Easy
null
55
Hi gas welcome and welcome back to my channel so today our problem is jump game so what have you given us in this problem statement, here we have been given a name by the name and here you have been told that man lo or you No, it is on the first index. Okay, your position is on the first index and whatever value is the...
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
1,887
Hello everyone welcome to my channel Kodasari with me, so today we are going to do video number 68 of our playlist. It is marked medium but it is very easy, it was made very quickly, I too had this question and I am sure you guys will also make it. Lead code number 18 87 Okay the name of the question is Reduction Opera...
Reduction Operations to Make the Array Elements Equal
minimum-degree-of-a-connected-trio-in-a-graph
Given an integer array `nums`, your goal is to make all elements in `nums` equal. To complete one operation, follow these steps: 1. Find the **largest** value in `nums`. Let its index be `i` (**0-indexed**) and its value be `largest`. If there are multiple elements with the largest value, pick the smallest `i`. 2. F...
Consider a trio with nodes u, v, and w. The degree of the trio is just degree(u) + degree(v) + degree(w) - 6. The -6 comes from subtracting the edges u-v, u-w, and v-w, which are counted twice each in the vertex degree calculation. To get the trios (u,v,w), you can iterate on u, then iterate on each w,v such that w and...
Graph
Hard
null
983
hey so welcome back and there's another daily code problem so today it was actually yet again a another uh cost optimization problem or a dynamic programming problem is a better term for it so yeah so basically what you're given is a set of days that you want to travel and so this is kind of the calendar year so or the...
Minimum Cost For Tickets
validate-stack-sequences
You have planned some train traveling one year in advance. The days of the year in which you will travel are given as an integer array `days`. Each day is an integer from `1` to `365`. Train tickets are sold in **three different ways**: * a **1-day** pass is sold for `costs[0]` dollars, * a **7-day** pass is sold...
null
Array,Stack,Simulation
Medium
null
1,528
to be very honest this is an easy problem to solve but I believe that this problem is asked in interviews because your interviewer wants to see how much of a concise solution that you can come up with because it is very simple to come up with a brute Source solution and a solution where you are iterating over every cha...
Shuffle String
kids-with-the-greatest-number-of-candies
You are given a string `s` and an integer array `indices` of the **same length**. The string `s` will be shuffled such that the character at the `ith` position moves to `indices[i]` in the shuffled string. Return _the shuffled string_. **Example 1:** **Input:** s = "codeleet ", `indices` = \[4,5,6,7,0,2,1,3\] **Out...
Use greedy approach. For each kid check if candies[i] + extraCandies ≥ maximum in Candies[i].
Array
Easy
null
1,830
hello everyone let's take a look at the code 1830 minimum number of operations to make string sorted it's the last question in the bi-weekly context the bi-weekly context the bi-weekly context and it's related to math so it's a pretty hard question i hope it will not being the interview question otherwise it will be to...
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
985
um hello so today we are going to do this problem called sum of even numbers after queries so the problem says uh this is part of Fleet code um daily challenge the problem says we get a an array for numbers and an array of queries and the queries contain both a value and an index and what we want to do with these is ba...
Sum of Even Numbers After Queries
bag-of-tokens
You are given an integer array `nums` and an array `queries` where `queries[i] = [vali, indexi]`. For each query `i`, first, apply `nums[indexi] = nums[indexi] + vali`, then print the sum of the even values of `nums`. Return _an integer array_ `answer` _where_ `answer[i]` _is the answer to the_ `ith` _query_. **Exam...
null
Array,Two Pointers,Greedy,Sorting
Medium
null
1,444
hey everybody this is Larry this is the last day right yay we made it friends the last day of the March Deco daily challenge hit the like button to subscribe and join me on Discord let me know what you think about this poem and uh yeah just we're gonna be I mean if you've been following along uh you know that my streak...
Number of Ways of Cutting a Pizza
number-of-steps-to-reduce-a-number-to-zero
Given a rectangular pizza represented as a `rows x cols` matrix containing the following characters: `'A'` (an apple) and `'.'` (empty cell) and given the integer `k`. You have to cut the pizza into `k` pieces using `k-1` cuts. For each cut you choose the direction: vertical or horizontal, then you choose a cut positi...
Simulate the process to get the final answer.
Math,Bit Manipulation
Easy
1303,2288
1,345
hello everyone so in this video let us talk about a problem from lead code that is a hard problem the problem name is jump game four so i've already made a video on jump game one jump game two and jump game three they are like a single video in all of the three jump games are already made so if you haven't like watched...
Jump Game IV
perform-string-shifts
Given an array of integers `arr`, you are initially positioned at the first index of the array. In one step you can jump from index `i` to index: * `i + 1` where: `i + 1 < arr.length`. * `i - 1` where: `i - 1 >= 0`. * `j` where: `arr[i] == arr[j]` and `i != j`. Return _the minimum number of steps_ to reach the...
Intuitively performing all shift operations is acceptable due to the constraints. You may notice that left shift cancels the right shift, so count the total left shift times (may be negative if the final result is right shift), and perform it once.
Array,Math,String
Easy
null
1,675
hey everybody this is larry this is me going with q4 of the weekly contest 217 uh minimized deviation in array um so this was a tricky problem um we're gonna go over this and then we'll do some minor quick code reviews and then um you know you could watch me still be live during the contest so hit the like button and s...
Minimize Deviation in Array
magnetic-force-between-two-balls
You are given an array `nums` of `n` positive integers. You can perform two types of operations on any element of the array any number of times: * If the element is **even**, **divide** it by `2`. * For example, if the array is `[1,2,3,4]`, then you can do this operation on the last element, and the array wil...
If you can place balls such that the answer is x then you can do it for y where y < x. Similarly if you cannot place balls such that the answer is x then you can do it for y where y > x. Binary search on the answer and greedily see if it is possible.
Array,Binary Search,Sorting
Medium
2188
1,662
hi python developers welcome to today's lead code daily number 1662 track F2 string arrays are equivalent so in this problem we are comparing the characters instead of the strings in the arrays or to say we only care the overall position of each of the characters not the position in the strings for example here this ch...
Check If Two String Arrays are Equivalent
minimum-numbers-of-function-calls-to-make-target-array
Given two string arrays `word1` and `word2`, return `true` _if the two arrays **represent** the same string, and_ `false` _otherwise._ A string is **represented** by an array if the array elements concatenated **in order** forms the string. **Example 1:** **Input:** word1 = \[ "ab ", "c "\], word2 = \[ "a ", "bc "...
Work backwards: try to go from nums to arr. You should try to divide by 2 as much as possible, but you can only divide by 2 if everything is even.
Array,Greedy
Medium
null
117
Hi guys welcome to take to live Nivedita and in this video we are going to solve populated next right points in its node to service problem is I have given you a cup binary tree and said here what is populated next point to Point to it Mix Right Noticed a Prisoner Next Flight Mode Next Point VS So what will we do with ...
Populating Next Right Pointers in Each Node II
populating-next-right-pointers-in-each-node-ii
Given a binary tree struct Node { int val; Node \*left; Node \*right; Node \*next; } Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to `NULL`. Initially, all next pointers are set to `NULL`. **Example 1:** **Input:** root = \[1,2,3...
null
Linked List,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
116
752
okay all right guys welcome to our channel code with sunny and in this video i will be again talking about the good problems of the lead code and the today our problem name is open the lock and the index number is 752 and the problem is of medium type problem delete code okay so actually i'm making this video after ver...
Open the Lock
ip-to-cidr
You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: `'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'`. The wheels can rotate freely and wrap around: for example we can turn `'9'` to be `'0'`, or `'0'` to be `'9'`. Each move consists of turning one wheel one slot. The lock initially starts...
Convert the ip addresses to and from (long) integers. You want to know what is the most addresses you can put in this block starting from the "start" ip, up to n. It is the smallest between the lowest bit of start and the highest bit of n. Then, repeat this process with a new start and n.
String,Bit Manipulation
Medium
93,468
43
Ok gas so today we will see multiply stream so this is what we have 2 inches and we have to return we have to produce the product which will also represent Naman so we have two problems if we look at us one problem is that whatever name first The name you are asking for, first we have to convert it into integer, then w...
Multiply Strings
multiply-strings
Given two non-negative integers `num1` and `num2` represented as strings, return the product of `num1` and `num2`, also represented as a string. **Note:** You must not use any built-in BigInteger library or convert the inputs to integer directly. **Example 1:** **Input:** num1 = "2", num2 = "3" **Output:** "6" **Ex...
null
Math,String,Simulation
Medium
2,66,67,415
925
hello everyone so in this video let us talk about one more easy problem from lead code the problem name is Long pressed name okay so you're given that your friend who is typing his name into a keyboard sometimes when we are typing a character C they type that particular key and it might get hold for a pretty long amoun...
Long Pressed Name
construct-binary-tree-from-preorder-and-postorder-traversal
Your friend is typing his `name` into a keyboard. Sometimes, when typing a character `c`, the key might get _long pressed_, and the character will be typed 1 or more times. You examine the `typed` characters of the keyboard. Return `True` if it is possible that it was your friends name, with some characters (possibly ...
null
Array,Hash Table,Divide and Conquer,Tree,Binary Tree
Medium
null
1,897
Hello friends welcome to my channel here solv code problems and prepared to the Cod interview today's problem number 18 97 redistribute characters to make all strings equal you given an array of strings words zero indexed in one operation pick two distinct indexes I and J their wordss of I is a nonempty sing and move a...
Redistribute Characters to Make All Strings Equal
maximize-palindrome-length-from-subsequences
You are given an array of strings `words` (**0-indexed**). In one operation, pick two **distinct** indices `i` and `j`, where `words[i]` is a non-empty string, and move **any** character from `words[i]` to **any** position in `words[j]`. Return `true` _if you can make **every** string in_ `words` _**equal** using **a...
Let's ignore the non-empty subsequence constraint. We can concatenate the two strings and find the largest palindromic subsequence with dynamic programming. Iterate through every pair of characters word1[i] and word2[j], and see if some palindrome begins with word1[i] and ends with word2[j]. This ensures that the subse...
String,Dynamic Programming
Hard
516
729
Hello friends to Jhal Ajay, welcome all of you to my YouTube channel Tier-3, in today's my YouTube channel Tier-3, in today's my YouTube channel Tier-3, in today's video there is a new question in the to-do list video there is a new question in the to-do list video there is a new question in the to-do list named MyCale...
My Calendar I
my-calendar-i
You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a **double booking**. A **double booking** happens when two events have some non-empty intersection (i.e., some moment is common to both events.). The event can be represented as a pair of integers `start...
Store the events as a sorted list of intervals. If none of the events conflict, then the new event can be added.
Design,Segment Tree,Ordered Set
Medium
731,732
946
hello everyone welcome to day 16th of march great code challenge and i hope all of you are having a great time the question that we have in today's validate stack sequences and the question itself says stacks so the approach that we will use to solve this question would be against tax to your surprise they've already s...
Validate Stack Sequences
smallest-range-ii
Given two integer arrays `pushed` and `popped` each with distinct values, return `true` _if this could have been the result of a sequence of push and pop operations on an initially empty stack, or_ `false` _otherwise._ **Example 1:** **Input:** pushed = \[1,2,3,4,5\], popped = \[4,5,3,2,1\] **Output:** true **Explana...
null
Array,Math,Greedy,Sorting
Medium
null
206
hey there guys it's cooper codes today we're going to be looking at the problem reversal link list in this video i'm going to be going over the iterative approach to solving this problem we're going to start by looking at some of the basic linked list concepts assuming that you've had light experience in linked list or...
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
55
when you first read this problem it feels like this is gonna involve some dynamic programming correct and to be very honest nobody actually likes dynamic programming so the good news is that this problem can be solved efficiently just by using the greedy approach and that's really wonderful so let's see what we can do ...
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
1,839
let's look at problem 18 39 long is the substring of all vowels in order so we are going to reach a solution based on the standard two pointer sliding window method so actually we practiced a number of similar problems following the same idea so here we will first look at the statement of the problem then we will analy...
Longest Substring Of All Vowels in Order
decode-xored-array
A string is considered **beautiful** if it satisfies the following conditions: * Each of the 5 English vowels (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`) must appear **at least once** in it. * The letters must be sorted in **alphabetical order** (i.e. all `'a'`s before `'e'`s, all `'e'`s before `'i'`s, etc.). For example...
Since that encoded[i] = arr[i] XOR arr[i+1], then arr[i+1] = encoded[i] XOR arr[i]. Iterate on i from beginning to end, and set arr[i+1] = encoded[i] XOR arr[i].
Array,Bit Manipulation
Easy
null
1,994
hey everybody this is larry this is me going with bi-weekly contest 60 me going with bi-weekly contest 60 me going with bi-weekly contest 60 number q4 the number of good subsets hit the like button hit the subscribe button join me in discord especially if you like contest problems and let me know what you think um so o...
The Number of Good Subsets
minimum-number-of-swaps-to-make-the-binary-string-alternating
You are given an integer array `nums`. We call a subset of `nums` **good** if its product can be represented as a product of one or more **distinct prime** numbers. * For example, if `nums = [1, 2, 3, 4]`: * `[2, 3]`, `[1, 2, 3]`, and `[1, 3]` are **good** subsets with products `6 = 2*3`, `6 = 2*3`, and `3 = 3...
Think about all valid strings of length n. Try to count the mismatched positions with each valid string of length n.
String,Greedy
Medium
null
215
Le code problem number 215 K largest element in the Inn array so this problem gives us a integer array called num and an integer K and we have to return the K largest element in the array and here it notes that it is the largest element in the solid in the sorted order and not the cave distinct element so what this is ...
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
212
this is larry this is day nine of the leeco daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's farm which is word search two huh seems like that's uh that's a sequel to the one that we just did was it two days ago three days ago um so yeah so not tha...
Word Search II
word-search-ii
Given an `m x n` `board` of characters and a list of strings `words`, return _all words on the board_. Each word must 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 in a word. **Exampl...
You would need to optimize your backtracking to pass the larger test. Could you stop backtracking earlier? If the current candidate does not exist in all words' prefix, you could stop backtracking immediately. What kind of data structure could answer such query efficiently? Does a hash table work? Why or why not? How a...
Array,String,Backtracking,Trie,Matrix
Hard
79,1022,1433
1,562
hey what's up guys this is john and today let's take a look at this lead code problem uh 1562 find latest group of size m so this is one of the weekly contest problem okay so i mean it's a medium but i to me i feel like it's more like bit medium hard at least i didn't solve this problem during this weekly contest you k...
Find Latest Group of Size M
people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list
Given an array `arr` that represents a permutation of numbers from `1` to `n`. You have a binary string of size `n` that initially has all its bits set to zero. At each step `i` (assuming both the binary string and `arr` are 1-indexed) from `1` to `n`, the bit at position `arr[i]` is set to `1`. You are also given an...
Use hashing to convert company names in numbers and then for each list check if this is a subset of any other list. In order to check if a list is a subset of another list, use two pointers technique to get a linear solution for this task. The total complexity will be O(n^2 * m) where n is the number of lists and m is ...
Array,Hash Table,String
Medium
null
1,519
hello welcome to JB's k-school we are hello welcome to JB's k-school we are hello welcome to JB's k-school we are going to talk about the daily question number of nodes in the stop tree with the same ladder um so if you see here um we will have three and then um zero is alphabet a and then if top three has same alphabe...
Number of Nodes in the Sub-Tree With the Same Label
minimum-subsequence-in-non-increasing-order
You are given a tree (i.e. a connected, undirected graph that has no cycles) consisting of `n` nodes numbered from `0` to `n - 1` and exactly `n - 1` `edges`. The **root** of the tree is the node `0`, and each node of the tree has **a label** which is a lower-case character given in the string `labels` (i.e. The node w...
Sort elements and take each element from the largest until accomplish the conditions.
Array,Greedy,Sorting
Easy
2316
377
hello everyone welcome back here is Vanessa and today we have a fascinating problem on our hands combination sum four so it's just one that allow us to dive deep into the words of dynamic programming so stick around and by the end of this video you will become a dynamic programming wizard so uh let's start by understan...
Combination Sum IV
combination-sum-iv
Given an array of **distinct** integers `nums` and a target integer `target`, return _the number of possible combinations that add up to_ `target`. The test cases are generated so that the answer can fit in a **32-bit** integer. **Example 1:** **Input:** nums = \[1,2,3\], target = 4 **Output:** 7 **Explanation:** Th...
null
Array,Dynamic Programming
Medium
39
1,047
foreign the problem name is remove all adjacent duplicate instead let us read a description what it says so you're given a string as consisting lower case English letters a duplicate removal consisting of choosing two adjacent and equal letters removing them okay let us in removing them we repeatedly make duplicate rem...
Remove All Adjacent Duplicates In String
maximize-sum-of-array-after-k-negations
You are given a string `s` consisting of lowercase English letters. A **duplicate removal** consists of choosing two **adjacent** and **equal** letters and removing them. We repeatedly make **duplicate removals** on `s` until we no longer can. Return _the final string after all such duplicate removals have been made_...
null
Array,Greedy,Sorting
Easy
2204
53
hello everyone in this video we are going to discuss the solution to the problem max zoom suburi the description says that given in integer n announce find the continuous every containing at least one number which has the largest sum and return it's some so we'll look at the example so the example is this we have to re...
Maximum Subarray
maximum-subarray
Given an integer array `nums`, find the subarray with the largest sum, and return _its sum_. **Example 1:** **Input:** nums = \[-2,1,-3,4,-1,2,1,-5,4\] **Output:** 6 **Explanation:** The subarray \[4,-1,2,1\] has the largest sum 6. **Example 2:** **Input:** nums = \[1\] **Output:** 1 **Explanation:** The subarray \...
null
Array,Divide and Conquer,Dynamic Programming
Easy
121,152,697,1020,1849,1893
1,415
hello so today we are going to look at this problem called k happy string of length n so the problem asks us to return the k happy string of length n such that a string is happy if it has these two conditions first the letters in the string are only a b and c and there are no adjacent letters that are equal as in for e...
The k-th Lexicographical String of All Happy Strings of Length n
students-and-examinations
A **happy string** is a string that: * consists only of letters of the set `['a', 'b', 'c']`. * `s[i] != s[i + 1]` for all values of `i` from `1` to `s.length - 1` (string is 1-indexed). For example, strings **"abc ", "ac ", "b "** and **"abcbabcbcb "** are all happy strings and strings **"aa ", "baa "** and **"a...
null
Database
Easy
null
43
the multiply strings problem on Lee code asks you to multiply two given strings representing non-negative integers here representing non-negative integers here representing non-negative integers here are three approaches to solve it you can use the Brute Force approach where you convert the input strings to integers pe...
Multiply Strings
multiply-strings
Given two non-negative integers `num1` and `num2` represented as strings, return the product of `num1` and `num2`, also represented as a string. **Note:** You must not use any built-in BigInteger library or convert the inputs to integer directly. **Example 1:** **Input:** num1 = "2", num2 = "3" **Output:** "6" **Ex...
null
Math,String,Simulation
Medium
2,66,67,415
798
so uh uh so uh uh so so up could you give us a chance oh love one day that's how you feel you win we should just is is i my so two please so you foreign uh this um so so so um oh so bye so oh so so so so so [Laughter] [Laughter] [Laughter] huh uh uh oh yes uh thank uh you
Smallest Rotation with Highest Score
transform-to-chessboard
You are given an array `nums`. You can rotate it by a non-negative integer `k` so that the array becomes `[nums[k], nums[k + 1], ... nums[nums.length - 1], nums[0], nums[1], ..., nums[k-1]]`. Afterward, any entries that are less than or equal to their index are worth one point. * For example, if we have `nums = [2,4...
null
Array,Math,Bit Manipulation,Matrix
Hard
null
139
hello everyone welcome back myself rahul so today we are going to solve a problem related to recursion so the problem name is word break so it's very simple problem let's go through the problem statement uh here we are given a string s and a dictionary of strings word dictionary we have to return true if s can be segme...
Word Break
word-break
Given a string `s` and a dictionary of strings `wordDict`, return `true` if `s` can be segmented into a space-separated sequence of one or more dictionary words. **Note** that the same word in the dictionary may be reused multiple times in the segmentation. **Example 1:** **Input:** s = "leetcode ", wordDict = \[ "...
null
Hash Table,String,Dynamic Programming,Trie,Memoization
Medium
140
312
200 Chanting With Another Problem In The Calling Series Welcome Guys Stress Problems For Best Payday Loans Guitar Level Problem Width Like Basu Many People Admit Quite Interesting Infection Let's Give In The Next 20 - And Prohibition Painted With The Numbers Next 20 - And Prohibition Painted With The Numbers Next 20 - ...
Burst Balloons
burst-balloons
You are given `n` balloons, indexed from `0` to `n - 1`. Each balloon is painted with a number on it represented by an array `nums`. You are asked to burst all the balloons. If you burst the `ith` balloon, you will get `nums[i - 1] * nums[i] * nums[i + 1]` coins. If `i - 1` or `i + 1` goes out of bounds of the array, ...
null
Array,Dynamic Programming
Hard
1042
203
so today we are looking at lead code number two zero three remove linked list elements so here we have a linked list one two six three four five six we wanna remove all the sixes from that linked list and return the link list if the value is not in the linked list we just go ahead and return whatever the link list is a...
Remove Linked List Elements
remove-linked-list-elements
Given the `head` of a linked list and an integer `val`, remove all the nodes of the linked list that has `Node.val == val`, and return _the new head_. **Example 1:** **Input:** head = \[1,2,6,3,4,5,6\], val = 6 **Output:** \[1,2,3,4,5\] **Example 2:** **Input:** head = \[\], val = 1 **Output:** \[\] **Example 3:**...
null
Linked List,Recursion
Easy
27,237,2216