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
76
it has been asked by Facebook Tik Tok Amazon lyt Google yendex Snapchat nagaro Adobe Airbnb LinkedIn Microsoft Apple Spotify Uber we can have let's quickly see what the problem says the problem is simply short and simple saying that we have two strings s and D of length M and N okay respectively uh just one thing in th...
Minimum Window Substring
minimum-window-substring
Given two strings `s` and `t` of lengths `m` and `n` respectively, return _the **minimum window**_ **_substring_** _of_ `s` _such that every character in_ `t` _(**including duplicates**) is included in the window_. If there is no such substring, return _the empty string_ `" "`. The testcases will be generated such tha...
Use two pointers to create a window of letters in S, which would have all the characters from T. Since you have to find the minimum window in S which has all the characters from T, you need to expand and contract the window using the two pointers and keep checking the window for all the characters. This approach is als...
Hash Table,String,Sliding Window
Hard
30,209,239,567,632,727
1,844
all right let's talk about replace all digits with characters so the idea is that you shift how many times after c so for example fight five times after a you get f and then there's a constraint it's guaranteed let your shift never exist z so the maximum for a is 25 a plus 25 is 26 right but for this is simple a right ...
Replace All Digits with Characters
maximum-number-of-balls-in-a-box
You are given a **0-indexed** string `s` that has lowercase English letters in its **even** indices and digits in its **odd** indices. There is a function `shift(c, x)`, where `c` is a character and `x` is a digit, that returns the `xth` character after `c`. * For example, `shift('a', 5) = 'f'` and `shift('x', 0) =...
Note that both lowLimit and highLimit are of small constraints so you can iterate on all nubmer between them You can simulate the boxes by counting for each box the number of balls with digit sum equal to that box number
Hash Table,Math,Counting
Easy
null
1,470
hi guys let's talk about a google interview question today the question is lead code 147 or shuffle the array uh it goes something like this given that a number consisting of two n elements in the form x 1 x 2 x 3 until x n y 1 y 2 y 3 so on until y n you have to return the array in the form x 1 y 1 x 2 y 2 x 3 y 3 and...
Shuffle the Array
tweet-counts-per-frequency
Given the array `nums` consisting of `2n` elements in the form `[x1,x2,...,xn,y1,y2,...,yn]`. _Return the array in the form_ `[x1,y1,x2,y2,...,xn,yn]`. **Example 1:** **Input:** nums = \[2,5,1,3,4,7\], n = 3 **Output:** \[2,3,5,4,1,7\] **Explanation:** Since x1\=2, x2\=5, x3\=1, y1\=3, y2\=4, y3\=7 then the answer ...
null
Hash Table,Binary Search,Design,Sorting,Ordered Set
Medium
null
489
hey everyone and welcome to another Elite code problem so today we're going to be doing problem number 489 robot room cleaner and it's a backtracking problem it's a hard one it's probably one of the hardest backtracking problems I've done um even if you know like backtracking there's a lot of annoying parts of this pro...
Robot Room Cleaner
kth-smallest-instructions
You are controlling a robot that is located somewhere in a room. The room is modeled as an `m x n` binary grid where `0` represents a wall and `1` represents an empty slot. The robot starts at an unknown location in the room that is guaranteed to be empty, and you do not have access to the grid, but you can move the r...
There are nCr(row + column, row) possible instructions to reach (row, column). Try building the instructions one step at a time. How many instructions start with "H", and how does this compare with k?
Array,Math,Dynamic Programming,Combinatorics
Hard
null
62
cool 62 unique paths will bite it's located on the top left corner over m-by-n great the robot can only move m-by-n great the robot can only move m-by-n great the robot can only move either down or right at any point in time well by trying to reach the bottom right corner and the grid how many possible unique paths are...
Unique Paths
unique-paths
There is a robot on an `m x n` grid. The robot is initially located at the **top-left corner** (i.e., `grid[0][0]`). The robot tries to move to the **bottom-right corner** (i.e., `grid[m - 1][n - 1]`). The robot can only move either down or right at any point in time. Given the two integers `m` and `n`, return _the nu...
null
Math,Dynamic Programming,Combinatorics
Medium
63,64,174,2192
1,732
welcome to code map today we are going to discuss daily record challenge find the highest altitude now let's discuss the question there is a biker going on a road trip the road trip consists of n plus one points at different altitudes the biker status strip at point zero with Attitude equal to zero you are given an int...
Find the Highest Altitude
minimum-one-bit-operations-to-make-integers-zero
There is a biker going on a road trip. The road trip consists of `n + 1` points at different altitudes. The biker starts his trip on point `0` with altitude equal `0`. You are given an integer array `gain` of length `n` where `gain[i]` is the **net gain in altitude** between points `i`​​​​​​ and `i + 1` for all (`0 <=...
The fastest way to convert n to zero is to remove all set bits starting from the leftmost one. Try some simple examples to learn the rule of how many steps are needed to remove one set bit. consider n=2^k case first, then solve for all n.
Dynamic Programming,Bit Manipulation,Memoization
Hard
2119
1,716
hello everyone today we are going to calculate money in lit code bank which is a problem which is a Del quing of today so uh basically what is happening is that you have a certain number of day which is the number of input n and then from that input you are supposed to compute the total amount that has been saved in th...
Calculate Money in Leetcode Bank
maximum-non-negative-product-in-a-matrix
Hercy wants to save money for his first car. He puts money in the Leetcode bank **every day**. He starts by putting in `$1` on Monday, the first day. Every day from Tuesday to Sunday, he will put in `$1` more than the day before. On every subsequent Monday, he will put in `$1` more than the **previous Monday**. Given...
Use Dynamic programming. Keep the highest value and lowest value you can achieve up to a point.
Array,Dynamic Programming,Matrix
Medium
null
201
Hello and welcome tool again this is Shaur Awasti and today we will talk about a medium level problem of lead code which is bit wise and of number range so basically what is in it, in this we are given left and right and what is we have to tell that in What will be the end of all, like suppose five and six and sane, wh...
Bitwise AND of Numbers Range
bitwise-and-of-numbers-range
Given two integers `left` and `right` that represent the range `[left, right]`, return _the bitwise AND of all numbers in this range, inclusive_. **Example 1:** **Input:** left = 5, right = 7 **Output:** 4 **Example 2:** **Input:** left = 0, right = 0 **Output:** 0 **Example 3:** **Input:** left = 1, right = 2147...
null
Bit Manipulation
Medium
null
1,961
um hello so today we are going to do this problem called check if string is a prefix of array so the problem says we get a string s and then array um of string words and we want to determine whether s is a prefix of strings of orders okay so we get s and then we get an array that is a string of words okay so this is ar...
Check If String Is a Prefix of Array
maximum-ice-cream-bars
Given a string `s` and an array of strings `words`, determine whether `s` is a **prefix string** of `words`. A string `s` is a **prefix string** of `words` if `s` can be made by concatenating the first `k` strings in `words` for some **positive** `k` no larger than `words.length`. Return `true` _if_ `s` _is a **prefi...
It is always optimal to buy the least expensive ice cream bar first. Sort the prices so that the cheapest ice cream bar comes first.
Array,Greedy,Sorting
Medium
null
1,650
hey this is josh from leak dev where we try to explain programming questions as simple and concise as we can today we'll be talking about the lowest common ancestor of a binary tree according to leed code this question has been asked quite frequently by facebook amazon microsoft and just from my own personal experience...
Lowest Common Ancestor of a Binary Tree III
find-root-of-n-ary-tree
Given two nodes of a binary tree `p` and `q`, return _their lowest common ancestor (LCA)_. Each node will have a reference to its parent node. The definition for `Node` is below: class Node { public int val; public Node left; public Node right; public Node parent; } According to the **[definition of ...
Node with indegree 0 is the root
Hash Table,Bit Manipulation,Tree,Depth-First Search
Medium
1655
103
hello everyone welcome to coding decoded my name isja I'm working at sd5 at Adobe and after a very long time I have come on to creating a new video because uh all the questions in the month of February seems like an easy question and most of them were already solved by me already and for those who were not I believe th...
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
119
welcome to august leeco challenge today's problem is pascal's triangle two given the non-negative index k we turn given the non-negative index k we turn given the non-negative index k we turn the kth index of a pascal's triangle is represented nicely in this graphic where every row has one more cell than its previous r...
Pascal's Triangle II
pascals-triangle-ii
Given an integer `rowIndex`, return the `rowIndexth` (**0-indexed**) row of the **Pascal's triangle**. In **Pascal's triangle**, each number is the sum of the two numbers directly above it as shown: **Example 1:** **Input:** rowIndex = 3 **Output:** \[1,3,3,1\] **Example 2:** **Input:** rowIndex = 0 **Output:** \[...
null
Array,Dynamic Programming
Easy
118,2324
438
Hello Hi Everyone Jasmine Chakraborty And Today Will Be Discussing Problem Number 1434 Let Code Find All Programs In History 109 This Is A Problem Dentist In Bittu Of Every Day I Am Not Challenge In Its Food Should You To Problem Avoid Yesterday I Want From You Can Be Sent out from Play List to Play List Soe Hind is th...
Find All Anagrams in a String
find-all-anagrams-in-a-string
Given two strings `s` and `p`, return _an array of all the start indices of_ `p`_'s anagrams in_ `s`. You may return the answer in **any order**. An **Anagram** is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. **Example 1:** *...
null
Hash Table,String,Sliding Window
Medium
242,567
103
hey everyone welcome back to the channel i hope you guys are doing extremely well so today we will be discussing the zigzag traversal from the frika tree series now what does this traversal means so in the previous traversal that is the level order traversal you saw that the traversal was like one two three then a four...
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,812
hello guys my name is Ursula and welcome back to my channel and today we are going to solve a new lead code question that is determined color of a chessboard Square we will be solving this question with the help of python the question said you are given coordinates a string that represents the coordinates of a square o...
Determine Color of a Chessboard Square
reformat-phone-number
You are given `coordinates`, a string that represents the coordinates of a square of the chessboard. Below is a chessboard for your reference. Return `true` _if the square is white, and_ `false` _if the square is black_. The coordinate will always represent a valid chessboard square. The coordinate will always have t...
Discard all the spaces and dashes. Use a while loop. While the string still has digits, check its length and see which rule to apply.
String
Easy
null
374
hello everyone welcome to kodus camp we are 12th day of october lead code challenge and the problem we are going to cover in this video is guess number higher or lower it is again a easy category problems the input given here is an integer value n and we have to return the number we picked so the problem statement has ...
Guess Number Higher or Lower
guess-number-higher-or-lower
We are playing the Guess Game. The game is as follows: I pick a number from `1` to `n`. You have to guess which number I picked. Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess. You call a pre-defined API `int guess(int num)`, which returns three possible re...
null
Binary Search,Interactive
Easy
278,375,658
1,799
hey everyone welcome back and let's write some more neat code today so today let's solve the problem maximize score after n operations this one is pretty hard but it's not as crazy as you might think and if you're not super familiar with bit masks this is an opportunity to learn a bit about them no pun intended but we ...
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
34
A high-rise So friend, today we will make a playlist of binary search A high-rise So friend, today we will make a playlist of binary search A high-rise So friend, today we will make a playlist of binary search and this video of binary search is going to be made. Okay, the question is medium. The question on the list is...
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
881
welcome to january's leeco challenge today's problem is boats to save people classic problem the eighth person has weight people eye and each boat can carry a max weight of limit now each boat carries at most two people at the same time provide the sum of the weight of those two people is at most limit return the minim...
Boats to Save People
loud-and-rich
You are given an array `people` where `people[i]` is the weight of the `ith` person, and an **infinite number of boats** where each boat can carry a maximum weight of `limit`. Each boat carries at most two people at the same time, provided the sum of the weight of those people is at most `limit`. Return _the minimum n...
null
Array,Depth-First Search,Graph,Topological Sort
Medium
null
16
hey everyone in this video we are going to solve the three sum closest problem in lead code it is similar to the threesome problem which we solved previously the only difference is instead of checking if the sum is equal to zero we have to check if it is if the sum of those three numbers is closest to a target number s...
3Sum Closest
3sum-closest
Given an integer array `nums` of length `n` and an integer `target`, find three integers in `nums` such that the sum is closest to `target`. Return _the sum of the three integers_. You may assume that each input would have exactly one solution. **Example 1:** **Input:** nums = \[-1,2,1,-4\], target = 1 **Output:** ...
null
Array,Two Pointers,Sorting
Medium
15,259
17
hello everyone let's look at letter combinations of a phone number the problem statement is we are giving a string containing digits from two to none inclusive return all possible letter combinations now the number could represent written answer in any order a mapping of a digit to letters look looks like below the que...
Letter Combinations of a Phone Number
letter-combinations-of-a-phone-number
Given a string containing digits from `2-9` inclusive, return all possible letter combinations that the number could represent. Return the answer in **any order**. A mapping of digits to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. **Example 1:** **Input:** di...
null
Hash Table,String,Backtracking
Medium
22,39,401
1,186
and welcome back to the cracking Fang YouTube channel today we're solving lead code problem 1,186 maximum subarray sum with one 1,186 maximum subarray sum with one 1,186 maximum subarray sum with one deletion given an array of integers return the maximum sum for a non-empty return the maximum sum for a non-empty return...
Maximum Subarray Sum with One Deletion
building-h2o
Given an array of integers, return the maximum sum for a **non-empty** subarray (contiguous elements) with at most one element deletion. In other words, you want to choose a subarray and optionally delete one element from it so that there is still at least one element left and the sum of the remaining elements is maxim...
null
Concurrency
Medium
null
1,094
hey guys welcome back to another video and today we're going to be solving the leakout question carpooling all right so in this question we're driving a vehicle that has capacity empty seats initially available for passengers the vehicle only drives east and it cannot turn around and drive the other direction so in oth...
Car Pooling
matrix-cells-in-distance-order
There is a car with `capacity` empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west). You are given the integer `capacity` and an array `trips` where `trips[i] = [numPassengersi, fromi, toi]` indicates that the `ith` trip has `numPassengersi` passengers and the locations to pick them u...
null
Array,Math,Geometry,Sorting,Matrix
Easy
2304
740
hey so welcome back this is another daily problem so today it's called delete and earn and it's a medium level dynamic programming problem and so essentially you're just given a array called nums here and you're playing a game where you want to get the maximum number of points and the way this game works and I'm kind o...
Delete and Earn
delete-and-earn
You are given an integer array `nums`. You want to maximize the number of points you get by performing the following operation any number of times: * Pick any `nums[i]` and delete it to earn `nums[i]` points. Afterwards, you must delete **every** element equal to `nums[i] - 1` and **every** element equal to `nums[i]...
If you take a number, you might as well take them all. Keep track of what the value is of the subset of the input with maximum M when you either take or don't take M.
Array,Hash Table,Dynamic Programming
Medium
198
1,897
the question is resistible characters to make old strings equal you are given an array of things worth zero in text in one operation with two distinct indices I and J where sub I is a known MD string and move any character from WhatsApp I to any position in WhatsApp J return true if you can make any string in words equ...
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
328
hello everybody today we'll be taking a look at odd even linked list on the code it is problem number 328 so let's take a look 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 t...
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
316
welcome to october's lee code challenge today's problem is remove duplicate letters given a string 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 say we're given the string bc abc our smallest le...
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
76
minimum window substring is a sliding window problem asked at facebook amazon microsoft lyft google linkedin apple bloomberg this problem is definitely hard so get your thinking cap on and let's get into it for this problem we are given two strings and we need to return the minimum window in string s that will contain ...
Minimum Window Substring
minimum-window-substring
Given two strings `s` and `t` of lengths `m` and `n` respectively, return _the **minimum window**_ **_substring_** _of_ `s` _such that every character in_ `t` _(**including duplicates**) is included in the window_. If there is no such substring, return _the empty string_ `" "`. The testcases will be generated such tha...
Use two pointers to create a window of letters in S, which would have all the characters from T. Since you have to find the minimum window in S which has all the characters from T, you need to expand and contract the window using the two pointers and keep checking the window for all the characters. This approach is als...
Hash Table,String,Sliding Window
Hard
30,209,239,567,632,727
39
welcome to leak codes blind crate 75 where I'll be solving the top 75 leak code questions this question is called combination some and it's a pretty standard problem that you will probably see in your coding journey here's the problem given a set of candidate numbers with out duplicates and a target number find all the...
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
344
hey guys persistent programmer here and welcome to my channel so if you're new here we solve a lot of problems on this channel and today we're gonna be looking at the reverse string problem so this is a really interesting problem when you use the two pointer solution to solve it and that's exactly what we will be doing...
Reverse String
reverse-string
Write a function that reverses a string. The input string is given as an array of characters `s`. You must do this by modifying the input array [in-place](https://en.wikipedia.org/wiki/In-place_algorithm) with `O(1)` extra memory. **Example 1:** **Input:** s = \["h","e","l","l","o"\] **Output:** \["o","l","l","e","h...
The entire logic for reversing a string is based on using the opposite directional two-pointer approach!
Two Pointers,String,Recursion
Easy
345,541
839
Hello everyone welcome to me channel 22 going to lead code number 839 D question if you understand this is the question of DFS and Buffs have to see from my playlist of graph concept sir questions na date playlist is the name of very important question Similar string group ok if you had to write BF in the graph then yo...
Similar String Groups
short-encoding-of-words
Two strings `X` and `Y` are similar if we can swap two letters (in different positions) of `X`, so that it equals `Y`. Also two strings `X` and `Y` are similar if they are equal. For example, `"tars "` and `"rats "` are similar (swapping at positions `0` and `2`), and `"rats "` and `"arts "` are similar, but `"star "`...
null
Array,Hash Table,String,Trie
Medium
null
1,233
come to my channel so in this video i'm going to cover two things the first thing is we should cover uh the solution to this problem and then we are going to do some coding work and the second one i'm going to cover the general procedure to follow in the coding interview briefly so before we start the real content for ...
Remove Sub-Folders from the Filesystem
number-of-ships-in-a-rectangle
Given a list of folders `folder`, return _the folders after removing all **sub-folders** in those folders_. You may return the answer in **any order**. If a `folder[i]` is located within another `folder[j]`, it is called a **sub-folder** of it. The format of a path is one or more concatenated strings of the form: `'/...
Use divide and conquer technique. Divide the query rectangle into 4 rectangles. Use recursion to continue with the rectangles that has ships only.
Array,Divide and Conquer,Interactive
Hard
null
146
hi i'm ali today i want to talk about another important interview question this question is called lru cache and it's a bit different from other problems that we have solved till now in this problem we have to design a data structure and then implement it this is among one of the most popular interview questions in lot...
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
1,423
hello guys welcome to algorithms made easy my name is rajat and today we will be discussing the question maximum points you can obtain from cards in this question we are given several cards arranged in a row and each card has an associated number of points the points are given in the integer array in one step we can ta...
Maximum Points You Can Obtain from Cards
maximum-number-of-occurrences-of-a-substring
There are several cards **arranged in a row**, and each card has an associated number of points. The points are given in the integer array `cardPoints`. In one step, you can take one card from the beginning or from the end of the row. You have to take exactly `k` cards. Your score is the sum of the points of the card...
Check out the constraints, (maxSize <=26). This means you can explore all substrings in O(n * 26). Find the Maximum Number of Occurrences of a Substring with bruteforce.
Hash Table,String,Sliding Window
Medium
null
125
everyone how are you today we are going to solve problem number 125 which is valid palindrome so what they are asking is you have to find a valid palindrome now what is a palindrome is something when you reverse a string the string remains same for example ABA so if you reverse this string it is same and now this right...
Valid Palindrome
valid-palindrome
A phrase is a **palindrome** if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. Given a string `s`, return `true` _if it is a **palindrome**, or_ `false` _otherwise_...
null
Two Pointers,String
Easy
234,680,2130,2231
342
hey everyone today we are going to solve theal question power all four okay I think we can solve this question with bitwise operation like this so this is a one time but in real interviews I've never seen someone who solved the question with bitwise operations so I'll show you another way instead of bitwise operation I...
Power of Four
power-of-four
Given an integer `n`, return _`true` if it is a power of four. Otherwise, return `false`_. An integer `n` is a power of four, if there exists an integer `x` such that `n == 4x`. **Example 1:** **Input:** n = 16 **Output:** true **Example 2:** **Input:** n = 5 **Output:** false **Example 3:** **Input:** n = 1 **O...
null
Math,Bit Manipulation,Recursion
Easy
231,326
1,025
hello everyone welcome back again to Li Kui today we're here with a very interesting problem called de visa game this problem is very famous in companies such as Google and Microsoft so we will be going through a series of solution solving this problem initially we will start with a simple naive recursive problem then ...
Divisor Game
minimum-cost-for-tickets
Alice and Bob take turns playing a game, with Alice starting first. Initially, there is a number `n` on the chalkboard. On each player's turn, that player makes a move consisting of: * Choosing any `x` with `0 < x < n` and `n % x == 0`. * Replacing the number `n` on the chalkboard with `n - x`. Also, if a player...
null
Array,Dynamic Programming
Medium
322
1,482
hello hi everyone loot do it president pimi numbers elements of porn of oo loot it is the garden and number aadhaar number of dangers lu 2012 novel in two and objective sarat2 bane 550 two To to a significant boiled only then at once first class 10th explain this question to you with the help of Punjab new that you und...
Minimum Number of Days to Make m Bouquets
how-many-numbers-are-smaller-than-the-current-number
You are given an integer array `bloomDay`, an integer `m` and an integer `k`. You want to make `m` bouquets. To make a bouquet, you need to use `k` **adjacent flowers** from the garden. The garden consists of `n` flowers, the `ith` flower will bloom in the `bloomDay[i]` and then can be used in **exactly one** bouquet...
Brute force for each array element. In order to improve the time complexity, we can sort the array and get the answer for each array element.
Array,Hash Table,Sorting,Counting
Easy
315
456
To Ajay, when you go to ribbon and decide compounding, today we are going to ask this question 132 patterns, what to do on 21, you will get a number in this question, you have to identify whether there is 132 pattern on it or not, if there is 132 pattern on it. If it is on this one, then you simply make a different one...
132 Pattern
132-pattern
Given an array of `n` integers `nums`, a **132 pattern** is a subsequence of three integers `nums[i]`, `nums[j]` and `nums[k]` such that `i < j < k` and `nums[i] < nums[k] < nums[j]`. Return `true` _if there is a **132 pattern** in_ `nums`_, otherwise, return_ `false`_._ **Example 1:** **Input:** nums = \[1,2,3,4\] ...
null
Array,Binary Search,Stack,Monotonic Stack,Ordered Set
Medium
null
232
this question asks you to implement a queue using stacks so let's make sure we understand the fundamentals before we start solving this a stack follows the lethal structure which is last in first out so if i have a stack it will look something like this and if i'm going to add values let's say i'm going to add a b and ...
Implement Queue using Stacks
implement-queue-using-stacks
Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (`push`, `peek`, `pop`, and `empty`). Implement the `MyQueue` class: * `void push(int x)` Pushes element x to the back of the queue. * `int pop()` Removes the element from th...
null
Stack,Design,Queue
Easy
225
113
Hey Gas, today we will do question number 11 of our Bin Entry Play List Okay, some variations have been asked in Google like Path Sam Tu whatever is okay, this has been asked to the company till now Right here, today we are solving the question 'Sam Tu', the Right here, today we are solving the question 'Sam Tu', the R...
Path Sum II
path-sum-ii
Given the `root` of a binary tree and an integer `targetSum`, return _all **root-to-leaf** paths where the sum of the node values in the path equals_ `targetSum`_. Each path should be returned as a list of the node **values**, not node references_. A **root-to-leaf** path is a path starting from the root and ending at...
null
Backtracking,Tree,Depth-First Search,Binary Tree
Medium
112,257,437,666,2217
149
hello guys today we are moving through the question max point on a line from lead code in the given problem we have given an array consisting of end point for each point is represented by the intercept on the x axis and y axis as x and y and we have to return maximum number of point on any particular line if we match e...
Max Points on a Line
max-points-on-a-line
Given an array of `points` where `points[i] = [xi, yi]` represents a point on the **X-Y** plane, return _the maximum number of points that lie on the same straight line_. **Example 1:** **Input:** points = \[\[1,1\],\[2,2\],\[3,3\]\] **Output:** 3 **Example 2:** **Input:** points = \[\[1,1\],\[3,2\],\[5,3\],\[4,1\]...
null
Array,Hash Table,Math,Geometry
Hard
356,2287
328
hey everyone welcome back to my channel before we get started don't forget to click the Subscribe button if you want more videos about coding interview so in this video we'll be solving the problem lead called odd ever linked list so let's get started so the problem is that they give us a singular linked list and they ...
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
66
hello everyone so let us solve one more problem from lead code the problem name is plus one so the problem goes like this that you're given a large integer represented as an integer array digits where each digit i is the eighth digit to the integer now the digits i ordered from the most significant or least significant...
Plus One
plus-one
You are given a **large integer** represented as an integer array `digits`, where each `digits[i]` is the `ith` digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading `0`'s. Increment the large integer by one and re...
null
Array,Math
Easy
43,67,369,1031
739
hey everyone welcome back and let's write some more neat code today so today let's solve a problem daily temperatures we are just given an array of integers which represent temperatures and we want to return an array answer such that at every single position in answer it's going to be the same exact size as our tempera...
Daily Temperatures
daily-temperatures
Given an array of integers `temperatures` represents the daily temperatures, return _an array_ `answer` _such that_ `answer[i]` _is the number of days you have to wait after the_ `ith` _day to get a warmer temperature_. If there is no future day for which this is possible, keep `answer[i] == 0` instead. **Example 1:**...
If the temperature is say, 70 today, then in the future a warmer temperature must be either 71, 72, 73, ..., 99, or 100. We could remember when all of them occur next.
Array,Stack,Monotonic Stack
Medium
496,937
231
hey guys today we will be solving the problem 231 power of two so in this problem what is given is like given an integer n uh return true if the power of it is a power of two otherwise return Force so what they are saying that n is an integer we need to check if n is an power of two we need to return true otherwise fal...
Power of Two
power-of-two
Given an integer `n`, return _`true` if it is a power of two. Otherwise, return `false`_. An integer `n` is a power of two, if there exists an integer `x` such that `n == 2x`. **Example 1:** **Input:** n = 1 **Output:** true **Explanation:** 20 = 1 **Example 2:** **Input:** n = 16 **Output:** true **Explanation:**...
null
Math,Bit Manipulation,Recursion
Easy
191,326,342
5
That a hello hi guys so all doing fine welcome back to the video english video bp looking and another list to problem name dance red chilli powder mixing stomach set given string gas follow on this internet substring in s u majumdar do maximum laptop testis 100 examples where Given year deposit example tabs follow room...
Longest Palindromic Substring
longest-palindromic-substring
Given a string `s`, return _the longest_ _palindromic_ _substring_ in `s`. **Example 1:** **Input:** s = "babad " **Output:** "bab " **Explanation:** "aba " is also a valid answer. **Example 2:** **Input:** s = "cbbd " **Output:** "bb " **Constraints:** * `1 <= s.length <= 1000` * `s` consist of only dig...
How can we reuse a previously computed palindrome to compute a larger palindrome? If “aba” is a palindrome, is “xabax” a palindrome? Similarly is “xabay” a palindrome? Complexity based hint: If we use brute-force and check whether for every start and end position a substring is a palindrome we have O(n^2) start - end ...
String,Dynamic Programming
Medium
214,266,336,516,647
139
hello everyone in this lecture i am going to explain you about what break so here in this question they given a string s and dish and dictionary of strings what dictionary written true if s can be segmented into space separated sequence of one or more dictionary words note that the same word is the dictionary may be re...
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
1,808
hey what's up guys uh this is sean here so today uh 1808 maximize number of nice divisors uh this one you know okay so give me like a positive integer prime factors and so basically we need to find an integer and that you know that satisfies the following condition you know so the first one is this one so the number of...
Maximize Number of Nice Divisors
stone-game-vii
You are given a positive integer `primeFactors`. You are asked to construct a positive integer `n` that satisfies the following conditions: * The number of prime factors of `n` (not necessarily distinct) is **at most** `primeFactors`. * The number of nice divisors of `n` is maximized. Note that a divisor of `n` is...
The constraints are small enough for an N^2 solution. Try using dynamic programming.
Array,Math,Dynamic Programming,Game Theory
Medium
909,1240,1522,1617,1685,1788,1896,2002,2156
35
hello guys uh i am the casper flaw from pt web 4 here i am to learn about binary search let's learn it through an example the question of later so as we know in linear size the time complexity of the algorithm is in order of n so in order to reduce time complexity we apply binary search here time complexity is as you c...
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
343
Hello everyone welcome to my channel code sorry with mike so today we are going to do video number 66 of our dynamic programming playlist ok and today's question is lead code number 343 is medium mark but this question can be made in a very easy way ok It will be a very simple code to understand. The question is also q...
Integer Break
integer-break
Given an integer `n`, break it into the sum of `k` **positive integers**, where `k >= 2`, and maximize the product of those integers. Return _the maximum product you can get_. **Example 1:** **Input:** n = 2 **Output:** 1 **Explanation:** 2 = 1 + 1, 1 \* 1 = 1. **Example 2:** **Input:** n = 10 **Output:** 36 **Exp...
There is a simple O(n) solution to this problem. You may check the breaking results of n ranging from 7 to 10 to discover the regularities.
Math,Dynamic Programming
Medium
1936
1,791
hello everyone so today's problem is find center of the star graph so it's an easy lead code problem so let's see how we can solve this so the question is there is an undirected star graph consisting of end nodes labeled from 1 to n a star graph is a graph where there is one Center node and exactly n minus 1 edges that...
Find Center of Star Graph
richest-customer-wealth
There is an undirected **star** graph consisting of `n` nodes labeled from `1` to `n`. A star graph is a graph where there is one **center** node and **exactly** `n - 1` edges that connect the center node with every other node. You are given a 2D integer array `edges` where each `edges[i] = [ui, vi]` indicates that th...
Calculate the wealth of each customer Find the maximum element in array.
Array,Matrix
Easy
null
452
hey guys welcome back to another video and today we're going to be solving the lee code question minimum number of arrows to burst balloons all right so in this question there are spherical balloons spread in a two-dimensional space for each in a two-dimensional space for each in a two-dimensional space for each balloo...
Minimum Number of Arrows to Burst Balloons
minimum-number-of-arrows-to-burst-balloons
There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array `points` where `points[i] = [xstart, xend]` denotes a balloon whose **horizontal diameter** stretches between `xstart` and `xend`. You do not know the exact y-coordinates of the ball...
null
Array,Greedy,Sorting
Medium
253,435
255
hey what's up engineers today we're doing question number 255 verify pre-order sequence in a binary search pre-order sequence in a binary search pre-order sequence in a binary search tree before you continue please check the description because if there's anything incorrect in this video i'll be making those correction...
Verify Preorder Sequence in Binary Search Tree
verify-preorder-sequence-in-binary-search-tree
Given an array of **unique** integers `preorder`, return `true` _if it is the correct preorder traversal sequence of a binary search tree_. **Example 1:** **Input:** preorder = \[5,2,1,3,6\] **Output:** true **Example 2:** **Input:** preorder = \[5,2,6,1,3\] **Output:** false **Constraints:** * `1 <= preorder.l...
null
Stack,Tree,Binary Search Tree,Recursion,Monotonic Stack,Binary Tree
Medium
144
1,492
hi everyone welcome to lead code daily challenge so the problem for today is to find the kth factor of a given number n so we will be given two positive integers l and k we need to find the kth factor of the given number n so the given integer n so as you know the factor is uh how do we define a factor so if the number...
The kth Factor of n
time-needed-to-inform-all-employees
You are given two positive integers `n` and `k`. A factor of an integer `n` is defined as an integer `i` where `n % i == 0`. Consider a list of all factors of `n` sorted in **ascending order**, return _the_ `kth` _factor_ in this list or return `-1` if `n` has less than `k` factors. **Example 1:** **Input:** n = 12,...
The company can be represented as a tree, headID is always the root. Store for each node the time needed to be informed of the news. Answer is the max time a leaf node needs to be informed.
Tree,Depth-First Search,Breadth-First Search
Medium
104,124
468
all right so this question is validated IP address so in this question you are giving the string query IP so you either return ipv4 or IPv6 and if both are links are not true then you return neither so ipv4 is this function so it's starting from 0 to 100 to 255. and the X you know the X represents the you know the stri...
Validate IP Address
validate-ip-address
Given a string `queryIP`, return `"IPv4 "` if IP is a valid IPv4 address, `"IPv6 "` if IP is a valid IPv6 address or `"Neither "` if IP is not a correct IP of any type. **A valid IPv4** address is an IP in the form `"x1.x2.x3.x4 "` where `0 <= xi <= 255` and `xi` **cannot contain** leading zeros. For example, `"192.16...
null
String
Medium
752
322
Hello guys welcome to disrespect video andar only coding and horses bihar assembly problem that is gold coin change and where given point of different denominations and total amount of money amount friday function to compute the furious number of the journey to make update amount is the volume An Incident - One Which M...
Coin Change
coin-change
You are given an integer array `coins` representing coins of different denominations and an integer `amount` representing a total amount of money. Return _the fewest number of coins that you need to make up that amount_. If that amount of money cannot be made up by any combination of the coins, return `-1`. You may a...
null
Array,Dynamic Programming,Breadth-First Search
Medium
1025,1393,2345
825
okay so lead code practice time so the question is friends of appropriate ages so the two goals the first one is to see how to solve this problem then we are going to put some code here and the second one is to see how to solve this problem in the real interview so let's get started so remember the first step in the re...
Friends Of Appropriate Ages
max-increase-to-keep-city-skyline
There are `n` persons on a social media website. You are given an integer array `ages` where `ages[i]` is the age of the `ith` person. A Person `x` will not send a friend request to a person `y` (`x != y`) if any of the following conditions is true: * `age[y] <= 0.5 * age[x] + 7` * `age[y] > age[x]` * `age[y] >...
null
Array,Greedy,Matrix
Medium
null
449
welcome to october sleep code challenge today's problem is serialize and deserialize bst serialization is converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer blah design an algorithm to serialize and deserialize a binary search tree there is no restriction o...
Serialize and Deserialize BST
serialize-and-deserialize-bst
Serialization is converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment. Design an algorithm to serialize and deserialize a **binary search t...
null
String,Tree,Depth-First Search,Breadth-First Search,Design,Binary Search Tree,Binary Tree
Medium
297,652,765
203
Hello everyone so today we will be discussing question number 203 of lead code which is removed link list elements ok so this one is the problem right this is a part of my recurring playlist and this is an easy problem so what will be its flow that first of all We will see its iterative solution and after that we will ...
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
9
Welcome, whenever you want to learn a new language, you try to make some programs, then this program is very common in it, you must have made it, whenever you have probably done CC or C plus, whatever you have learned, this is This program must have been made 100% by myself, this is This program must have been made 100...
Palindrome Number
palindrome-number
Given an integer `x`, return `true` _if_ `x` _is a_ _**palindrome**__, and_ `false` _otherwise_. **Example 1:** **Input:** x = 121 **Output:** true **Explanation:** 121 reads as 121 from left to right and from right to left. **Example 2:** **Input:** x = -121 **Output:** false **Explanation:** From left to right, i...
Beware of overflow when you reverse the integer.
Math
Easy
234,1375
1,684
A Heaven President will take according to the channel, that question is account number of consistent subscribe then what is this question saying, first what will I do read the question now what am I doing now friend my question craft so that you can practice in this palace Play List In the play list itself, I am thinki...
Count the Number of Consistent Strings
find-latest-group-of-size-m
You are given a string `allowed` consisting of **distinct** characters and an array of strings `words`. A string is **consistent** if all characters in the string appear in the string `allowed`. Return _the number of **consistent** strings in the array_ `words`. **Example 1:** **Input:** allowed = "ab ", words = \[...
Since the problem asks for the latest step, can you start the searching from the end of arr? Use a map to store the current “1” groups. At each step (going backwards) you need to split one group and update the map.
Array,Binary Search,Simulation
Medium
null
1,640
Are Hello Guys Welcome To Another Interesting Problem Industries According School Check Formation Cry Coordination Lecture Are Updating Teachers Are Three Fatty Dare Pieces Vendors In Peace And Established For My Bay Contesting The Amazing Pieces In This However Not Allowed Studio Dealers In Which Are Peace And Tours I...
Check Array Formation Through Concatenation
design-a-file-sharing-system
You are given an array of **distinct** integers `arr` and an array of integer arrays `pieces`, where the integers in `pieces` are **distinct**. Your goal is to form `arr` by concatenating the arrays in `pieces` **in any order**. However, you are **not** allowed to reorder the integers in each array `pieces[i]`. Return...
Try to solve it by keeping for each file chunk, the users who have this chunk. Try to solve it by keeping all the users in the system with their owned chunks, and when you request a chunk, check all users for it.
Hash Table,Design,Heap (Priority Queue),Data Stream
Medium
355
1,046
are you calling enthusiasts welcome back to another episode of Code Master Quest today we are diving into a drilling puzzle involving songs and some smashing logic so let's get started and find out the question description on lead code here's the problem statement you are given an array of integer zones where contain u...
Last Stone Weight
max-consecutive-ones-iii
You are given an array of integers `stones` where `stones[i]` is the weight of the `ith` stone. We are playing a game with the stones. On each turn, we choose the **heaviest two stones** and smash them together. Suppose the heaviest two stones have weights `x` and `y` with `x <= y`. The result of this smash is: * I...
One thing's for sure, we will only flip a zero if it extends an existing window of 1s. Otherwise, there's no point in doing it, right? Think Sliding Window! Since we know this problem can be solved using the sliding window construct, we might as well focus in that direction for hints. Basically, in a given window, we c...
Array,Binary Search,Sliding Window,Prefix Sum
Medium
340,424,485,487,2134
258
hey hello there let's talk about today's liquid and challenge question add digits giving a non-negative integer add digits giving a non-negative integer add digits giving a non-negative integer we want to repeatedly add all its digits up until the resulting number has only one digit looking at the example we have the i...
Add Digits
add-digits
Given an integer `num`, repeatedly add all its digits until the result has only one digit, and return it. **Example 1:** **Input:** num = 38 **Output:** 2 **Explanation:** The process is 38 --> 3 + 8 --> 11 11 --> 1 + 1 --> 2 Since 2 has only one digit, return it. **Example 2:** **Input:** num = 0 **Output:** 0 *...
A naive implementation of the above process is trivial. Could you come up with other methods? What are all the possible results? How do they occur, periodically or randomly? You may find this Wikipedia article useful.
Math,Simulation,Number Theory
Easy
202,1082,2076,2264
1,022
Jhal Hello Hi Guys Welcome To Code Where She Stood As Question Is Precious Fruit To Lip Binary Numbers In This Question Which Give Will Press Tree Is Note Key Value 2018 Shruti Lift Represented By Number Starting With Most Suited For Example 15 This Type Of This Will Press It 2015 in this form and its decimal form is t...
Sum of Root To Leaf Binary Numbers
unique-paths-iii
You are given the `root` of a binary tree where each node has a value `0` or `1`. Each root-to-leaf path represents a binary number starting with the most significant bit. * For example, if the path is `0 -> 1 -> 1 -> 0 -> 1`, then this could represent `01101` in binary, which is `13`. For all leaves in the tree, c...
null
Array,Backtracking,Bit Manipulation,Matrix
Hard
37,63,212
1,680
Hi gas welcome and welcome back to my channel so today our problem is which concatenation of consecutive numbers so on this problem statement what have you given us here we have given a wait and what we have to do is to find the decimal value of D Mind Re Stream Now this thinking will become yours, how what do we have ...
Concatenation of Consecutive Binary Numbers
count-all-possible-routes
Given an integer `n`, return _the **decimal value** of the binary string formed by concatenating the binary representations of_ `1` _to_ `n` _in order, **modulo**_ `109 + 7`. **Example 1:** **Input:** n = 1 **Output:** 1 **Explanation: ** "1 " in binary corresponds to the decimal value 1. **Example 2:** **Input:**...
Use dynamic programming to solve this problem with each state defined by the city index and fuel left. Since the array contains distinct integers fuel will always be spent in each move and so there can be no cycles.
Array,Dynamic Programming,Memoization
Hard
null
1,678
foreign problem 1678 called parser interpretation you own a gold parser that can interpret a string command the command consists of an alphabet of J open and close scope and or Al in some order the call part server will interpret J as a string Jake s scope and as a string o and Al inside of a scope will be as a string ...
Goal Parser Interpretation
number-of-ways-to-split-a-string
You own a **Goal Parser** that can interpret a string `command`. The `command` consists of an alphabet of `"G "`, `"() "` and/or `"(al) "` in some order. The Goal Parser will interpret `"G "` as the string `"G "`, `"() "` as the string `"o "`, and `"(al) "` as the string `"al "`. The interpreted strings are then concat...
There is no way if the sum (number of '1's) is not divisible by the number of splits. So sum%3 should be 0. Preffix s1 , and suffix s3 should have sum/3 characters '1'. Follow up: Can you generalize the problem with numbers between [-10^9, 10^9] such the sum between subarrays s1, s2, s3 are the same?
Math,String
Medium
548
1,470
hey everybody this is Larry I'm doing this problem as part of a contest so you're gonna watch me live as I go through my daughter's I'm coding they've been explanation near the end and for more context they'll be a link below on this actual screen cats of the contest how did you do let me know you do hit the like butto...
Shuffle the Array
tweet-counts-per-frequency
Given the array `nums` consisting of `2n` elements in the form `[x1,x2,...,xn,y1,y2,...,yn]`. _Return the array in the form_ `[x1,y1,x2,y2,...,xn,yn]`. **Example 1:** **Input:** nums = \[2,5,1,3,4,7\], n = 3 **Output:** \[2,3,5,4,1,7\] **Explanation:** Since x1\=2, x2\=5, x3\=1, y1\=3, y2\=4, y3\=7 then the answer ...
null
Hash Table,Binary Search,Design,Sorting,Ordered Set
Medium
null
678
everyone welcome back and let's write some more neat code today so today let's solve the problem valid parentheses string we've solved a few parentheses related problems on this channel but this is a pretty unique one so we're given a string s and it could contain three types of characters a left parenthesis a right pa...
Valid Parenthesis String
valid-parenthesis-string
Given a string `s` containing only three types of characters: `'('`, `')'` and `'*'`, return `true` _if_ `s` _is **valid**_. The following rules define a **valid** string: * Any left parenthesis `'('` must have a corresponding right parenthesis `')'`. * Any right parenthesis `')'` must have a corresponding left p...
null
String,Dynamic Programming,Stack,Greedy
Medium
763,2221
912
hey guys welcome to a new video in today's video we're going to look at the lead code problem and the problem's name is sort and array so in this question we are given an array called nums and we need to sort the array ascending order and return it coming to the functions have given us this is the function name and thi...
Sort an Array
random-pick-with-weight
Given an array of integers `nums`, sort the array in ascending order and return it. You must solve the problem **without using any built-in** functions in `O(nlog(n))` time complexity and with the smallest space complexity possible. **Example 1:** **Input:** nums = \[5,2,3,1\] **Output:** \[1,2,3,5\] **Explanation:*...
null
Math,Binary Search,Prefix Sum,Randomized
Medium
398,894,914
396
so this question is lead code 396 rotate function we are given a nums array of length n and we have to calculate F of K function for 0 to n minus 1. how we calculate F of K is for f of 0 we will have to multiply each number with its index and sum it up then we rotate the number once numbs array ones and we repeat it fo...
Rotate Function
rotate-function
You are given an integer array `nums` of length `n`. Assume `arrk` to be an array obtained by rotating `nums` by `k` positions clock-wise. We define the **rotation function** `F` on `nums` as follow: * `F(k) = 0 * arrk[0] + 1 * arrk[1] + ... + (n - 1) * arrk[n - 1].` Return _the maximum value of_ `F(0), F(1), ...,...
null
Array,Math,Dynamic Programming
Medium
null
1,254
hey what's up guys this is sean here so uh today let's take a look at this 1254 number of closed islands so i mean the media one it's this one is not definitely not that hard i mean okay so given like a 2d grades here consists of either zeros represents the land or ones represents water and an island is a is like a max...
Number of Closed Islands
deepest-leaves-sum
Given a 2D `grid` consists of `0s` (land) and `1s` (water). An _island_ is a maximal 4-directionally connected group of `0s` and a _closed island_ is an island **totally** (all left, top, right, bottom) surrounded by `1s.` Return the number of _closed islands_. **Example 1:** **Input:** grid = \[\[1,1,1,1,1,1,1,0\],...
Traverse the tree to find the max depth. Traverse the tree again to compute the sum required.
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
1,061
good morning everyone today is January 14th Saturday morning um I randomly looked up this problem because this is the problem for leave code has a daily problem challenge so this is today's problem um 10 legal problem 1061. this is today's problem challenge you see all the other problems I started in the ascending orde...
Lexicographically Smallest Equivalent String
number-of-valid-subarrays
You are given two strings of the same length `s1` and `s2` and a string `baseStr`. We say `s1[i]` and `s2[i]` are equivalent characters. * For example, if `s1 = "abc "` and `s2 = "cde "`, then we have `'a' == 'c'`, `'b' == 'd'`, and `'c' == 'e'`. Equivalent characters follow the usual rules of any equivalence rela...
Given a data structure that answers queries of the type to find the minimum in a range of an array (Range minimum query (RMQ) sparse table) in O(1) time. How can you solve this problem? For each starting index do a binary search with an RMQ to find the ending possible position.
Array,Stack,Monotonic Stack
Hard
2233
527
word abbreviation so we are given an array of nonempty strings and then we need to generate minimal possible abbreviations and we have some rules so we need to begin with the first character then the number of characters abbreviated followed by the last character and then if there's a conflict we need to abbreviate the...
Word Abbreviation
word-abbreviation
Given an array of **distinct** strings `words`, return _the minimal possible **abbreviations** for every word_. The following are the rules for a string abbreviation: 1. The **initial** abbreviation for each word is: the first character, then the number of characters in between, followed by the last character. 2. I...
null
Array,String,Greedy,Trie,Sorting
Hard
408,411
1,092
so welcome back guys today I'm here to solve a deep equation which was I was solving and I just solved by my own with the help of the previous rated question so I am want to explain my strategy what I have used to solve this question you will find many of the solution out there with the different YouTubers but I want t...
Shortest Common Supersequence
maximum-difference-between-node-and-ancestor
Given two strings `str1` and `str2`, return _the shortest string that has both_ `str1` _and_ `str2` _as **subsequences**_. If there are multiple valid strings, return **any** of them. A string `s` is a **subsequence** of string `t` if deleting some number of characters from `t` (possibly `0`) results in the string `s`...
For each subtree, find the minimum value and maximum value of its descendants.
Tree,Depth-First Search,Binary Tree
Medium
null
112
October lead code challenge the problem that we have in today is path sum this is a fairly easy problem on lead code and I believe the subscribers of coding decoded will be able to solve this question by themselves however if you are new then this video is for you the question says you're given a binary tree and an int...
Path Sum
path-sum
Given the `root` of a binary tree and an integer `targetSum`, return `true` if the tree has a **root-to-leaf** path such that adding up all the values along the path equals `targetSum`. A **leaf** is a node with no children. **Example 1:** **Input:** root = \[5,4,8,11,null,13,4,7,2,null,null,null,1\], targetSum = 22...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
113,124,129,437,666
475
welcome to this new video where we will solve the heater's problem we have a horizontal line and it will have houses for example here the house is 1 3 4 6 8. and these houses have to be heated for that we have heaters at certain positions for example at positions 1 and 5 here and we are given the ability to modify thei...
Heaters
heaters
Winter is coming! During the contest, your first job is to design a standard heater with a fixed warm radius to warm all the houses. Every house can be warmed, as long as the house is within the heater's warm radius range. Given the positions of `houses` and `heaters` on a horizontal line, return _the minimum radius ...
null
Array,Two Pointers,Binary Search,Sorting
Medium
null
410
Hello hello everyone welcome back to my channel today were going to discuss in two problem split air a large sum suji problem value given here which consists of negative teachers and teachers day mam are you can play in 2m non anti quantity just save this The soldiers are given right and teacher and even need to split ...
Split Array Largest Sum
split-array-largest-sum
Given an integer array `nums` and an integer `k`, split `nums` into `k` non-empty subarrays such that the largest sum of any subarray is **minimized**. Return _the minimized largest sum of the split_. A **subarray** is a contiguous part of the array. **Example 1:** **Input:** nums = \[7,2,5,10,8\], k = 2 **Output:*...
null
Array,Binary Search,Dynamic Programming,Greedy
Hard
1056,1192,2242,2330
258
hey guys welcome back today let's solve the problem add digits so in this problem given an integer num our task is to repeatedly add all of its digits such that the result has only one digit so if you're given an example of two digits 38 what we can do is to take the two digits three and eight and add them together thi...
Add Digits
add-digits
Given an integer `num`, repeatedly add all its digits until the result has only one digit, and return it. **Example 1:** **Input:** num = 38 **Output:** 2 **Explanation:** The process is 38 --> 3 + 8 --> 11 11 --> 1 + 1 --> 2 Since 2 has only one digit, return it. **Example 2:** **Input:** num = 0 **Output:** 0 *...
A naive implementation of the above process is trivial. Could you come up with other methods? What are all the possible results? How do they occur, periodically or randomly? You may find this Wikipedia article useful.
Math,Simulation,Number Theory
Easy
202,1082,2076,2264
496
hey what's up guys and they're quite here I do tecnico ting stuff on Twitch in YouTube check the description you get all my information discord is pretty cool if you want to join that and I do all these premium problems on patreon also help me up on github you are given to a raise I don't like hit me up so forget I sai...
Next Greater Element I
next-greater-element-i
The **next greater element** of some element `x` in an array is the **first greater** element that is **to the right** of `x` in the same array. You are given two **distinct 0-indexed** integer arrays `nums1` and `nums2`, where `nums1` is a subset of `nums2`. For each `0 <= i < nums1.length`, find the index `j` such ...
null
Array,Hash Table,Stack,Monotonic Stack
Easy
503,556,739,2227
227
welcome to the channel this is vaga we are going to solve another reach good question and the question in question is going to be basic calculator and um you're basically given a string you're supposed to evaluate the value in this case 3 plus 2 times 2 is going to be 7 right so how we do this is pretty straightforward...
Basic Calculator II
basic-calculator-ii
Given a string `s` which represents an expression, _evaluate this expression and return its value_. The integer division should truncate toward zero. You may assume that the given expression is always valid. All intermediate results will be in the range of `[-231, 231 - 1]`. **Note:** You are not allowed to use any ...
null
Math,String,Stack
Medium
224,282,785
779
hey everyone welcome back and let's write some more neat code today so today let's solve the problem Ki symbol in grammar we are given a bunch of rows that I guess are one indexed and to go through it quickly the first row is going to have a single value zero and then the rule is that we build every subsequent row by t...
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
315
Ki gas welcome tu take tu vedita and its video c r going tu solve count of smaller numbers after self so what is given in this problem statement here I have given you a vein and you have to make it how will count aunteric be made what to do here What is the rectangle index one, we have to take the particular index, oka...
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
1,477
hello today we're gonna be talking about the good problem 1477 fine to non-overlapping subarrays each would non-overlapping subarrays each would non-overlapping subarrays each would target some so I think it's pretty easy conceptually we have to find two non-overlapping subarrays such that the non-overlapping subarrays...
Find Two Non-overlapping Sub-arrays Each With Target Sum
product-of-the-last-k-numbers
You are given an array of integers `arr` and an integer `target`. You have to find **two non-overlapping sub-arrays** of `arr` each with a sum equal `target`. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is **minimum**. Return _the minimum sum of the l...
Keep all prefix products of numbers in an array, then calculate the product of last K elements in O(1) complexity. When a zero number is added, clean the array of prefix products.
Array,Math,Design,Queue,Data Stream
Medium
null
1,650
hello in this video we're going to be going through Lois common ancestor of a binary tree three which is lead code problem 1650 this problem is marked as a medium and it's fairly new and fairly popular but um it is high on the frequency list given two nodes of a binary tree p and Q return their lowest common ancestor L...
Lowest Common Ancestor of a Binary Tree III
find-root-of-n-ary-tree
Given two nodes of a binary tree `p` and `q`, return _their lowest common ancestor (LCA)_. Each node will have a reference to its parent node. The definition for `Node` is below: class Node { public int val; public Node left; public Node right; public Node parent; } According to the **[definition of ...
Node with indegree 0 is the root
Hash Table,Bit Manipulation,Tree,Depth-First Search
Medium
1655
1,980
hey everyone let's talk the today's lad code challenge find unique binary strings so in this problem we are given a string array nums containing n unique binary strings and all of that binary strings are of length n and we have to return any binary string of length n which does not appear in that nums array and you can...
Find Unique Binary String
faulty-sensor
Given an array of strings `nums` containing `n` **unique** binary strings each of length `n`, return _a binary string of length_ `n` _that **does not appear** in_ `nums`_. If there are multiple answers, you may return **any** of them_. **Example 1:** **Input:** nums = \[ "01 ", "10 "\] **Output:** "11 " **Explanatio...
Check for a common prefix of the two arrays. After this common prefix, there should be one array similar to the other but shifted by one. If both arrays can be shifted, return -1.
Array,Two Pointers
Easy
null
377
in this video we're going to take a look at a legal problem called combination sum four so uh previously i did a legal video called combination sum uh number one number two number three so this is just a follow-up question or so this is just a follow-up question or so this is just a follow-up question or i should say a...
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
349
hello guys welcome back to the channel and today we're going to solve this Le code question which is intersection of two arrays this question we basically given two integer arrays nums one and nums two and we need to return the array of their intersection each element in the result must be unique and you may return the...
Intersection of Two Arrays
intersection-of-two-arrays
Given two integer arrays `nums1` and `nums2`, return _an array of their intersection_. Each element in the result must be **unique** and you may return the result in **any order**. **Example 1:** **Input:** nums1 = \[1,2,2,1\], nums2 = \[2,2\] **Output:** \[2\] **Example 2:** **Input:** nums1 = \[4,9,5\], nums2 = \...
null
Array,Hash Table,Two Pointers,Binary Search,Sorting
Easy
350,1149,1392,2190,2282
684
hello everyone so let's talk about a redundant connection so you are giving the um direct graph right and then you are given to the array and which you generate on that request so you want to return the edge that is removable so if you want to remove two or three uh the graphics still connect right if you want to remov...
Redundant Connection
redundant-connection
In this problem, a tree is an **undirected graph** that is connected and has no cycles. You are given a graph that started as a tree with `n` nodes labeled from `1` to `n`, with one additional edge added. The added edge has two **different** vertices chosen from `1` to `n`, and was not an edge that already existed. Th...
null
Depth-First Search,Breadth-First Search,Union Find,Graph
Medium
685,721,2246
442
detecting duplicate items in a list is a problem you tend to run into quite often and there are many ways to solve it from direct to optimized this problem has the following list of eight elements have two constraints first no number in the list the little owl indicates a list item can have a value greater than the siz...
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
413
hello everyone today we are going to cover arithmetic slices so we are given an input of an integer array and we have to return the number of arithmetic slices in given array so what is arithmetic slice a sequence of number is called arithmetic if it consists of at least three elements and if the difference between any...
Arithmetic Slices
arithmetic-slices
An integer array is called arithmetic if it consists of **at least three elements** and if the difference between any two consecutive elements is the same. * For example, `[1,3,5,7,9]`, `[7,7,7,7]`, and `[3,-1,-5,-9]` are arithmetic sequences. Given an integer array `nums`, return _the number of arithmetic **subarr...
null
Array,Dynamic Programming
Medium
446,1752
1,684
Hua Hai The Kid Number 101 Title Se Is Account Number Accident Distic And The Problem Description Yagya Ministerial Out In The River Systems And Don't Stop This Problem Virvar Problem Subscribe And Subscribe The Picture And Subscribe To Feed Subscribe Chhindwara To Middle One Playlist Voice Assistant Setting On In Whic...
Count the Number of Consistent Strings
find-latest-group-of-size-m
You are given a string `allowed` consisting of **distinct** characters and an array of strings `words`. A string is **consistent** if all characters in the string appear in the string `allowed`. Return _the number of **consistent** strings in the array_ `words`. **Example 1:** **Input:** allowed = "ab ", words = \[...
Since the problem asks for the latest step, can you start the searching from the end of arr? Use a map to store the current “1” groups. At each step (going backwards) you need to split one group and update the map.
Array,Binary Search,Simulation
Medium
null
212
Loot hello everyone welcome to my channel today is the last day of miding challenge and problems but search to sleep very famous problem in the interview problem given alms from all must be constructed from subscribe and subscribe to that beer given a list of birds like and Speed ​​and give that subscribe The and Speed...
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
41
hey everyone today we are going to serve the little question fast missing and positive and you are given unsorted integer array numbers return the smallest missing positive integer you must Implement algorithm that runs in o and a time and I use constant extra space so let's see the example so you are given one to zero...
First Missing Positive
first-missing-positive
Given an unsorted integer array `nums`, return the smallest missing positive integer. You must implement an algorithm that runs in `O(n)` time and uses constant extra space. **Example 1:** **Input:** nums = \[1,2,0\] **Output:** 3 **Explanation:** The numbers in the range \[1,2\] are all in the array. **Example 2:*...
Think about how you would solve the problem in non-constant space. Can you apply that logic to the existing space? We don't care about duplicates or non-positive integers Remember that O(2n) = O(n)
Array,Hash Table
Hard
268,287,448,770
35
guys today's problem is search insert position and um this is simple search question searching question where we have an integer array it is uh sorted so from um from one to six it is um given in sorted array a sorted manner and we have one target variable and we need to return its position right where can we insert it...
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
88
hey there today we'll solve one of the problem it could merge sorted in so which means that uh two sorted array will be given in the input and the number of elements in the array is also given and the first array will have extra space so that the one will merge it now the second area elements can also be tested inside ...
Merge Sorted Array
merge-sorted-array
You are given two integer arrays `nums1` and `nums2`, sorted in **non-decreasing order**, and two integers `m` and `n`, representing the number of elements in `nums1` and `nums2` respectively. **Merge** `nums1` and `nums2` into a single array sorted in **non-decreasing order**. The final sorted array should not be re...
You can easily solve this problem if you simply think about two elements at a time rather than two arrays. We know that each of the individual arrays is sorted. What we don't know is how they will intertwine. Can we take a local decision and arrive at an optimal solution? If you simply consider one element each at a ti...
Array,Two Pointers,Sorting
Easy
21,1019,1028
1,754
hey everybody this is larry this is me going over q3 of the weekly contest 227 uh largest merge of two strings so actually this one pretty quickly i spent too much time at the end testing for this one because i wasn't sure um but i think this is uh greedy in a way and how is it greedy um i think for me during the conte...
Largest Merge Of Two Strings
largest-merge-of-two-strings
You are given two strings `word1` and `word2`. You want to construct a string `merge` in the following way: while either `word1` or `word2` are non-empty, choose **one** of the following options: * If `word1` is non-empty, append the **first** character in `word1` to `merge` and delete it from `word1`. * For e...
null
null
Medium
null
61
foreign to the right by K places so actually through this problem there are two things that we should know and the both of the two things are pretty much explained by the examples so in the first example we have k equal to 2 so basically we have to rotate the list by to the right by two places and uh we are given one t...
Rotate List
rotate-list
Given the `head` of a linked list, rotate the list to the right by `k` places. **Example 1:** **Input:** head = \[1,2,3,4,5\], k = 2 **Output:** \[4,5,1,2,3\] **Example 2:** **Input:** head = \[0,1,2\], k = 4 **Output:** \[2,0,1\] **Constraints:** * The number of nodes in the list is in the range `[0, 500]`. * ...
null
Linked List,Two Pointers
Medium
189,725
1,903
hi everyone so welcome back to our new video today's lead code daily challenges largest odd number in string this is an easy level question okay now let's see the problem description so in this problem we have been given a string which is called num okay and it is representing a large integer and what we need to do is ...
Largest Odd Number in String
design-most-recently-used-queue
You are given a string `num`, representing a large integer. Return _the **largest-valued odd** integer (as a string) that is a **non-empty substring** of_ `num`_, or an empty string_ `" "` _if no odd integer exists_. A **substring** is a contiguous sequence of characters within a string. **Example 1:** **Input:** nu...
You can store the data in an array and apply each fetch by moving the ith element to the end of the array (i.e, O(n) per operation). A better way is to use the square root decomposition technique. You can build chunks of size sqrt(n). For each fetch operation, You can search for the chunk which has the ith element and ...
Array,Hash Table,Stack,Design,Binary Indexed Tree,Ordered Set
Medium
146