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 |
|---|---|---|---|---|---|---|---|---|
272 | hey what's up guys this is chung here so uh today uh let's take a look at this problem number 272 closest binary search tree value number two so you're given like a non-empty binary so you're given like a non-empty binary so you're given like a non-empty binary search tree okay so remember this is a binary search tree ... | Closest Binary Search Tree Value II | closest-binary-search-tree-value-ii | Given the `root` of a binary search tree, a `target` value, and an integer `k`, return _the_ `k` _values in the BST that are closest to the_ `target`. You may return the answer in **any order**.
You are **guaranteed** to have only one unique set of `k` values in the BST that are closest to the `target`.
**Example 1:*... | Consider implement these two helper functions:
getPredecessor(N), which returns the next smaller node to N.
getSuccessor(N), which returns the next larger node to N. Try to assume that each node has a parent pointer, it makes the problem much easier. Without parent pointer we just need to keep track of the path from ... | Two Pointers,Stack,Tree,Depth-First Search,Binary Search Tree,Heap (Priority Queue),Binary Tree | Hard | 94,270 |
139 | In this video we will discuss the problem of word break. In this problem you are given a string and you are given a trick. You have to return if you can segment S in which dictionary word and if you cannot then You have to return from the result, like the example given here is lead code and we have dictionary's lead an... | 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 |
268 | hello everyone welcome back and today we are looking at question 268 which is missing number so we are given an array nums containing n distinct numbers in the range 0 to n inclusive now we want to return the only number in the range that does not appear in our nums array for instance if we pick n to be 3 this means th... | Missing Number | missing-number | Given an array `nums` containing `n` distinct numbers in the range `[0, n]`, return _the only number in the range that is missing from the array._
**Example 1:**
**Input:** nums = \[3,0,1\]
**Output:** 2
**Explanation:** n = 3 since there are 3 numbers, so all numbers are in the range \[0,3\]. 2 is the missing number... | null | Array,Hash Table,Math,Bit Manipulation,Sorting | Easy | 41,136,287,770,2107 |
895 | hey everybody this is larry this is day 19 of the leeco daily challenge only 10 days to go now 11 days to go somewhere like that 12 days to go hit the like button hit the subscribe button join me in the discord let me know what you um let me know what let me know how you're doing in general hope y'all having a great we... | Maximum Frequency Stack | shortest-path-to-get-all-keys | Design a stack-like data structure to push elements to the stack and pop the most frequent element from the stack.
Implement the `FreqStack` class:
* `FreqStack()` constructs an empty frequency stack.
* `void push(int val)` pushes an integer `val` onto the top of the stack.
* `int pop()` removes and returns the... | null | Bit Manipulation,Breadth-First Search | Hard | null |
443 | hello everyone let's solve the problem string compression given an array of characters compress it using the following algorithm begin with an empty string s for each consecutive repeating characters if the group's length is 1 appendic character to S otherwise append the character followed by the group's length the com... | String Compression | string-compression | Given an array of characters `chars`, compress it using the following algorithm:
Begin with an empty string `s`. For each group of **consecutive repeating characters** in `chars`:
* If the group's length is `1`, append the character to `s`.
* Otherwise, append the character followed by the group's length.
The co... | How do you know if you are at the end of a consecutive group of characters? | Two Pointers,String | Medium | 38,271,604,1241 |
17 | Hello friends, welcome to the new video, question number 17 lead letter combination of phone number is a medium level question, backtracking question is a friend's question, this question has been asked from many companies, big names are Amazon, Microsoft, Google, Facebook, Uber app, Pal. Oracle let's start the questio... | 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 |
204 | you guys this is easier as we can go in this video I'm going to take a look at 2:04 cam crimes it's easy one but 2:04 cam crimes it's easy one but 2:04 cam crimes it's easy one but there's a lot of hints here if you have time you can look at it carefully about how to include through the approach and yeah let's forget s... | Count Primes | count-primes | Given an integer `n`, return _the number of prime numbers that are strictly less than_ `n`.
**Example 1:**
**Input:** n = 10
**Output:** 4
**Explanation:** There are 4 prime numbers less than 10, they are 2, 3, 5, 7.
**Example 2:**
**Input:** n = 0
**Output:** 0
**Example 3:**
**Input:** n = 1
**Output:** 0
**Co... | Let's start with a isPrime function. To determine if a number is prime, we need to check if it is not divisible by any number less than n. The runtime complexity of isPrime function would be O(n) and hence counting the total prime numbers up to n would be O(n2). Could we do better? As we know the number must not be div... | Array,Math,Enumeration,Number Theory | Medium | 263,264,279 |
19 | hey everyone welcome back let's write some more neat code today let's solve remove nth node from the end of a list so we're given a linked list and all we need to do is remove the nth node from the end of the list and then return the new list so that's pretty straightforward right so in this case we got five nodes we j... | Remove Nth Node From End of List | remove-nth-node-from-end-of-list | Given the `head` of a linked list, remove the `nth` node from the end of the list and return its head.
**Example 1:**
**Input:** head = \[1,2,3,4,5\], n = 2
**Output:** \[1,2,3,5\]
**Example 2:**
**Input:** head = \[1\], n = 1
**Output:** \[\]
**Example 3:**
**Input:** head = \[1,2\], n = 1
**Output:** \[1\]
**C... | Maintain two pointers and update one with a delay of n steps. | Linked List,Two Pointers | Medium | 528,1618,2216 |
451 | hey guys welcome to a new video in today's video we're going to look at a lead code problem and the problem's name is sort characters by frequency so in this question we given a string s and we have to sort it in decreasing order based on the frequency of the characters and the frequency of a character is defined by th... | Sort Characters By Frequency | sort-characters-by-frequency | Given a string `s`, sort it in **decreasing order** based on the **frequency** of the characters. The **frequency** of a character is the number of times it appears in the string.
Return _the sorted string_. If there are multiple answers, return _any of them_.
**Example 1:**
**Input:** s = "tree "
**Output:** "eer... | null | Hash Table,String,Sorting,Heap (Priority Queue),Bucket Sort,Counting | Medium | 347,387,1741 |
1,800 | zero maximum ascending sub arrays up hope you guys subscribe to my channel also given already positive numbers and uh so basically in array numbers and uh basically uh ascending means that uh a sub array that means that satisfy this relation right so basically for oi so basically increasing right and uh cannot be the s... | Maximum Ascending Subarray Sum | concatenation-of-consecutive-binary-numbers | Given an array of positive integers `nums`, return the _maximum possible sum of an **ascending** subarray in_ `nums`.
A subarray is defined as a contiguous sequence of numbers in an array.
A subarray `[numsl, numsl+1, ..., numsr-1, numsr]` is **ascending** if for all `i` where `l <= i < r`, `numsi < numsi+1`. Note th... | Express the nth number value in a recursion formula and think about how we can do a fast evaluation. | Math,Bit Manipulation,Simulation | Medium | null |
1,092 | Hello guys welcome back to decades in this video you will see the artist ko man super sequence problem user variation of the longest comment subscribe isse tis from list ko number 109 to and widening programming show latest reader problem statement no problem given two strings struts2 return The Short History of Meghva... | 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 |
1,749 | hey everybody this is larry this is me going over to two of the bi-weekly contest 45 maximum two of the bi-weekly contest 45 maximum two of the bi-weekly contest 45 maximum sum uh maximum absolute sum of any sub array so this one the prerequisite i would say for this problem is just kadene's algorithm and for that is j... | Maximum Absolute Sum of Any Subarray | sellers-with-no-sales | You are given an integer array `nums`. The **absolute sum** of a subarray `[numsl, numsl+1, ..., numsr-1, numsr]` is `abs(numsl + numsl+1 + ... + numsr-1 + numsr)`.
Return _the **maximum** absolute sum of any **(possibly empty)** subarray of_ `nums`.
Note that `abs(x)` is defined as follows:
* If `x` is a negative... | null | Database | Easy | 1724 |
1,046 | hello everyone welcome to the channel today's question is last stone weight if you are new to the channel please consider subscribing we sold a lot of interview questions on this channel that can definitely help you with your interview question says we have collection of stones each stone have a positive integer value ... | 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 |
767 | all right let's talk about reorganized strain so given the string as rearrange the character of s so that any two adjacent characters are not the same return any possible rearrangement of s or return the mp if not possible so the idea is a b right you're done epa and this can be done by a hashmap so key will be a chara... | Reorganize String | prime-number-of-set-bits-in-binary-representation | Given a string `s`, rearrange the characters of `s` so that any two adjacent characters are not the same.
Return _any possible rearrangement of_ `s` _or return_ `" "` _if not possible_.
**Example 1:**
**Input:** s = "aab"
**Output:** "aba"
**Example 2:**
**Input:** s = "aaab"
**Output:** ""
**Constraints:**
* ... | Write a helper function to count the number of set bits in a number, then check whether the number of set bits is 2, 3, 5, 7, 11, 13, 17 or 19. | Math,Bit Manipulation | Easy | 191 |
1,463 | Hello everyone welcome to my channel Quote Story with Mike So today we are going to do video number 88 of our dynamic programming playlist. I have heard that this is a very popular question and it is also a hard mark but we can make it very easily with three approaches. OK, we will take recursive memoization on 3D bott... | Cherry Pickup II | the-k-weakest-rows-in-a-matrix | You are given a `rows x cols` matrix `grid` representing a field of cherries where `grid[i][j]` represents the number of cherries that you can collect from the `(i, j)` cell.
You have two robots that can collect cherries for you:
* **Robot #1** is located at the **top-left corner** `(0, 0)`, and
* **Robot #2** is... | Sort the matrix row indexes by the number of soldiers and then row indexes. | Array,Binary Search,Sorting,Heap (Priority Queue),Matrix | Easy | null |
1,690 | That A Hello Everyone Welcome To Day Level Tak Julie's Challenge And Aspiration To Give Seven In The Street In Three Years Of Clans Game Election Bob Unleashes You All Subscribe Problem And Solution Subscribe Different Problem Something New To Me How To Give A Valid Code Close 600 Is Try to Understand Rulers of the Que... | Stone Game VII | maximum-length-of-subarray-with-positive-product | Alice and Bob take turns playing a game, with **Alice starting first**.
There are `n` stones arranged in a row. On each player's turn, they can **remove** either the leftmost stone or the rightmost stone from the row and receive points equal to the **sum** of the remaining stones' values in the row. The winner is the ... | Split the whole array into subarrays by zeroes since a subarray with positive product cannot contain any zero. If the subarray has even number of negative numbers, the whole subarray has positive product. Otherwise, we have two choices, either - remove the prefix till the first negative element in this subarray, or rem... | Array,Dynamic Programming,Greedy | Medium | null |
236 | Hey welcome back to another problem of lead code and today we're gonna solve a problem it's a common interview question and it's called lowest common ancestor of a binary tree so given a tree we need to just find not just an ancestor we need to find the lowest common ancestor okay so given a binary tree find the lowest... | Lowest Common Ancestor of a Binary Tree | lowest-common-ancestor-of-a-binary-tree | Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
According to the [definition of LCA on Wikipedia](https://en.wikipedia.org/wiki/Lowest_common_ancestor): "The lowest common ancestor is defined between two nodes `p` and `q` as the lowest node in `T` that has both `p` and `q` as... | null | Tree,Depth-First Search,Binary Tree | Medium | 235,1190,1354,1780,1790,1816,2217 |
1,732 | Hello hello welcome to my YouTube channel thank you will be doing problem pandey high school person again zinc whole life problem statement k 1000 likes subscribe and third tips subscribe with obscure length is net this is 2.5 violet anil 2012 net this is 2.5 violet anil 2012 net this is 2.5 violet anil 2012 point ques... | 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 |
207 | hello and welcome to another self study session today we're going to be looking at leeco number 207 course schedule so there are a total of num courses that need to be taken and it's labeled from zero to num courses minus one and so we're given an array of prerequisites where prerequisites of i is equal to the pair of ... | Course Schedule | course-schedule | There are a total of `numCourses` courses you have to take, labeled from `0` to `numCourses - 1`. You are given an array `prerequisites` where `prerequisites[i] = [ai, bi]` indicates that you **must** take course `bi` first if you want to take course `ai`.
* For example, the pair `[0, 1]`, indicates that to take cou... | This problem is equivalent to finding if a cycle exists in a directed graph. If a cycle exists, no topological ordering exists and therefore it will be impossible to take all courses. Topological Sort via DFS - A great video tutorial (21 minutes) on Coursera explaining the basic concepts of Topological Sort. Topologica... | Depth-First Search,Breadth-First Search,Graph,Topological Sort | Medium | 210,261,310,630 |
84 | Sir, in today's video, there is a very important question about finding the maximum area in histogram. I have given you a basic histogram and some graphs of this type and to tell you how to make this graph, who is the designer of maximum area, ticket is enough. The famous interviewer has increased a lot and the taste i... | 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 |
931 | hello viewers welcome back to my channel hope you are enjoying all the videos that I'm uploading if you haven't subscribed yet please subscribe to my channel and share among your friends so today's problem is minimum failing path some given a square array of integers a we want the minimum sum of the following path thro... | Minimum Falling Path Sum | maximum-frequency-stack | Given an `n x n` array of integers `matrix`, return _the **minimum sum** of any **falling path** through_ `matrix`.
A **falling path** starts at any element in the first row and chooses the element in the next row that is either directly below or diagonally left/right. Specifically, the next element from position `(ro... | null | Hash Table,Stack,Design,Ordered Set | Hard | null |
1,288 | hello everyone welcome or welcome back to my channel so today we are going to discuss another problem but before going forward if you have not liked the video please like it subscribe to my channel and hit the bell icon so that you get notified when i post a new video so without any further ado let's get started so pro... | Remove Covered Intervals | maximum-subarray-sum-with-one-deletion | Given an array `intervals` where `intervals[i] = [li, ri]` represent the interval `[li, ri)`, remove all intervals that are covered by another interval in the list.
The interval `[a, b)` is covered by the interval `[c, d)` if and only if `c <= a` and `b <= d`.
Return _the number of remaining intervals_.
**Example 1:... | How to solve this problem if no deletions are allowed ? Try deleting each element and find the maximum subarray sum to both sides of that element. To do that efficiently, use the idea of Kadane's algorithm. | Array,Dynamic Programming | Medium | null |
830 | hello everyone so in this video let us talk about one more problem from lead code it is an easy problem that is position of large groups the problem goes like this that in a string s it consists of lower case letters these letters form conjugative groups of same characters so it will form conjugated groups as you can s... | Positions of Large Groups | largest-triangle-area | In a string `s` of lowercase letters, these letters form consecutive groups of the same character.
For example, a string like `s = "abbxxxxzyy "` has the groups `"a "`, `"bb "`, `"xxxx "`, `"z "`, and `"yy "`.
A group is identified by an interval `[start, end]`, where `start` and `end` denote the start and end indice... | null | Array,Math,Geometry | Easy | 1018 |
122 | hello everyone let's look at best time to buy and sell stock number two if you did not watch the first question for this theory feel free to have a look at it first the question number is one to one back to this question the problem statement is we are giving an array the eighth element is a price for a given stock on ... | Best Time to Buy and Sell Stock II | best-time-to-buy-and-sell-stock-ii | You are given an integer array `prices` where `prices[i]` is the price of a given stock on the `ith` day.
On each day, you may decide to buy and/or sell the stock. You can only hold **at most one** share of the stock at any time. However, you can buy it then immediately sell it on the **same day**.
Find and return _t... | null | Array,Dynamic Programming,Greedy | Medium | 121,123,188,309,714 |
1,688 | hey everyone today we are going to solve the problem number 168 count the number of matches in a tournament okay so here we are given an integer n which is the number of teams part participating in the tournament and we just have to return the number of matches uh going to happen in that tournament it's a simple math s... | Count of Matches in Tournament | the-most-recent-orders-for-each-product | You are given an integer `n`, the number of teams in a tournament that has strange rules:
* If the current number of teams is **even**, each team gets paired with another team. A total of `n / 2` matches are played, and `n / 2` teams advance to the next round.
* If the current number of teams is **odd**, one team ... | null | Database | Medium | 1671,1735 |
983 | all right so this question is minimum cost for tickets so uh just re-over the problem uh just re-over the problem uh just re-over the problem and I'm going to talk about the solution so you are going to uh you have this array and it costs array right so what you have to do is what you want to find on the last day insid... | 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 |
430 | hello everyone welcome to let word coding today welcome to South problem 430 frettin a multi-level doubly linked list multi-level doubly linked list multi-level doubly linked list so given this structure we need to traverse the linked list level by level and then I returned the following output so from 1 2 to 3 then 7 ... | Flatten a Multilevel Doubly Linked List | flatten-a-multilevel-doubly-linked-list | You are given a doubly linked list, which contains nodes that have a next pointer, a previous pointer, and an additional **child pointer**. This child pointer may or may not point to a separate doubly linked list, also containing these special nodes. These child lists may have one or more children of their own, and so ... | null | null | Medium | null |
1,679 | Hello ji, how are you guys? Welcome to the week one of the Weekly Lead Code Challenge of I hope you have registered on our website, so if you have not done so yet then do it quickly, we will help us track your progress. If it will help then let's move towards the solution ok so let's start with the 1st question of a we... | Max Number of K-Sum Pairs | shortest-subarray-to-be-removed-to-make-array-sorted | You are given an integer array `nums` and an integer `k`.
In one operation, you can pick two numbers from the array whose sum equals `k` and remove them from the array.
Return _the maximum number of operations you can perform on the array_.
**Example 1:**
**Input:** nums = \[1,2,3,4\], k = 5
**Output:** 2
**Explana... | The key is to find the longest non-decreasing subarray starting with the first element or ending with the last element, respectively. After removing some subarray, the result is the concatenation of a sorted prefix and a sorted suffix, where the last element of the prefix is smaller than the first element of the suffix... | Array,Two Pointers,Binary Search,Stack,Monotonic Stack | Medium | null |
1,046 | welcome to tim's leco challenge this problem is called last stone weight you are given an array of integers stones where stone's eye is the weight of the i stone so you're playing a game with the stones on each turn you choose the heaviest two stones and smash them together now suppose the heaviest two stones have weig... | 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 |
394 | hey guys now we're going to solve a little problem decode string this is a popular problem you're given an encoded string return its decoded string the encoding rule is k encoded strings where the encoded string inside the square brackets is being repeated exactly k times note that k is guaranteed to be a positive inte... | Decode String | decode-string | Given an encoded string, return its decoded string.
The encoding rule is: `k[encoded_string]`, where the `encoded_string` inside the square brackets is being repeated exactly `k` times. Note that `k` is guaranteed to be a positive integer.
You may assume that the input string is always valid; there are no extra white... | null | String,Stack,Recursion | Medium | 471,726,1076 |
77 | 77 combinations given two integers n and k return all possible combinations of k numbers out of range 1 to n and as you see is inclusive from 1 to n you can you may return the answer in any order let's talk about combinations so what is a combination let's say we have two numbers one and two and if you want to generate... | Combinations | combinations | Given two integers `n` and `k`, return _all possible combinations of_ `k` _numbers chosen from the range_ `[1, n]`.
You may return the answer in **any order**.
**Example 1:**
**Input:** n = 4, k = 2
**Output:** \[\[1,2\],\[1,3\],\[1,4\],\[2,3\],\[2,4\],\[3,4\]\]
**Explanation:** There are 4 choose 2 = 6 total combin... | null | Backtracking | Medium | 39,46 |
1,584 | That's what guys welcome and welcome back to my channel in this video we are going to solve minimum cost to connect all points what is in this problem you have given a bundle of batter which is giving points in this it has given points point of points And what you have to do is, which points have to be connected here, ... | Min Cost to Connect All Points | average-salary-excluding-the-minimum-and-maximum-salary | You are given an array `points` representing integer coordinates of some points on a 2D-plane, where `points[i] = [xi, yi]`.
The cost of connecting two points `[xi, yi]` and `[xj, yj]` is the **manhattan distance** between them: `|xi - xj| + |yi - yj|`, where `|val|` denotes the absolute value of `val`.
Return _the m... | Get the total sum and subtract the minimum and maximum value in the array. Finally divide the result by n - 2. | Array,Sorting | Easy | null |
1,745 | hey what's up guys this is john here so this time 1745 palindrome partition number four um so this is a very straightforward problem so basically you're given like a string as and your task is just to check if this current string can be partitioned can be split into three non-empty into three non-empty into three non-e... | Palindrome Partitioning IV | find-nearest-right-node-in-binary-tree | Given a string `s`, return `true` _if it is possible to split the string_ `s` _into three **non-empty** palindromic substrings. Otherwise, return_ `false`.
A string is said to be palindrome if it the same string when reversed.
**Example 1:**
**Input:** s = "abcbdd "
**Output:** true
**Explanation: ** "abcbdd "... | Use BFS, traverse the tree level by level and always push the left node first When you reach the target node, mark a boolean variable true If you meet another node in the same level after marking the boolean true, return this node. If you did not meet new nodes in the same level and started traversing a new level, ret... | Tree,Breadth-First Search,Binary Tree | Medium | null |
1,636 | 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 short array by increasing frequency so in this question we're given an array which contains integers and we need to sort the output array based on the increasing order of the frequency of the elements... | Sort Array by Increasing Frequency | number-of-substrings-with-only-1s | Given an array of integers `nums`, sort the array in **increasing** order based on the frequency of the values. If multiple values have the same frequency, sort them in **decreasing** order.
Return the _sorted array_.
**Example 1:**
**Input:** nums = \[1,1,2,2,2,3\]
**Output:** \[3,1,1,2,2,2\]
**Explanation:** '3' h... | Count number of 1s in each consecutive-1 group. For a group with n consecutive 1s, the total contribution of it to the final answer is (n + 1) * n // 2. | Math,String | Medium | 1885,2186 |
1,577 | uh hey everybody this is larry this is me going over q2 of the weekly contest 205 number of ways where square is equal to the prime of two numbers so this one should have been so easy and it was surprisingly easy i think for me it was just about reading the forms uh and also just feel like reason recently the contests ... | Number of Ways Where Square of Number Is Equal to Product of Two Numbers | probability-of-a-two-boxes-having-the-same-number-of-distinct-balls | Given two arrays of integers `nums1` and `nums2`, return the number of triplets formed (type 1 and type 2) under the following rules:
* Type 1: Triplet (i, j, k) if `nums1[i]2 == nums2[j] * nums2[k]` where `0 <= i < nums1.length` and `0 <= j < k < nums2.length`.
* Type 2: Triplet (i, j, k) if `nums2[i]2 == nums1[j... | Check how many ways you can distribute the balls between the boxes. Consider that one way you will use (x1, x2, x3, ..., xk) where xi is the number of balls from colour i. The probability of achieving this way randomly is ( (ball1 C x1) * (ball2 C x2) * (ball3 C x3) * ... * (ballk C xk)) / (2n C n). The probability of ... | Math,Dynamic Programming,Backtracking,Combinatorics,Probability and Statistics | Hard | null |
540 | hey everyone welcome back and let's write some more neat code today so today let's solve the problem single element in a sorted array we're given a sorted array of integers maybe like this one over here there will be two copies of every number in the array except for one of them and that's the one that we want to retur... | Single Element in a Sorted Array | single-element-in-a-sorted-array | You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once.
Return _the single element that appears only once_.
Your solution must run in `O(log n)` time and `O(1)` space.
**Example 1:**
**Input:** nums = \[1,1,2,3,3,4,4,8,8\... | null | Array,Binary Search | Medium | null |
724 | hey guys welcome to a new video in today's video we're going to look at lead code problem so in this question we given an integer AR called nums and we have to calculate the index of this array a index is the index where the sum of all elements strictly to the left of the index is equal to the sum of elements strictly ... | Find Pivot Index | find-pivot-index | Given an array of integers `nums`, calculate the **pivot index** of this array.
The **pivot index** is the index where the sum of all the numbers **strictly** to the left of the index is equal to the sum of all the numbers **strictly** to the index's right.
If the index is on the left edge of the array, then the left... | We can precompute prefix sums P[i] = nums[0] + nums[1] + ... + nums[i-1].
Then for each index, the left sum is P[i], and the right sum is P[P.length - 1] - P[i] - nums[i]. | Array,Prefix Sum | Easy | 560,2102,2369 |
344 | start this question is flown from pointers ok sudhir basic question which causes of artwork has been kept hospital subscribe to tomorrow morning first made using a stir work which will not difficult net life in the UK end users can show you are we are S Pi Three Par Hot S.No's Special Permission To Android Based Ones S... | 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 |
48 | all of you are doing fine so today we will discuss lead code problem 48 which is a rotation of an image so uh this in this problem so first we will go through the problem statement then look at these examples and then write our algorithm and at the last implement the solution okay so the problem statement says case we ... | Rotate Image | rotate-image | You are given an `n x n` 2D `matrix` representing an image, rotate the image by **90** degrees (clockwise).
You have to rotate the image [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm), which means you have to modify the input 2D matrix directly. **DO NOT** allocate another 2D matrix and do the rotati... | null | Array,Math,Matrix | Medium | 2015 |
1,046 | hello everyone now we are going to do the problem JL 8 code problem of the day and the problem name is last stone weight in this problem uh we have been given an area of size n and each indices value represents a stone value weight of a stone and we are playing again with the stones on each turn we choose the high BS t... | 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 |
50 | I have one World come back and math Lite amani weigh today of finished Power Of About Love and War Vietnam since the Style and the forest of Death of Superman show that worked on the study or just like you feel me and this is preferred within its rightful owner of the well Mediamart When She can solve Even you have see... | Pow(x, n) | powx-n | Implement [pow(x, n)](http://www.cplusplus.com/reference/valarray/pow/), which calculates `x` raised to the power `n` (i.e., `xn`).
**Example 1:**
**Input:** x = 2.00000, n = 10
**Output:** 1024.00000
**Example 2:**
**Input:** x = 2.10000, n = 3
**Output:** 9.26100
**Example 3:**
**Input:** x = 2.00000, n = -2
**... | null | Math,Recursion | Medium | 69,372 |
56 | this is one of those problems which become very simple to solve once you actually draw diagrams and try to look at it visually I am talking about the problem merge intervals on lead code and no doubt this is asked in a lot of coding interviews by almost every other company so let's see what we can do about it Hello fri... | Merge Intervals | merge-intervals | Given an array of `intervals` where `intervals[i] = [starti, endi]`, merge all overlapping intervals, and return _an array of the non-overlapping intervals that cover all the intervals in the input_.
**Example 1:**
**Input:** intervals = \[\[1,3\],\[2,6\],\[8,10\],\[15,18\]\]
**Output:** \[\[1,6\],\[8,10\],\[15,18\]\... | null | Array,Sorting | Medium | 57,252,253,495,616,715,761,768,1028,2297,2319 |
89 | hello viewers welcome back to my channel I hope you are enjoying all the problems that I am uploading today I'm back with another problem from leak code gray code the gray code is a binary numeral system where two comes successive values differ in only one bit given a non integer non-negative integer and representing n... | Gray Code | gray-code | An **n-bit gray code sequence** is a sequence of `2n` integers where:
* Every integer is in the **inclusive** range `[0, 2n - 1]`,
* The first integer is `0`,
* An integer appears **no more than once** in the sequence,
* The binary representation of every pair of **adjacent** integers differs by **exactly one ... | null | Math,Backtracking,Bit Manipulation | Medium | 717 |
1,852 | what is going on everybody it's your boy average leader here with another video and today we are tackling number 1852 distinct numbers in each subarray now this is a pretty new problem on leak code so it hasn't been asked by a lot of companies uh this year at least but i think it was a pretty good one to try out and i ... | Distinct Numbers in Each Subarray | biggest-window-between-visits | Given an integer array `nums` and an integer `k`, you are asked to construct the array `ans` of size `n-k+1` where `ans[i]` is the number of **distinct** numbers in the subarray `nums[i:i+k-1] = [nums[i], nums[i+1], ..., nums[i+k-1]]`.
Return _the array_ `ans`.
**Example 1:**
**Input:** nums = \[1,2,3,2,2,1,3\], k =... | null | Database | Medium | 2370 |
513 | I don't know what's up with lead code medium questions are easy questions are medium hi guys good morning welcome back to a new video in this problem find bottom left tree value again it's marked as medium but it's a very easy problem so yeah let's start off it has been asked by Amazon and Microsoft in last one to two ... | Find Bottom Left Tree Value | find-bottom-left-tree-value | Given the `root` of a binary tree, return the leftmost value in the last row of the tree.
**Example 1:**
**Input:** root = \[2,1,3\]
**Output:** 1
**Example 2:**
**Input:** root = \[1,2,3,4,null,5,6,null,null,7\]
**Output:** 7
**Constraints:**
* The number of nodes in the tree is in the range `[1, 104]`.
* `-... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Medium | null |
338 | Today we will solve the next problem of Blind 75 which is called Counting Bits. So first of all let us see its problem statement. Return and Answer are of length n + 1 true date Return and Answer are of length n + 1 true date Return and Answer are of length n + 1 true date i > i > i > both are inclusive and an... | Counting Bits | counting-bits | Given an integer `n`, return _an array_ `ans` _of length_ `n + 1` _such that for each_ `i` (`0 <= i <= n`)_,_ `ans[i]` _is the **number of**_ `1`_**'s** in the binary representation of_ `i`.
**Example 1:**
**Input:** n = 2
**Output:** \[0,1,1\]
**Explanation:**
0 --> 0
1 --> 1
2 --> 10
**Example 2:**
**Input:** n =... | You should make use of what you have produced already. Divide the numbers in ranges like [2-3], [4-7], [8-15] and so on. And try to generate new range from previous. Or does the odd/even status of the number help you in calculating the number of 1s? | Dynamic Programming,Bit Manipulation | Easy | 191 |
261 | hey how's it going guys so today i'll quickly go over my solution to lee codes graph value tree problem of 261 okay give an endnotes label from 0 to n minus 1 and a list of undirected edges each edge is a pair of nodes write a function to check whether these edges makes up a valid tree uh so example one we're given uh ... | Graph Valid Tree | graph-valid-tree | You have a graph of `n` nodes labeled from `0` to `n - 1`. You are given an integer n and a list of `edges` where `edges[i] = [ai, bi]` indicates that there is an undirected edge between nodes `ai` and `bi` in the graph.
Return `true` _if the edges of the given graph make up a valid tree, and_ `false` _otherwise_.
**... | Given n = 5 and edges = [[0, 1], [1, 2], [3, 4]], what should your return? Is this case a valid tree? According to the definition of tree on Wikipedia: “a tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles is a tree.” | Depth-First Search,Breadth-First Search,Union Find,Graph | Medium | 207,323,871 |
297 | all right we are doing the top 75 leak code questions from team blind and we are currently on number 297 serialize and deserialize binary tree so the problem is asking us to define two methods of the codec class serialize and deserialize the goal of the serialize method is to take as input a root node of a binary tree ... | Serialize and Deserialize Binary Tree | serialize-and-deserialize-binary-tree | Serialization is the process of 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 bi... | null | String,Tree,Depth-First Search,Breadth-First Search,Design,Binary Tree | Hard | 271,449,652,765 |
83 | hey guys so this is problem 83 remove duplicates from sorted list right it is an easy problem and uh let's start with the problem statement so given the head of a sorted list so first of all the thing that has to be mentioned here that is mentioned here is that the list is going to be a sorted list so okay so delete al... | 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 |
1,189 | hello let's do this easy question today uh maximum number of balloons are you given a string text and you want to find out how many times can you write the word balloon out of the characters from text and can use each character only once so like for example in example two you have a b you have two b's you have two a's ... | Maximum Number of Balloons | encode-number | Given a string `text`, you want to use the characters of `text` to form as many instances of the word **"balloon "** as possible.
You can use each character in `text` **at most once**. Return the maximum number of instances that can be formed.
**Example 1:**
**Input:** text = "nlaebolko "
**Output:** 1
**Example 2... | Try to find the number of binary digits returned by the function. The pattern is to start counting from zero after determining the number of binary digits. | Math,String,Bit Manipulation | Medium | 1070 |
103 | today we're looking at lead code number 103 binary tree zigzag level order traversal this is a continuation on the series of level order traversal questions that we have in this playlist it's going to use the same exact pattern as we use for binary tree level order traversal 1 and 2 as well as n area tree level order t... | 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 |
382 | The festival today we will discuss the network problem number is 382 problem is click please channel note what is it that we have the thing listed ok and what we have to do is to set a friend value and that random note why value Less than retaining I rental value this contingent back if and come back to my channel betw... | Linked List Random Node | linked-list-random-node | Given a singly linked list, return a random node's value from the linked list. Each node must have the **same probability** of being chosen.
Implement the `Solution` class:
* `Solution(ListNode head)` Initializes the object with the head of the singly-linked list `head`.
* `int getRandom()` Chooses a node randoml... | null | Linked List,Math,Reservoir Sampling,Randomized | Medium | 398 |
162 | everyone welcome to my channel so in this video i'm going to introduce uh how we are going to solve this problem called find peak element and before we start the content for this video i would invite you to help subscribe this channel because it can really help this channel to grow thanks a lot so let's get started a p... | Find Peak Element | find-peak-element | A peak element is an element that is strictly greater than its neighbors.
Given a **0-indexed** integer array `nums`, find a peak element, and return its index. If the array contains multiple peaks, return the index to **any of the peaks**.
You may imagine that `nums[-1] = nums[n] = -∞`. In other words, an element is... | null | Array,Binary Search | Medium | 882,2047,2273,2316 |
1,046 | hello everyone today we are going to solve a very easy problem which is the last stone weight so in this problem we are given an area of histones where strong eye is the weight of the ith stone we have to choose two heaviest stone and if mesh them together if their weight are equal then both stones will be destroyed an... | 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 |
246 | hello and welcome to the next video of python bytes problem solving in this video we will see how to write a program to find all strobogrammatic numbers with n digits in this problem we are going to create a program that finds all strobogamatic numbers with n digits so what is a strobogrammatic number a stopogrammatic ... | Strobogrammatic Number | strobogrammatic-number | Given a string `num` which represents an integer, return `true` _if_ `num` _is a **strobogrammatic number**_.
A **strobogrammatic number** is a number that looks the same when rotated `180` degrees (looked at upside down).
**Example 1:**
**Input:** num = "69 "
**Output:** true
**Example 2:**
**Input:** num = "88... | null | Hash Table,Two Pointers,String | Easy | 247,248,1069 |
1,952 | Hello hello everyone welcome to some tips on n Is device of in the resistance in more fuel like this soudians king david and returns through the big b positive and definition of multiple should that tubelight you can find only a 200 aa and is winfree device not that office number like this overview country or Fever num... | Three Divisors | minimum-sideway-jumps | Given an integer `n`, return `true` _if_ `n` _has **exactly three positive divisors**. Otherwise, return_ `false`.
An integer `m` is a **divisor** of `n` if there exists an integer `k` such that `n = k * m`.
**Example 1:**
**Input:** n = 2
**Output:** false
**Explantion:** 2 has only two divisors: 1 and 2.
**Exampl... | At a given point, there are only 3 possible states for where the frog can be. Check all the ways to move from one point to the next and update the minimum side jumps for each lane. | Array,Dynamic Programming,Greedy | Medium | 403 |
458 | hello everyone welcome to coding decoded my name is sanchez i'm working as technical architect at adobe and i am slightly unwell today i have mild fever and gold so i'll keep this video short and to the point so i'll be walking you through the question as well as the algorithm by the presentation so let's quickly hop o... | Poor Pigs | poor-pigs | There are `buckets` buckets of liquid, where **exactly one** of the buckets is poisonous. To figure out which one is poisonous, you feed some number of (poor) pigs the liquid to see whether they will die or not. Unfortunately, you only have `minutesToTest` minutes to determine which bucket is poisonous.
You can feed t... | What if you only have one shot? Eg. 4 buckets, 15 mins to die, and 15 mins to test. How many states can we generate with x pigs and T tests? Find minimum x such that (T+1)^x >= N | Math,Dynamic Programming,Combinatorics | Hard | null |
399 | hey everybody this is larry this is day 27 of the lead code daily challenge uh hit the like button to subscribe and join me on discord let me know what you think about today's problem uh today in today's problem is evaluate division okay so you're given equations a over b is equal to k okay no division by zero no contr... | Evaluate Division | evaluate-division | You are given an array of variable pairs `equations` and an array of real numbers `values`, where `equations[i] = [Ai, Bi]` and `values[i]` represent the equation `Ai / Bi = values[i]`. Each `Ai` or `Bi` is a string that represents a single variable.
You are also given some `queries`, where `queries[j] = [Cj, Dj]` rep... | Do you recognize this as a graph problem? | Array,Depth-First Search,Breadth-First Search,Union Find,Graph,Shortest Path | Medium | null |
46 | hey how's it going this is computer red and in this video we are going to look at the lit code problem number 46 called permutations this problem will serve as an introduction to backtracking so the description of this problem is quite simple so given a collection of distinct integers return all possible permutations s... | Permutations | permutations | Given an array `nums` of distinct integers, return _all the possible permutations_. You can return the answer in **any order**.
**Example 1:**
**Input:** nums = \[1,2,3\]
**Output:** \[\[1,2,3\],\[1,3,2\],\[2,1,3\],\[2,3,1\],\[3,1,2\],\[3,2,1\]\]
**Example 2:**
**Input:** nums = \[0,1\]
**Output:** \[\[0,1\],\[1,0\... | null | Array,Backtracking | Medium | 31,47,60,77 |
220 | That's a hello hi guys relation side so today we are going to do the difference of balance in patience between in that manner as quickly as possible 09 that the difference of the balance on which the difference is lying should be the loosening point and the temperature of the Indians is useless. Should I do something t... | Contains Duplicate III | contains-duplicate-iii | You are given an integer array `nums` and two integers `indexDiff` and `valueDiff`.
Find a pair of indices `(i, j)` such that:
* `i != j`,
* `abs(i - j) <= indexDiff`.
* `abs(nums[i] - nums[j]) <= valueDiff`, and
Return `true` _if such pair exists or_ `false` _otherwise_.
**Example 1:**
**Input:** nums = \[1... | Time complexity O(n logk) - This will give an indication that sorting is involved for k elements. Use already existing state to evaluate next state - Like, a set of k sorted numbers are only needed to be tracked. When we are processing the next number in array, then we can utilize the existing sorted state and it is... | Array,Sliding Window,Sorting,Bucket Sort,Ordered Set | Medium | 217,219 |
867 | on everyone so today we are looking at lead code number 867 it's a question called transpose matrix these matrix questions can be a real headache sometimes but i think if you go step by step on this one uh it's not too bad and it's good to know this one just know the pattern underneath it because there's another a lot ... | Transpose Matrix | new-21-game | Given a 2D integer array `matrix`, return _the **transpose** of_ `matrix`.
The **transpose** of a matrix is the matrix flipped over its main diagonal, switching the matrix's row and column indices.
**Example 1:**
**Input:** matrix = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\]
**Output:** \[\[1,4,7\],\[2,5,8\],\[3,6,9\]\]
**E... | null | Math,Dynamic Programming,Sliding Window,Probability and Statistics | Medium | null |
167 | all right this is 167 to sum the second version where the input array is sorted already it's sorted in non-decreasing already it's sorted in non-decreasing already it's sorted in non-decreasing order meaning ascending order and you're supposed to find two numbers that add up to a specific Target and you're supposed to ... | 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 |
863 | 200 Hello everyone welcome to my channel so in this video I am going to explain to you this binary free problem of all notes distance which is a very good problem and was also asked in one of the interviews so first we will discuss the problem a cup of this We will add semolina and we will quote, then basically in the ... | All Nodes Distance K in Binary Tree | sum-of-distances-in-tree | Given the `root` of a binary tree, the value of a target node `target`, and an integer `k`, return _an array of the values of all nodes that have a distance_ `k` _from the target node._
You can return the answer in **any order**.
**Example 1:**
**Input:** root = \[3,5,1,6,2,0,8,null,null,7,4\], target = 5, k = 2
**O... | null | Dynamic Programming,Tree,Depth-First Search,Graph | Hard | 1021,2175 |
36 | hello everyone welcome back and today we are looking at question 36 which is valid sudoku now instead of reading the description of the question i will go straight to the blackboard explain what sudoku is and explain the rules of the game and finally show you how simple this question can get alright so let's get straig... | Valid Sudoku | valid-sudoku | Determine if a `9 x 9` Sudoku board is valid. Only the filled cells need to be validated **according to the following rules**:
1. Each row must contain the digits `1-9` without repetition.
2. Each column must contain the digits `1-9` without repetition.
3. Each of the nine `3 x 3` sub-boxes of the grid must contain... | null | Array,Hash Table,Matrix | Medium | 37,2254 |
201 | hello everyone welcome to Mayu programming club today we will be solving another daily code problem and the problem's name is bitwise end of numbers range so the problem statement goes like this given two integers left and right that represents the range of uh left and right both inclusive return the bitwise and of all... | 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 |
764 | Scientist A Hello Hi How Are You Hi What Are You Doing Good Welcome To The Record So City Will Do The Largest Per Sign In This Is It Is Given That You Have A Matrix Of Band Se Will Show You To Find The Maximum One You Wish You Can Make Show Apps Please Mention In This One So In This Day That Someone Else Becomes 100 Ko... | Largest Plus Sign | n-ary-tree-level-order-traversal | You are given an integer `n`. You have an `n x n` binary grid `grid` with all values initially `1`'s except for some indices given in the array `mines`. The `ith` element of the array `mines` is defined as `mines[i] = [xi, yi]` where `grid[xi][yi] == 0`.
Return _the order of the largest **axis-aligned** plus sign of_ ... | null | Tree,Breadth-First Search | Medium | 102,775,776,2151 |
69 | in this video we'll go over leak code question number 69 Square < t x given a question number 69 Square < t x given a question number 69 Square < t x given a non- negative integer X we need to non- negative integer X we need to non- negative integer X we need to return the non- negative s otk of X return the n... | Sqrt(x) | sqrtx | Given a non-negative integer `x`, return _the square root of_ `x` _rounded down to the nearest integer_. The returned integer should be **non-negative** as well.
You **must not use** any built-in exponent function or operator.
* For example, do not use `pow(x, 0.5)` in c++ or `x ** 0.5` in python.
**Example 1:**
... | Try exploring all integers. (Credits: @annujoshi) Use the sorted property of integers to reduced the search space. (Credits: @annujoshi) | Math,Binary Search | Easy | 50,367 |
1,466 | hello friends so today we gonna discuss this problem from the it quote we click on test 191 problem number one four six reorder routes to make all paths lead to ct0 so you can read the statement but the statement actually states that there are n cities with numbers from 0 till n minus 1 and they are directional which m... | Reorder Routes to Make All Paths Lead to the City Zero | jump-game-v | There are `n` cities numbered from `0` to `n - 1` and `n - 1` roads such that there is only one way to travel between two different cities (this network form a tree). Last year, The ministry of transport decided to orient the roads in one direction because they are too narrow.
Roads are represented by `connections` wh... | Use dynamic programming. dp[i] is max jumps you can do starting from index i. Answer is max(dp[i]). dp[i] = 1 + max (dp[j]) where j is all indices you can reach from i. | Array,Dynamic Programming,Sorting | Hard | 2001 |
93 | right so we have given to the equation is a restore IP address and we have discussed about this so I will recommend you please go for the first part of this video and uh understand how we have implemented the uh backtracking okay so in the backtracking what we have taken a list right that is a list of string and we wil... | Restore IP Addresses | restore-ip-addresses | A **valid IP address** consists of exactly four integers separated by single dots. Each integer is between `0` and `255` (**inclusive**) and cannot have leading zeros.
* For example, `"0.1.2.201 "` and `"192.168.1.1 "` are **valid** IP addresses, but `"0.011.255.245 "`, `"192.168.1.312 "` and `"192.168@1.1 "` are **... | null | String,Backtracking | Medium | 752 |
869 | hello guys welcome to algorithms made easy today we will be discussing the question reordered power of 2 in this question we are given a positive integer n and we need to reorder the digits in any order including the original order such that the leading digit is not zero we need to return true if and only if we can do ... | Reordered Power of 2 | similar-string-groups | You are given an integer `n`. We reorder the digits in any order (including the original order) such that the leading digit is not zero.
Return `true` _if and only if we can do this so that the resulting number is a power of two_.
**Example 1:**
**Input:** n = 1
**Output:** true
**Example 2:**
**Input:** n = 10
**... | null | Array,String,Depth-First Search,Breadth-First Search,Union Find | Hard | 2276 |
859 | Hello hello bigs today in this video will be the big spring problem of the year so give me two strings and video up lower case letters written true if you can set up two letters in a solid gold ruby opposite return letters in a solid gold ruby opposite return letters in a solid gold ruby opposite return forms swa... | Buddy Strings | design-circular-deque | Given two strings `s` and `goal`, return `true` _if you can swap two letters in_ `s` _so the result is equal to_ `goal`_, otherwise, return_ `false`_._
Swapping letters is defined as taking two indices `i` and `j` (0-indexed) such that `i != j` and swapping the characters at `s[i]` and `s[j]`.
* For example, swappi... | null | Array,Linked List,Design,Queue | Medium | 860,1767 |
879 | hey everybody this is Larry this is day 21st of the April legal daily challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's Farm I'm still having some allergy things so have you uh catch me like pausing of it is because um my mouth is very itchy not gonna lie... | 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 |
257 | how's it going guys today we're gonna be going over another league good question today our question is from Amazon and it's called binary tree paths alright guys today our question is called binary tree paths again it's a questions being asked by Amazon and a problem description says it's given a binary tree return all... | Binary Tree Paths | binary-tree-paths | Given the `root` of a binary tree, return _all root-to-leaf paths in **any order**_.
A **leaf** is a node with no children.
**Example 1:**
**Input:** root = \[1,2,3,null,5\]
**Output:** \[ "1->2->5 ", "1->3 "\]
**Example 2:**
**Input:** root = \[1\]
**Output:** \[ "1 "\]
**Constraints:**
* The number of nodes ... | null | String,Backtracking,Tree,Depth-First Search,Binary Tree | Easy | 113,1030,2217 |
1,046 | hello everyone welcome to day 7th of april challenge and i hope all of you are having a great time my name is anchor deja i'm working a software developer for at adobe and today i represent 650th video solution of lead code daily challenges the question that we have in today's last stone weight here in this question we... | 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 |
310 | hello fellow engineers it's luke here um today i'm going to be doing leak code problem 310 i chose this problem because i was just looking over it for uh looking over exercises that i could give to one of my students and i found this problem and it jumped out to me as one that i have no idea immediately how i would sol... | Minimum Height Trees | minimum-height-trees | A tree is an undirected graph in which any two vertices are connected by _exactly_ one path. In other words, any connected graph without simple cycles is a tree.
Given a tree of `n` nodes labelled from `0` to `n - 1`, and an array of `n - 1` `edges` where `edges[i] = [ai, bi]` indicates that there is an undirected edg... | How many MHTs can a graph have at most? | Depth-First Search,Breadth-First Search,Graph,Topological Sort | Medium | 207,210 |
1,005 | Hello Friends This Youth Welcome to our Channel Ko Def YouTube Channel Please subscribe and press the Bell Icon Student Union More Videos Without Going Video Start [ Video Start [ Video Start Hello Friends Talking Questions in Today's Video Maximum Favorite Song Chapter Key Negation OK So let's open the question maximu... | Maximize Sum Of Array After K Negations | univalued-binary-tree | Given an integer array `nums` and an integer `k`, modify the array in the following way:
* choose an index `i` and replace `nums[i]` with `-nums[i]`.
You should apply this process exactly `k` times. You may choose the same index `i` multiple times.
Return _the largest possible sum of the array after modifying it i... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Easy | 1609 |
40 | Hello Viewers Welcome Back to Channel Commission Setting Extremely Well City Will Be Solving Key Problem Combination Sham to Front This Seat Per Before Moving Onto Key Problem This YouTube Channel 30 Ukraine Subscribe and Channel All Problems Status Bank Collection of Candidate Numbers Will Also Be Given no target numb... | Combination Sum II | combination-sum-ii | Given a collection of candidate numbers (`candidates`) and a target number (`target`), find all unique combinations in `candidates` where the candidate numbers sum to `target`.
Each number in `candidates` may only be used **once** in the combination.
**Note:** The solution set must not contain duplicate combinations.... | null | Array,Backtracking | Medium | 39 |
44 | one will come to above the training the coldest solution if you want the best a software engineer market interview experience in North America feel free to check out us check us out at paltry needle org we're here to help you and also you know I just realized we have this very cool awesome videos on our show pretty nic... | Wildcard Matching | wildcard-matching | Given an input string (`s`) and a pattern (`p`), implement wildcard pattern matching with support for `'?'` and `'*'` where:
* `'?'` Matches any single character.
* `'*'` Matches any sequence of characters (including the empty sequence).
The matching should cover the **entire** input string (not partial).
**Exam... | null | String,Dynamic Programming,Greedy,Recursion | Hard | 10 |
371 | welcome to this video now we're going to cover a coding interview question sum of two integers here's the problem statement calculate the sum of two integers a and b but you are not allowed to use the operator plus and minus addition and subtraction how you can solve this problem to solve this type of problems we have ... | Sum of Two Integers | sum-of-two-integers | Given two integers `a` and `b`, return _the sum of the two integers without using the operators_ `+` _and_ `-`.
**Example 1:**
**Input:** a = 1, b = 2
**Output:** 3
**Example 2:**
**Input:** a = 2, b = 3
**Output:** 5
**Constraints:**
* `-1000 <= a, b <= 1000` | null | Math,Bit Manipulation | Medium | 2 |
1,980 | hi so today we are going to solve lead code problem 1980 find unique binary string so problem statement is like they are giving a array of string and each string having length n so the length of each string exactly the number equ equal to the number of string that we are having in the array like here we are having two ... | 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 |
171 | foreign title and you have to written the corresponding column number so if this is the first column B is the second currency is the all combinations are there so starts from a then till set again after this a gone till is that will go from zda to Z and this list continues for the it just it doesn't stop here thanks so... | Excel Sheet Column Number | excel-sheet-column-number | Given a string `columnTitle` that represents the column title as appears in an Excel sheet, return _its corresponding column number_.
For example:
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
...
**Example 1:**
**Input:** columnTitle = "A "
**Output:** 1
**Example 2:**
**Input:** columnTitle = "AB "
**Ou... | null | Math,String | Easy | 168,2304 |
1,870 | um hello so today we are going to do this problem which is part of Fleet code daily challenge minimum speed to arrive on time so here we have a floating Point number hour that we get in the input um and this represents the amount of time you have to reach the office so you are going from one point to the office so for ... | Minimum Speed to Arrive on Time | minimum-speed-to-arrive-on-time | You are given a floating-point number `hour`, representing the amount of time you have to reach the office. To commute to the office, you must take `n` trains in sequential order. You are also given an integer array `dist` of length `n`, where `dist[i]` describes the distance (in kilometers) of the `ith` train ride.
E... | null | null | Medium | null |
528 | hey what's up guys this is shown here again and so this time I want to talk about this later called problem number five hundred and twenty eight random pick with weight right so basically we're given like an array with in with positive integers each element of the array represents the weight after currently index for e... | 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 |
1,926 | Welcome back, I have given you a channel from there, you enter from there and what do you have to do, exit and exit point, which is the exit point, which are the points and where do you enter from, you are entering from an entrance point, but what do you have to do? What we have to do is to reach the exit point as quic... | Nearest Exit from Entrance in Maze | products-price-for-each-store | You are given an `m x n` matrix `maze` (**0-indexed**) with empty cells (represented as `'.'`) and walls (represented as `'+'`). You are also given the `entrance` of the maze, where `entrance = [entrancerow, entrancecol]` denotes the row and column of the cell you are initially standing at.
In one step, you can move o... | null | Database | Easy | 1948 |
993 | Hello Welcome To Day Gift Rather Subscribe Appointed Nodal subscribe to subscribe our suggestion fog subscribe Video subscribe to whatever question it's also given the internet to keep track of the series bane stuart finn ur amazing fluoride subscribe Video subscribe The Channel subscribe Now Already SUBSCRIBE TO TU UN... | Cousins in Binary Tree | tallest-billboard | Given the `root` of a binary tree with unique values and the values of two different nodes of the tree `x` and `y`, return `true` _if the nodes corresponding to the values_ `x` _and_ `y` _in the tree are **cousins**, or_ `false` _otherwise._
Two nodes of a binary tree are **cousins** if they have the same depth with d... | null | Array,Dynamic Programming | Hard | 2162 |
449 | hey guys welcome back to another video and today we're going to be solving the lee code question serialize and deserialize a binary search tree all right so let's just start off with what exactly serialization means so serialization is converting a data structure or an object into a sequence of bits so that it can be s... | 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 |
90 | hey everyone welcome back and let's write some more neat code today so today let's solve the problem subsets 2. we did solve the first one of this and that was actually a long time ago and people have been requesting i solved this one as well so let's do it today the first one is actually very similar to this one the o... | Subsets II | subsets-ii | Given an integer array `nums` that may contain duplicates, return _all possible_ _subsets_ _(the power set)_.
The solution set **must not** contain duplicate subsets. Return the solution in **any order**.
**Example 1:**
**Input:** nums = \[1,2,2\]
**Output:** \[\[\],\[1\],\[1,2\],\[1,2,2\],\[2\],\[2,2\]\]
**Example... | null | Array,Backtracking,Bit Manipulation | Medium | 78,2109 |
6 | hello friends welcome to good Hecker disco tutorial here we are going to solve zig zag conversion code in public the string paper is hiding is written in a zig-zag pattern on a given number of a zig-zag pattern on a given number of a zig-zag pattern on a given number of those like this you may want to display this patt... | 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 |
474 | welcome to april's lego challenge today's problem is ones and zeros you are given an array of binary strings and two integers m and n return the size of the largest subset of strings such that there are most m zeros and n ones inside the subset a set x is a subset of a set y if all elements of x are also elements of y ... | Ones and Zeroes | ones-and-zeroes | You are given an array of binary strings `strs` and two integers `m` and `n`.
Return _the size of the largest subset of `strs` such that there are **at most**_ `m` `0`_'s and_ `n` `1`_'s in the subset_.
A set `x` is a **subset** of a set `y` if all elements of `x` are also elements of `y`.
**Example 1:**
**Input:**... | null | Array,String,Dynamic Programming | Medium | 510,600,2261 |
11 | Hi Everyone Welcome Back To A New Video Today We Are Going To See A New Question From Top Interview 150 And The Question Is A Two Pointer Base Question Which Is Container With Most Water This Is A Medium Level Question Now Let's Move On To The Problem Description So let's see the problem description now in this problem... | Container With Most Water | container-with-most-water | You are given an integer array `height` of length `n`. There are `n` vertical lines drawn such that the two endpoints of the `ith` line are `(i, 0)` and `(i, height[i])`.
Find two lines that together with the x-axis form a container, such that the container contains the most water.
Return _the maximum amount of water... | The aim is to maximize the area formed between the vertical lines. The area of any container is calculated using the shorter line as length and the distance between the lines as the width of the rectangle.
Area = length of shorter vertical line * distance between lines
We can definitely get the maximum width ... | Array,Two Pointers,Greedy | Medium | 42 |
451 | Jhaal Hello Hi How are you love you all doing good welcome to the learn co disney today will solve question tips and character frequency and social media level question and will solve discussion and even after you upload e used is on time urine se if chunri show Fear of approach how we will do soul slow agency the exam... | Sort Characters By Frequency | sort-characters-by-frequency | Given a string `s`, sort it in **decreasing order** based on the **frequency** of the characters. The **frequency** of a character is the number of times it appears in the string.
Return _the sorted string_. If there are multiple answers, return _any of them_.
**Example 1:**
**Input:** s = "tree "
**Output:** "eer... | null | Hash Table,String,Sorting,Heap (Priority Queue),Bucket Sort,Counting | Medium | 347,387,1741 |
910 | Hello Everyone Welcome to Twenty Possibly DSP SS Master and Second in this Question Don't Give and You Can Perform Special Operation Inch Element Director Vikram Arya's Tweet A Number's Tweet and Aircraft Number's Promise Land Acquisition Subscribe to the Subscribe button and Subscribe color soya sauce MB setting which... | Smallest Range II | nth-magical-number | You are given an integer array `nums` and an integer `k`.
For each index `i` where `0 <= i < nums.length`, change `nums[i]` to be either `nums[i] + k` or `nums[i] - k`.
The **score** of `nums` is the difference between the maximum and minimum elements in `nums`.
Return _the minimum **score** of_ `nums` _after changi... | null | Math,Binary Search | Hard | null |
437 | hey there F coders welcome back to another episode on COD Master Quest in today's episode we are going to tackle another question related to the binary trees so let's get started and find the problem statement on Le code the problem is path given the root of a bin tree and integer like Target sum return the number of p... | Path Sum III | path-sum-iii | Given the `root` of a binary tree and an integer `targetSum`, return _the number of paths where the sum of the values along the path equals_ `targetSum`.
The path does not need to start or end at the root or a leaf, but it must go downwards (i.e., traveling only from parent nodes to child nodes).
**Example 1:**
**In... | null | Tree,Depth-First Search,Binary Tree | Medium | 112,113,666,687 |
88 | we're looking at lead code number 88 it's called merge sorted array and so here we're giving two sorted integer arrays num1 and num2 and we're going to merge nums 2 into num1 as one sorted array and the number of elements initialized num1 and num2 are m and n respectively and we can assume that num1 has in size equal t... | 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 |
764 | in a 2d grid thumb - silly - when every in a 2d grid thumb - silly - when every in a 2d grid thumb - silly - when every cell contains of one except for those who come into this mines which are zero what is the largest access a line plus sign of once contained in a cleared we turned the order on to plus sign + n9 we tur... | Largest Plus Sign | n-ary-tree-level-order-traversal | You are given an integer `n`. You have an `n x n` binary grid `grid` with all values initially `1`'s except for some indices given in the array `mines`. The `ith` element of the array `mines` is defined as `mines[i] = [xi, yi]` where `grid[xi][yi] == 0`.
Return _the order of the largest **axis-aligned** plus sign of_ ... | null | Tree,Breadth-First Search | Medium | 102,775,776,2151 |
63 | Hello friends welcome to code Sutra and have a wonderful day in this video we'll be discussing about lead code problem number 63 unique paths 2. in this problem we are given a m cross n Matrix and we are also given obstacle at some point and this will be the starting point and this will be our ending part the starting ... | Unique Paths II | unique-paths-ii | You are given an `m x n` integer array `grid`. There is a robot initially located at the **top-left corner** (i.e., `grid[0][0]`). The robot tries to move to the **bottom-right corner** (i.e., `grid[m - 1][n - 1]`). The robot can only move either down or right at any point in time.
An obstacle and space are marked as ... | The robot can only move either down or right. Hence any cell in the first row can only be reached from the cell left to it. However, if any cell has an obstacle, you don't let that cell contribute to any path. So, for the first row, the number of ways will simply be
if obstacleGrid[i][j] is not an obstacle
... | Array,Dynamic Programming,Matrix | Medium | 62,1022 |
76 | Hello everyone, today we will give question number 5 of our sliding window mechanism, it is a hard level question of the delete code, so you will not find it hard, okay and we will make it easy, the name of the question is and it is a very good question, okay So this shows how popular and good the question will be. Oka... | 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 |
68 | hello and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem 68 text justification before we read the question prompt i just want to say that 78.6 of you that are watching this 78.6 of you that are watching this 78.6 of you that are watching this channel are not subscrib... | Text Justification | text-justification | Given an array of strings `words` and a width `maxWidth`, format the text such that each line has exactly `maxWidth` characters and is fully (left and right) justified.
You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces `' '` when necessary so that ea... | null | Array,String,Simulation | Hard | 1714,2260 |
910 | hey everybody this is larry this is me going over day 21 of the league code daily uh challenge on lead code uh hit the like button in the subscriber and join me on discord uh as usual i actually solve these live and i do the um explanation live so however for this problem i actually had a lot of issues of it uh it took... | Smallest Range II | nth-magical-number | You are given an integer array `nums` and an integer `k`.
For each index `i` where `0 <= i < nums.length`, change `nums[i]` to be either `nums[i] + k` or `nums[i] - k`.
The **score** of `nums` is the difference between the maximum and minimum elements in `nums`.
Return _the minimum **score** of_ `nums` _after changi... | null | Math,Binary Search | Hard | null |
1,658 | hey everyone today we are going to solve the ration minimum operations to reduce X to Zero so you are given integer array nums and integer X in one operation you can either remove the leftmost or the rightmost element from the array NS and subtract its value from X note that this modifies the arrays for future operatio... | Minimum Operations to Reduce X to Zero | minimum-swaps-to-arrange-a-binary-grid | You are given an integer array `nums` and an integer `x`. In one operation, you can either remove the leftmost or the rightmost element from the array `nums` and subtract its value from `x`. Note that this **modifies** the array for future operations.
Return _the **minimum number** of operations to reduce_ `x` _to **e... | For each row of the grid calculate the most right 1 in the grid in the array maxRight. To check if there exist answer, sort maxRight and check if maxRight[i] ≤ i for all possible i's. If there exist an answer, simulate the swaps. | Array,Greedy,Matrix | Medium | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.