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 |
|---|---|---|---|---|---|---|---|---|
763 | all right let's talk about partition label so your given string of lowercase english later is given so you need to return the partition so for this a b c b a c a right the string the partition string is at most as possible so let each letter appear in at most one time so in this case every letter inside the inside a st... | Partition Labels | special-binary-string | You are given a string `s`. We want to partition the string into as many parts as possible so that each letter appears in at most one part.
Note that the partition is done so that after concatenating all the parts in order, the resultant string should be `s`.
Return _a list of integers representing the size of these ... | Draw a line from (x, y) to (x+1, y+1) if we see a "1", else to (x+1, y-1).
A special substring is just a line that starts and ends at the same y-coordinate, and that is the lowest y-coordinate reached.
Call a mountain a special substring with no special prefixes - ie. only at the beginning and end is the lowest y-coo... | String,Recursion | Hard | 678 |
1,854 | lead code 1854 maximum population year so the question is say that you'll be given uh an array which is nothing but a log of people who uh were born and the year they were they died in so this array is something like this so it gives details about each person say a person took birth in 1993 and died in 1999 okay so tha... | Maximum Population Year | maximum-population-year | You are given a 2D integer array `logs` where each `logs[i] = [birthi, deathi]` indicates the birth and death years of the `ith` person.
The **population** of some year `x` is the number of people alive during that year. The `ith` person is counted in year `x`'s population if `x` is in the **inclusive** range `[birthi... | null | null | Easy | null |
202 | what's going on everybody zane here back with another video for this one we've got question number 202 which is happy number on lead code so we need to write some algorithm to determine whether or not a number that we're given is happy a happy number is essentially going to be its numbers like if there was a number one... | Happy Number | happy-number | Write an algorithm to determine if a number `n` is happy.
A **happy number** is a number defined by the following process:
* Starting with any positive integer, replace the number by the sum of the squares of its digits.
* Repeat the process until the number equals 1 (where it will stay), or it **loops endlessly ... | null | Hash Table,Math,Two Pointers | Easy | 141,258,263,2076 |
1,588 | all right so let's talk about the sum of all of then sub array so you're giving a real positive integer array and calculate the sum of all possible all length separates so you have to return the sum of all of them sub array of array so this question consisted pretty hard so i'm going to give this guy credit so this is ... | Sum of All Odd Length Subarrays | sum-of-all-odd-length-subarrays | Given an array of positive integers `arr`, return _the sum of all possible **odd-length subarrays** of_ `arr`.
A **subarray** is a contiguous subsequence of the array.
**Example 1:**
**Input:** arr = \[1,4,2,5,3\]
**Output:** 58
**Explanation:** The odd-length subarrays of arr and their sums are:
\[1\] = 1
\[4\] = 4... | null | null | Easy | null |
1,889 | hey what's up guys uh this is chung here so this time bitcoin number 1889 minimum space wasted from packaging right okay so you're giving like un packages and you're trying to pull to place in the in some boxes right so one package per box and then we you have like m suppliers and each produce different size of boxes o... | Minimum Space Wasted From Packaging | check-if-number-is-a-sum-of-powers-of-three | You have `n` packages that you are trying to place in boxes, **one package in each box**. There are `m` suppliers that each produce boxes of **different sizes** (with infinite supply). A package can be placed in a box if the size of the package is **less than or equal to** the size of the box.
The package sizes are gi... | Let's note that the maximum power of 3 you'll use in your soln is 3^16 The number can not be represented as a sum of powers of 3 if it's ternary presentation has a 2 in it | Math | Medium | 326 |
226 | I am Ashok Hello friends blind 725 new day and today problem number five is born in Shagun's words for adultery easy problem the previous one BCE and this is so small that means we have been a lot of workers too so this is for and this phone is that route of ours. The voice message will remain the same, just add other ... | Invert Binary Tree | invert-binary-tree | Given the `root` of a binary tree, invert the tree, and return _its root_.
**Example 1:**
**Input:** root = \[4,2,7,1,3,6,9\]
**Output:** \[4,7,2,9,6,3,1\]
**Example 2:**
**Input:** root = \[2,1,3\]
**Output:** \[2,3,1\]
**Example 3:**
**Input:** root = \[\]
**Output:** \[\]
**Constraints:**
* The number of n... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Easy | null |
729 | hey everybody this is larry this is the 10th day of the june niko daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's problem uh i my ac is still booking it in case you're curious and wondering uh but i did figure i put on the t-shirt uh but i did fig... | My Calendar I | my-calendar-i | You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a **double booking**.
A **double booking** happens when two events have some non-empty intersection (i.e., some moment is common to both events.).
The event can be represented as a pair of integers `start... | Store the events as a sorted list of intervals. If none of the events conflict, then the new event can be added. | Design,Segment Tree,Ordered Set | Medium | 731,732 |
1,609 | hey guys let's understand the problem 1609 even odd trees okay it's bit a unique question uh this question let's read the question given a binary tree name even and odd if it meet the following conditions means uh we have to say if the tree is even or tree it will be only by these following conditions so let's understa... | Even Odd Tree | find-all-the-lonely-nodes | A binary tree is named **Even-Odd** if it meets the following conditions:
* The root of the binary tree is at level index `0`, its children are at level index `1`, their children are at level index `2`, etc.
* For every **even-indexed** level, all nodes at the level have **odd** integer values in **strictly increa... | Do a simple tree traversal, try to check if the current node is lonely or not. Node is lonely if at least one of the left/right pointers is null. | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Easy | 563,1005 |
1,217 | That's all Hello everyone welcome back to my channel today were going to discuss the problem is minimum cost to move chips to same position its very easy problem butter concept is very good so let's see what problems we have and ships where the position of IS CHIP IS POSITION I HAVE TORCH LIGHT VINNY TUNG ALL THE TIPS ... | Minimum Cost to Move Chips to The Same Position | relative-sort-array | We have `n` chips, where the position of the `ith` chip is `position[i]`.
We need to move all the chips to **the same position**. In one step, we can change the position of the `ith` chip from `position[i]` to:
* `position[i] + 2` or `position[i] - 2` with `cost = 0`.
* `position[i] + 1` or `position[i] - 1` with... | Using a hashmap, we can map the values of arr2 to their position in arr2. After, we can use a custom sorting function. | Array,Hash Table,Sorting,Counting Sort | Easy | null |
1,846 | hello hi guys good morning welcome back to a new video this maximum element after decreasing and rearranging I hope that you guys are doing good I hope that Changi now let's go see the it has been asked by Amazon not pretty much uh just in last one two years and not much frequently let's see uh it's marked as medium bu... | Maximum Element After Decreasing and Rearranging | maximum-element-after-decreasing-and-rearranging | You are given an array of positive integers `arr`. Perform some operations (possibly none) on `arr` so that it satisfies these conditions:
* The value of the **first** element in `arr` must be `1`.
* The absolute difference between any 2 adjacent elements must be **less than or equal to** `1`. In other words, `abs... | null | null | Medium | null |
987 | hi guys welcome to algorithms made easy today we will go through the day 7 problem from august lead coding challenge vertical order traversal of a binary tree please like the video and if you are new don't forget to subscribe to our channel so that you never miss any update given a binary tree we need to return the ver... | Vertical Order Traversal of a Binary Tree | reveal-cards-in-increasing-order | Given the `root` of a binary tree, calculate the **vertical order traversal** of the binary tree.
For each node at position `(row, col)`, its left and right children will be at positions `(row + 1, col - 1)` and `(row + 1, col + 1)` respectively. The root of the tree is at `(0, 0)`.
The **vertical order traversal** o... | null | Array,Queue,Sorting,Simulation | Medium | null |
309 | hey what is up everybody welcome back to my channel this is a part two of um the problem 309 and uh previously we had an intuitive attempt trying to solve the problem by breaking uh this stock buy and sell problem into sub problems um by you know cutting the entire array of prices into different uh smaller chunks but l... | Best Time to Buy and Sell Stock with Cooldown | best-time-to-buy-and-sell-stock-with-cooldown | You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day.
Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times) with the following restrictions:
* After you sell your stock, yo... | null | Array,Dynamic Programming | Medium | 121,122 |
142 | hey guys welcome back to another video and today we're going to be solving the lead code question linked cycle 2. sorry linked list cycle 2. all right so in this question we're going to be given a linked list and we want to return the node where the cycle begins and if there is no cycle we're going to end up returning ... | Linked List Cycle II | linked-list-cycle-ii | Given the `head` of a linked list, return _the node where the cycle begins. If there is no cycle, return_ `null`.
There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the `next` pointer. Internally, `pos` is used to denote the index of the node that ta... | null | Hash Table,Linked List,Two Pointers | Medium | 141,287 |
352 | so here we are given within data stream input of non-negative integer A1 to n input of non-negative integer A1 to n input of non-negative integer A1 to n and we have to summarize the number seen so far as a list of design intervals so I have made a small presentation regarding the question and explaining the example wh... | Data Stream as Disjoint Intervals | data-stream-as-disjoint-intervals | Given a data stream input of non-negative integers `a1, a2, ..., an`, summarize the numbers seen so far as a list of disjoint intervals.
Implement the `SummaryRanges` class:
* `SummaryRanges()` Initializes the object with an empty stream.
* `void addNum(int value)` Adds the integer `value` to the stream.
* `int... | null | Binary Search,Design,Ordered Set | Hard | 228,436,715 |
212 | hello and welcome back to another Elite code problem so today we're going to be doing problem number 212 word search two so we're given an M by n Board of characters and a list of strings and we need to return all words on the board each word must be constructed from letters of sequential adjacent cells where Jason cel... | 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 |
228 | foreign thank you foreign coming up thank you foreign welcome to this tutorial on solving the lead code problem summary ranges in this video we will tackle an interesting problem that involves efficiently finding and summarizing consecutive ranges within a sorted array this problem asks us to take a sorted array of uni... | Summary Ranges | summary-ranges | You are given a **sorted unique** integer array `nums`.
A **range** `[a,b]` is the set of all integers from `a` to `b` (inclusive).
Return _the **smallest sorted** list of ranges that **cover all the numbers in the array exactly**_. That is, each element of `nums` is covered by exactly one of the ranges, and there is... | null | Array | Easy | 163,352 |
977 | hey what's up guys and quite here - tech hey what's up guys and quite here - tech hey what's up guys and quite here - tech encoding stuff on Twitch in YouTube and I do all the Waco problems I got a million up right now not a million but a lot so check those out if you're looking for solutions on leak code problems and ... | Squares of a Sorted Array | distinct-subsequences-ii | Given an integer array `nums` sorted in **non-decreasing** order, return _an array of **the squares of each number** sorted in non-decreasing order_.
**Example 1:**
**Input:** nums = \[-4,-1,0,3,10\]
**Output:** \[0,1,9,16,100\]
**Explanation:** After squaring, the array becomes \[16,1,0,9,100\].
After sorting, it be... | null | String,Dynamic Programming | Hard | 2115 |
95 | Hello everyone, welcome to me, we are going to do channel 54 and you can also see the playlist of DP construction. If you want to understand DP from the beginner level, then okay 95 is the medium mark but it is very easy because we have already done it. I have solved the question, I have given its link in the descripti... | Unique Binary Search Trees II | unique-binary-search-trees-ii | Given an integer `n`, return _all the structurally unique **BST'**s (binary search trees), which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`. Return the answer in **any order**.
**Example 1:**
**Input:** n = 3
**Output:** \[\[1,null,2,null,3\],\[1,null,3,2\],\[2,1,3\],\[3,1,null,null,2\],\[3,2,null,1\... | null | Dynamic Programming,Backtracking,Tree,Binary Search Tree,Binary Tree | Medium | 96,241 |
91 | hi all welcome back to cracking the fang interviews today i'm going to be talking about lead code number 91 which is decode ways this is again a recursion or dynamic programming problem that is very popular in interviews it's been lately asked at google amazon microsoft salesforce and i've also seen being asked at face... | Decode Ways | decode-ways | A message containing letters from `A-Z` can be **encoded** into numbers using the following mapping:
'A' -> "1 "
'B' -> "2 "
...
'Z' -> "26 "
To **decode** an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For examp... | null | String,Dynamic Programming | Medium | 639,2091 |
417 | So hello friends, welcome to the new video of Ticket, today is our 70th day, we are going to finish it soon, Pacific Atlantic Water Flow, okay, this is a medium type of question and what is the question trying to say, you can read the statement. There is a link to both the question and the answer. I will give it in the... | Pacific Atlantic Water Flow | pacific-atlantic-water-flow | There is an `m x n` rectangular island that borders both the **Pacific Ocean** and **Atlantic Ocean**. The **Pacific Ocean** touches the island's left and top edges, and the **Atlantic Ocean** touches the island's right and bottom edges.
The island is partitioned into a grid of square cells. You are given an `m x n` i... | null | Array,Depth-First Search,Breadth-First Search,Matrix | Medium | null |
942 | okay cool 942 di strain match given a string s that only contains I or D that n is to go the length of the string we turn any permutation a of just some way such that for or I guess suffice you can add and well yeah a survival item it 10 the next car gets bigger if not then if it's teeth and it's smaller okay and they ... | DI String Match | super-palindromes | A permutation `perm` of `n + 1` integers of all the integers in the range `[0, n]` can be represented as a string `s` of length `n` where:
* `s[i] == 'I'` if `perm[i] < perm[i + 1]`, and
* `s[i] == 'D'` if `perm[i] > perm[i + 1]`.
Given a string `s`, reconstruct the permutation `perm` and return it. If there are ... | null | Math,Enumeration | Hard | null |
22 | Hello friends, welcome to the new video, question number 22 Let's generate code for parents, this is a medium level question, this is a question about backtracking, you people will find this question on the internet, it has been asked in Facebook and Microsoft, let's start with the right function to generate all combin... | Generate Parentheses | generate-parentheses | Given `n` pairs of parentheses, write a function to _generate all combinations of well-formed parentheses_.
**Example 1:**
**Input:** n = 3
**Output:** \["((()))","(()())","(())()","()(())","()()()"\]
**Example 2:**
**Input:** n = 1
**Output:** \["()"\]
**Constraints:**
* `1 <= n <= 8` | null | String,Dynamic Programming,Backtracking | Medium | 17,20,2221 |
902 | hey what's up guys this is chung here again so this time let's take a look at today's daily challenge problem number 902 numbers at most any given digit set so this is a very interesting hard problem because this is more like it's related to the digits and it also asks you to use the dp concept to solve it basically th... | Numbers At Most N Given Digit Set | minimum-number-of-refueling-stops | Given an array of `digits` which is sorted in **non-decreasing** order. You can write numbers using each `digits[i]` as many times as we want. For example, if `digits = ['1','3','5']`, we may write numbers such as `'13'`, `'551'`, and `'1351315'`.
Return _the number of positive integers that can be generated_ that are... | null | Array,Dynamic Programming,Greedy,Heap (Priority Queue) | Hard | null |
1,408 | hi my name is david today we're going to do number 1408 string matching in array this is an easy level problem on lead code and we're going to solve it in javascript so the prop is we're giving an array of string an array of strings here and we want to return all the strings in words this input which is a substring of ... | String Matching in an Array | find-the-smallest-divisor-given-a-threshold | Given an array of string `words`, return _all strings in_ `words` _that is a **substring** of another word_. You can return the answer in **any order**.
A **substring** is a contiguous sequence of characters within a string
**Example 1:**
**Input:** words = \[ "mass ", "as ", "hero ", "superhero "\]
**Output:** \[ "... | Examine every possible number for solution. Choose the largest of them. Use binary search to reduce the time complexity. | Array,Binary Search | Medium | 2188 |
1,288 | Jhaal Hello Hi Guys Welcome To Dad Sales Today's Question Is When To Remove At Intervals In This Question Which Will Stop Intervals Where To Remove All Intervals Baithak Covered Boy In The Interval Hindi List Interval A Copy Squad And Interval Scene From A Different Only This Series nickel to have and beat them equalit... | 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 |
279 | That fans festival, the question above has been asked by taking minimum squares, you will get your number, you have to tell in how many minimum number of squares you can represent it, what does this mean, like if there is a note, then one can get pregnant by smelling only one number. If yes then the answer will be like... | Perfect Squares | perfect-squares | Given an integer `n`, return _the least number of perfect square numbers that sum to_ `n`.
A **perfect square** is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, `1`, `4`, `9`, and `16` are perfect squares while `3` and `11` are not.
**Example ... | null | Math,Dynamic Programming,Breadth-First Search | Medium | 204,264 |
1,768 | Hello friends, welcome to Day 8 of 990 Days SC Prep. This is the first question of Lead Code 75. Lead Code 1768 Merge Strings. Alternatively, I have made such an idea that I will make separate videos for each question and on Sunday I will do a live one for which Inside you can talk to me and if you have any doubt then ... | Merge Strings Alternately | design-an-expression-tree-with-evaluate-function | You are given two strings `word1` and `word2`. Merge the strings by adding letters in alternating order, starting with `word1`. If a string is longer than the other, append the additional letters onto the end of the merged string.
Return _the merged string._
**Example 1:**
**Input:** word1 = "abc ", word2 = "pqr "... | Apply the concept of Polymorphism to get a good design Implement the Node class using NumericNode and OperatorNode classes. NumericNode only maintains the value and evaluate returns this value. OperatorNode Maintains the left and right nodes representing the left and right operands, and the evaluate function applies th... | Math,Stack,Tree,Design,Binary Tree | Medium | null |
907 | Hello Aggarwal Welcome, what happened here was that there was a complete area of our own and inside it there were two was a complete area of our own and inside it there were two was a complete area of our own and inside it there were two problems, if you understand it as yours, then one was that you have to make ... | Sum of Subarray Minimums | koko-eating-bananas | Given an array of integers arr, find the sum of `min(b)`, where `b` ranges over every (contiguous) subarray of `arr`. Since the answer may be large, return the answer **modulo** `109 + 7`.
**Example 1:**
**Input:** arr = \[3,1,2,4\]
**Output:** 17
**Explanation:**
Subarrays are \[3\], \[1\], \[2\], \[4\], \[3,1\], \... | null | Array,Binary Search | Medium | 788,1335,2188 |
1,232 | Hello everyone welcome to me channel question and it is really easy but generally in phone interview or in online assessment sometimes an easy question is asked then one of them is ok straight line here it has not been asked by amazon and question Let's look at it is very simple, you must have given the coordinates, yo... | Check If It Is a Straight Line | sum-of-mutated-array-closest-to-target | You are given an array `coordinates`, `coordinates[i] = [x, y]`, where `[x, y]` represents the coordinate of a point. Check if these points make a straight line in the XY plane.
**Example 1:**
**Input:** coordinates = \[\[1,2\],\[2,3\],\[3,4\],\[4,5\],\[5,6\],\[6,7\]\]
**Output:** true
**Example 2:**
**Input:** coo... | If you draw a graph with the value on one axis and the absolute difference between the target and the array sum, what will you get? That graph is uni-modal. Use ternary search on that graph to find the best value. | Array,Binary Search,Sorting | Medium | null |
729 | Ki 510 Welcome To My Channel And They Are Also Living Very Important And Famous Interview Problem MyCalendar Vansh Sidhi Like Share And Subscribe Attempting Interview Tips Interview Sharing This Problem Thursday Till Pen Drive And Subscribe And You Know It Is The CEO Of The Subscribe Free Quit Successfully and Returns ... | My Calendar I | my-calendar-i | You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a **double booking**.
A **double booking** happens when two events have some non-empty intersection (i.e., some moment is common to both events.).
The event can be represented as a pair of integers `start... | Store the events as a sorted list of intervals. If none of the events conflict, then the new event can be added. | Design,Segment Tree,Ordered Set | Medium | 731,732 |
1,774 | hi everyone it's albert today let's solve the contest median question closest dessert cost and before we start don't forget to subscribe to my channel i'll be constantly solving good and classic clinical question with clear explanation animation and visualization now let's look at a question in this question we would l... | Closest Dessert Cost | add-two-polynomials-represented-as-linked-lists | You would like to make dessert and are preparing to buy the ingredients. You have `n` ice cream base flavors and `m` types of toppings to choose from. You must follow these rules when making your dessert:
* There must be **exactly one** ice cream base.
* You can add **one or more** types of topping or have no topp... | Process both linked lists at the same time If the current power of the two heads is equal, add this power with the sum of the coefficients to the answer list. If one head has a larger power, add this power to the answer list and move only this head. | Linked List,Math,Two Pointers | Medium | 2,21,445 |
1,523 | hey everybody this is Larry this is day 13 of the lead code daily challenge hit the like button hit the Subscribe and join me on Discord let me know what you think about today's form uh 15 23 count our numbers in an interval range um yeah let me know what you think I just watched the Super Bowl uh so I don't know let m... | Count Odd Numbers in an Interval Range | capital-gainloss | Given two non-negative integers `low` and `high`. Return the _count of odd numbers between_ `low` _and_ `high` _(inclusive)_.
**Example 1:**
**Input:** low = 3, high = 7
**Output:** 3
**Explanation:** The odd numbers between 3 and 7 are \[3,5,7\].
**Example 2:**
**Input:** low = 8, high = 10
**Output:** 1
**Explana... | null | Database | Medium | null |
1,728 | hey welcome back and today we're going to continue our journey to minimax and we're going to talk about this super hard problem cat and mouse and we're going to go ahead and read the question a game is played by a cat a mouse named a catamount and the environment is represented by the grid we have the rows and columns ... | Cat and Mouse II | fancy-sequence | A game is played by a cat and a mouse named Cat and Mouse.
The environment is represented by a `grid` of size `rows x cols`, where each element is a wall, floor, player (Cat, Mouse), or food.
* Players are represented by the characters `'C'`(Cat)`,'M'`(Mouse).
* Floors are represented by the character `'.'` and c... | Use two arrays to save the cumulative multipliers at each time point and cumulative sums adjusted by the current multiplier. The function getIndex(idx) ask to the current value modulo 10^9+7. Use modular inverse and both arrays to calculate this value. | Math,Design,Segment Tree | Hard | null |
1,705 | That Welcome Back Price Today Will Be Seen The Maximum Number of Return Apples Problem This Problem Appeared in the Weekly Contest of List Ko Dr. Ko Cut Song From A Explicit Flex Reader Problem Dare This Special Kind of People Tree Traffic Date for Entries Contra Voucher Deputy Producer Apple Cider Free State Will Supp... | Maximum Number of Eaten Apples | count-unhappy-friends | There is a special kind of apple tree that grows apples every day for `n` days. On the `ith` day, the tree grows `apples[i]` apples that will rot after `days[i]` days, that is on day `i + days[i]` the apples will be rotten and cannot be eaten. On some days, the apple tree does not grow any apples, which are denoted by ... | Create a matrix “rank” where rank[i][j] holds how highly friend ‘i' views ‘j’. This allows for O(1) comparisons between people | Array,Simulation | Medium | null |
367 | hello everyone welcome to another one of my lead code videos and this one we'll do lead code 367 valid perfect square so we're basically given a number and we need to determine if it is a perfect square so for example 16 is a perfect square because two integers when you multiply four times four it'll give you 16. note ... | Valid Perfect Square | valid-perfect-square | Given a positive integer num, return `true` _if_ `num` _is a perfect square or_ `false` _otherwise_.
A **perfect square** is an integer that is the square of an integer. In other words, it is the product of some integer with itself.
You must not use any built-in library function, such as `sqrt`.
**Example 1:**
**In... | null | Math,Binary Search | Easy | 69,633 |
133 | Okay, so this is the clone graph, okay, its code is written and our test case is this tooth 4 is connected, so we have to clone it, okay, so initially what we are doing is we will check that the weather node is null and not. In this case, there is no null, so we will simply move ahead, so what will we do, we will creat... | Clone Graph | clone-graph | Given a reference of a node in a **[connected](https://en.wikipedia.org/wiki/Connectivity_(graph_theory)#Connected_graph)** undirected graph.
Return a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) (clone) of the graph.
Each node in the graph contains a value (`int`) and a list (`List[Node]`)... | null | Hash Table,Depth-First Search,Breadth-First Search,Graph | Medium | 138,1624,1634 |
129 | Welcome to my channel again today will discuss some problem to meet code 1298 sum to lip numbers for the problem statement saying from root will have to race to the list node from root dalit note hair 605 lips note means have no children beans left and right to Win All Software Which Can Find Three Lip Notes 675 Soft 2... | Sum Root to Leaf Numbers | sum-root-to-leaf-numbers | You are given the `root` of a binary tree containing digits from `0` to `9` only.
Each root-to-leaf path in the tree represents a number.
* For example, the root-to-leaf path `1 -> 2 -> 3` represents the number `123`.
Return _the total sum of all root-to-leaf numbers_. Test cases are generated so that the answer w... | null | Tree,Depth-First Search,Binary Tree | Medium | 112,124,1030 |
7 | hey guys hope you are doing fine welcome back to another video in this video we will be looking at solution ah another lead coat problem which is reversed integer the problem definition is given a 32-bit signed definition is given a 32-bit signed definition is given a 32-bit signed integer reverse digits of an integer ... | Reverse Integer | reverse-integer | Given a signed 32-bit integer `x`, return `x` _with its digits reversed_. If reversing `x` causes the value to go outside the signed 32-bit integer range `[-231, 231 - 1]`, then return `0`.
**Assume the environment does not allow you to store 64-bit integers (signed or unsigned).**
**Example 1:**
**Input:** x = 123
... | null | Math | Medium | 8,190,2238 |
1,669 | A a beauty mausam jo washing machine thoda this question of list ko 12345 to jo question hai uske andar ko 2 released hum ko and one english march inside the other english, there has been a little light this question and there is no ko cheer I have tied you to this, so here in the case, the list on which was initially ... | Merge In Between Linked Lists | minimum-cost-to-cut-a-stick | You are given two linked lists: `list1` and `list2` of sizes `n` and `m` respectively.
Remove `list1`'s nodes from the `ath` node to the `bth` node, and put `list2` in their place.
The blue edges and nodes in the following figure indicate the result:
_Build the result list and return its head._
**Example 1:**
**In... | Build a dp array where dp[i][j] is the minimum cost to achieve all the cuts between i and j. When you try to get the minimum cost between i and j, try all possible cuts k between them, dp[i][j] = min(dp[i][k] + dp[k][j]) + (j - i) for all possible cuts k between them. | Array,Dynamic Programming | Hard | 2251 |
922 | hello everyone welcome to day twenty eighth of stem bitcoin challenge and today's question is sort array by parity two in this question we are given an array of integers and we need to sort this array such that at every odd index we have an odd integer at every even index we have an even integer the result can be any s... | Sort Array By Parity II | possible-bipartition | Given an array of integers `nums`, half of the integers in `nums` are **odd**, and the other half are **even**.
Sort the array so that whenever `nums[i]` is odd, `i` is **odd**, and whenever `nums[i]` is even, `i` is **even**.
Return _any answer array that satisfies this condition_.
**Example 1:**
**Input:** nums =... | null | Depth-First Search,Breadth-First Search,Union Find,Graph | Medium | null |
1,707 | hey what's up guys this is chong so let's take a look at uh 1707 maximum xor with an element from array so you're given like an array nums consisting of none negative integers right and then and you are also given like a queries a list of queries which has like uh who has like two elements the first one is x the second... | Maximum XOR With an Element From Array | check-if-string-is-transformable-with-substring-sort-operations | You are given an array `nums` consisting of non-negative integers. You are also given a `queries` array, where `queries[i] = [xi, mi]`.
The answer to the `ith` query is the maximum bitwise `XOR` value of `xi` and any element of `nums` that does not exceed `mi`. In other words, the answer is `max(nums[j] XOR xi)` for a... | Suppose the first digit you need is 'd'. How can you determine if it's possible to get that digit there? Consider swapping adjacent characters to maintain relative ordering. | String,Greedy,Sorting | Hard | null |
326 | hello everyone welcome back here is van damson and today we are diving into a coding challenge that's often asked in interview determining if number is power or free so if you're new here make sure to hit the Subscribe button and ring notification Bell so you never miss on our coding Adventure okay so let's take a look... | Power of Three | power-of-three | Given an integer `n`, return _`true` if it is a power of three. Otherwise, return `false`_.
An integer `n` is a power of three, if there exists an integer `x` such that `n == 3x`.
**Example 1:**
**Input:** n = 27
**Output:** true
**Explanation:** 27 = 33
**Example 2:**
**Input:** n = 0
**Output:** false
**Explanat... | null | Math,Recursion | Easy | 231,342,1889 |
97 | 114 WhatsApp Guys Welcome to my channel, so today we will solve one of the least important heart problems, interweaving of strings, so first of all we will discuss the approach in the problem, withdrawal logic canteen. All right, so as I always say, the most important thing in dynamic programming is our approach. It ha... | Interleaving String | interleaving-string | Given strings `s1`, `s2`, and `s3`, find whether `s3` is formed by an **interleaving** of `s1` and `s2`.
An **interleaving** of two strings `s` and `t` is a configuration where `s` and `t` are divided into `n` and `m` substrings respectively, such that:
* `s = s1 + s2 + ... + sn`
* `t = t1 + t2 + ... + tm`
* `|... | null | String,Dynamic Programming | Medium | null |
1,091 | hey everyone today we are going to throw the electrical questions shortest path in binary metrics so you are given n by n binary Matrix grid return the length of shortest career path in The Matrix if there is no clear path return -1 a clear there is no clear path return -1 a clear there is no clear path return -1 a cle... | Shortest Path in Binary Matrix | maximum-average-subtree | Given an `n x n` binary matrix `grid`, return _the length of the shortest **clear path** in the matrix_. If there is no clear path, return `-1`.
A **clear path** in a binary matrix is a path from the **top-left** cell (i.e., `(0, 0)`) to the **bottom-right** cell (i.e., `(n - 1, n - 1)`) such that:
* All the visite... | Can you find the sum of values and the number of nodes for every sub-tree ? Can you find the sum of values and the number of nodes for a sub-tree given the sum of values and the number of nodes of it's left and right sub-trees ? Use depth first search to recursively find the solution for the children of a node then use... | Tree,Depth-First Search,Binary Tree | Medium | 2126 |
93 | all right let's talk about the result ip address so a valid fbi just consists of exactly four integers separated by a single dot so each integer is between 0 and 255 and cannot have leading zero so which means this is not valid and also this is not valid right so you are given the string s containing only digits and re... | 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 |
312 | okay cool 312 burst balloons givin em balloons indexed from 0 to n minus 1 well that's not a complete sentence that's why I read Tyler will anyway huge balloon is painted with number are they represent by away gnomes you are asked to first order the balloons after you what if I guess what after you burst balloon I if y... | Burst Balloons | burst-balloons | You are given `n` balloons, indexed from `0` to `n - 1`. Each balloon is painted with a number on it represented by an array `nums`. You are asked to burst all the balloons.
If you burst the `ith` balloon, you will get `nums[i - 1] * nums[i] * nums[i + 1]` coins. If `i - 1` or `i + 1` goes out of bounds of the array, ... | null | Array,Dynamic Programming | Hard | 1042 |
447 | hello everyone so in this video let us talk about a problem from lead code the problem name is number of boomerangs so you are given n points in the plane that are all distinct where the point is denoted by x of x and y of y a boomerang is a tuple of points i j and k that you have to find out such that a distance betwe... | Number of Boomerangs | number-of-boomerangs | You are given `n` `points` in the plane that are all **distinct**, where `points[i] = [xi, yi]`. A **boomerang** is a tuple of points `(i, j, k)` such that the distance between `i` and `j` equals the distance between `i` and `k` **(the order of the tuple matters)**.
Return _the number of boomerangs_.
**Example 1:**
... | null | Array,Hash Table,Math | Medium | 356 |
255 | okay so back again the next problem we're gonna go with um yet another elite code medium so welcome and basically i'll just give you one moment and we'll check something yeah basically the last problem that we solved took us like half an hour didn't really need to take that much time but i got a little bit uncertain at... | 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 |
242 | question 242 of leak code valid anagram so given two strings s and t return true if t is a nanogram of s and falls otherwise 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 so in the first example we have anagram and na... | Valid Anagram | valid-anagram | Given two strings `s` and `t`, return `true` _if_ `t` _is an anagram of_ `s`_, and_ `false` _otherwise_.
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:**
**Input:** s = "anagram", t = "nagaram"
**... | null | Hash Table,String,Sorting | Easy | 49,266,438 |
1,604 | Hello hello friends so this is the problem from the list difficult contest 3638 omelette using quantity three or more times in one and ₹ 100 from the station I want you to check on one side light sweet crude oil price in a 10 name the The person who is the list of the people and not the example of who behaves the two i... | Alert Using Same Key-Card Three or More Times in a One Hour Period | least-number-of-unique-integers-after-k-removals | LeetCode company workers use key-cards to unlock office doors. Each time a worker uses their key-card, the security system saves the worker's name and the time when it was used. The system emits an **alert** if any worker uses the key-card **three or more times** in a one-hour period.
You are given a list of strings `... | Use a map to count the frequencies of the numbers in the array. An optimal strategy is to remove the numbers with the smallest count first. | Array,Hash Table,Greedy,Sorting,Counting | Medium | null |
943 | welcome to mazelico challenge this problem is called find the shortest super string given an array of strings words return the smallest string that contains each string in words as a substring if there are multiple valid strings in of the smallest length return any of them okay so you may assume that no string in words... | Find the Shortest Superstring | sum-of-subarray-minimums | Given an array of strings `words`, return _the smallest string that contains each string in_ `words` _as a substring_. If there are multiple valid strings of the smallest length, return **any of them**.
You may assume that no string in `words` is a substring of another string in `words`.
**Example 1:**
**Input:** wo... | null | Array,Dynamic Programming,Stack,Monotonic Stack | Medium | 2227 |
149 | good evening everyone today we are going to do the problem of the day for 8 January 2023 that is question number 149 maximum points on a line they are saying that we are given an array of points we have a array of some points where points indicates the x coordinate and y coordinate on a x y plane and we have to return ... | 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 |
237 | hello everyone welcome back to lead coding the question which we are going to solve today is delete node in a linked list the problem description is write a function to delete a node in a singly linked list you will not be given access to the head of the list instead you will be given access to the node which is to be ... | Delete Node in a Linked List | delete-node-in-a-linked-list | There is a singly-linked list `head` and we want to delete a node `node` in it.
You are given the node to be deleted `node`. You will **not be given access** to the first node of `head`.
All the values of the linked list are **unique**, and it is guaranteed that the given node `node` is not the last node in the linke... | null | Linked List | Easy | 203 |
875 | hey everybody this is larry this is day 20 of the lego daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's prom actually that's funny because i was just looking at this problem because i've been working on a on um on a binary search uh video um so thi... | Koko Eating Bananas | longest-mountain-in-array | Koko loves to eat bananas. There are `n` piles of bananas, the `ith` pile has `piles[i]` bananas. The guards have gone and will come back in `h` hours.
Koko can decide her bananas-per-hour eating speed of `k`. Each hour, she chooses some pile of bananas and eats `k` bananas from that pile. If the pile has less than `k... | null | Array,Two Pointers,Dynamic Programming,Enumeration | Medium | 1766,2205 |
121 | okay it's the best time to buy and sell stock elite code question one two one so you're given an array of prices where price i is the price of a given stock on life day you want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock return the max... | Best Time to Buy and Sell Stock | best-time-to-buy-and-sell-stock | You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day.
You want to maximize your profit by choosing a **single day** to buy one stock and choosing a **different day in the future** to sell that stock.
Return _the maximum profit you can achieve from this transaction_. If you ... | null | Array,Dynamic Programming | Easy | 53,122,123,188,309,2138,2144 |
486 | Hello gas, how are you all and today we are going to solve 486, so while discussing this question, it has been said in this question, who will have higher number in the last, we have to find out, if there are chances, then if the number of player one is either It's time to happen, so we have to return true, or Jal, onc... | Predict the Winner | predict-the-winner | You are given an integer array `nums`. Two players are playing a game with this array: player 1 and player 2.
Player 1 and player 2 take turns, with player 1 starting first. Both players start the game with a score of `0`. At each turn, the player takes one of the numbers from either end of the array (i.e., `nums[0]` ... | null | Array,Math,Dynamic Programming,Recursion,Game Theory | Medium | 464 |
228 | welcome back for another video we are going to do another vehicle question the question is 22a summary ranges you are given a salty unique integer array nonce a range ap is set of own integers from a to b inclusive we don't smell this sorted list of ranges that cover all numbers in array exactly that is each element of... | Summary Ranges | summary-ranges | You are given a **sorted unique** integer array `nums`.
A **range** `[a,b]` is the set of all integers from `a` to `b` (inclusive).
Return _the **smallest sorted** list of ranges that **cover all the numbers in the array exactly**_. That is, each element of `nums` is covered by exactly one of the ranges, and there is... | null | Array | Easy | 163,352 |
141 | Hello everyone welcome tu my channel it is very popular solution bhi patna hota slogan fast point based question hai linked list cycle tu theek hai liquid mein 142 medium level questions and everyone knows slow internet fast point wala This is the approach that was taught in college too, to detect cycles, so it is not ... | Linked List Cycle | linked-list-cycle | Given `head`, the head of a linked list, determine if the linked list has a cycle in it.
There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the `next` pointer. Internally, `pos` is used to denote the index of the node that tail's `next` pointer is co... | null | Hash Table,Linked List,Two Pointers | Easy | 142,202 |
5 | hey everybody this is larry this is day 16 or 17. why is my computer so slow okay day 16 of the leco day challenge hit the like button hit the subscribe button join me on discord let me know what you think about taste farming as you can see i'm back in new york yay um i got in really late after about 12 hours of uh fly... | 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 |
730 | cool 7:30 count different palindromic cool 7:30 count different palindromic cool 7:30 count different palindromic pollute public subsequences chemistry gas find a number of different non-empty gas find a number of different non-empty gas find a number of different non-empty powder omics of sequences in s and we turned ... | Count Different Palindromic Subsequences | count-different-palindromic-subsequences | Given a string s, return _the number of different non-empty palindromic subsequences in_ `s`. Since the answer may be very large, return it **modulo** `109 + 7`.
A subsequence of a string is obtained by deleting zero or more characters from the string.
A sequence is palindromic if it is equal to the sequence reversed... | Let dp(i, j) be the answer for the string T = S[i:j+1] including the empty sequence. The answer is the number of unique characters in T, plus palindromes of the form "a_a", "b_b", "c_c", and "d_d", where "_" represents zero or more characters. | String,Dynamic Programming | Hard | 516 |
337 | Hello Hi Everyone Welcome to my channel let's all the third problem of house road and series for this is a problem solved different in first attempt and less tourist problem like this time to stealing money from big boss house hair in this time is so face -2 Rok Di Houses In Sacha is so face -2 Rok Di Houses In Sacha i... | House Robber III | house-robber-iii | The thief has found himself a new place for his thievery again. There is only one entrance to this area, called `root`.
Besides the `root`, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will automatically contact the police if ... | null | Dynamic Programming,Tree,Depth-First Search,Binary Tree | Medium | 198,213 |
1,054 | hey yo what's up guys babybear4812 coming at you one more time today with problem number 1054 distant barcodes so this problem came up in earlier this year in 2020 in one of the weekly or bi-weekly contests weekly or bi-weekly contests weekly or bi-weekly contests and it looks like it's been picked up by uh bloomberg p... | Distant Barcodes | complement-of-base-10-integer | In a warehouse, there is a row of barcodes, where the `ith` barcode is `barcodes[i]`.
Rearrange the barcodes so that no two adjacent barcodes are equal. You may return any answer, and it is guaranteed an answer exists.
**Example 1:**
**Input:** barcodes = \[1,1,1,2,2,2\]
**Output:** \[2,1,2,1,2,1\]
**Example 2:**
... | A binary number plus its complement will equal 111....111 in binary. Also, N = 0 is a corner case. | Bit Manipulation | Easy | null |
678 | Hello Guys Welcome Back To Decades And This Video Will See The Valid Parents Is Trick Problem Typical From List To Dresses For Wedding Challenge So Let's Look At Problem Subscribe Tanning Only Three Types Of Characters Which Tend To Check Weather This Is The Subscribe Like Subscribe and subscribe the Channel and subsci... | 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 |
1,359 | Hello everyone welcome to my channel, today we are going to do video number 13 of our maths playlist. Lead code number is 1359 hard but I will explain it in such a way that it will become very easy for you. It is important to understand that tuition is necessary, that I am definitely clear. I will do it in my video, th... | Count All Valid Pickup and Delivery Options | circular-permutation-in-binary-representation | Given `n` orders, each order consist in pickup and delivery services.
Count all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i).
Since the answer may be too large, return it modulo 10^9 + 7.
**Example 1:**
**Input:** n = 1
**Output:** 1
**Explanation:** Unique order (P1, ... | Use gray code to generate a n-bit sequence. Rotate the sequence such that its first element is start. | Math,Backtracking,Bit Manipulation | Medium | null |
1,356 | Hello everyone welcome to my channel Codesari with Mike, so today we are going to do video number four of our bit manipulation playlist. Okay, the lead code number is 1356, it is easy, that is why I have kept it more informative, meaning you will learn more extra things from this video. What do we learn? The name of th... | Sort Integers by The Number of 1 Bits | minimum-number-of-moves-to-make-palindrome | You are given an integer array `arr`. Sort the integers in the array in ascending order by the number of `1`'s in their binary representation and in case of two or more integers have the same number of `1`'s you have to sort them in ascending order.
Return _the array after sorting it_.
**Example 1:**
**Input:** arr ... | Consider a greedy strategy. Let’s start by making the leftmost and rightmost characters match with some number of swaps. If we figure out how to do that using the minimum number of swaps, then we can delete the leftmost and rightmost characters and solve the problem recursively. | Two Pointers,String,Greedy,Binary Indexed Tree | Hard | 1437 |
354 | hey what's up guys this is sean here so today uh let's take a look at this problem number 354 russian doll envelopes uh i think you have some of you may know this russian though right basically so this is like a door inside another door right which is another dough so you have a number of envelopes with width and heigh... | Russian Doll Envelopes | russian-doll-envelopes | You are given a 2D array of integers `envelopes` where `envelopes[i] = [wi, hi]` represents the width and the height of an envelope.
One envelope can fit into another if and only if both the width and height of one envelope are greater than the other envelope's width and height.
Return _the maximum number of envelope... | null | Array,Binary Search,Dynamic Programming,Sorting | Hard | 300,2123 |
347 | looking at problem 347 top K frequent elements just per usually the three steps implementing any problem are one understand it to visualize and then three implement it given an integer array nums and integer K return the K most frequent elements you may return the answer in any order you have an example we have one two... | Top K Frequent Elements | top-k-frequent-elements | Given an integer array `nums` and an integer `k`, return _the_ `k` _most frequent elements_. You may return the answer in **any order**.
**Example 1:**
**Input:** nums = \[1,1,1,2,2,3\], k = 2
**Output:** \[1,2\]
**Example 2:**
**Input:** nums = \[1\], k = 1
**Output:** \[1\]
**Constraints:**
* `1 <= nums.lengt... | null | Array,Hash Table,Divide and Conquer,Sorting,Heap (Priority Queue),Bucket Sort,Counting,Quickselect | Medium | 192,215,451,659,692,1014,1919 |
1 | what's going on guys welcome back in this video we are going to be solving leap code problem number one Numero Uno and it's going to be the two sum problem so get excited guys let's go ahead and jump straight into the code so let's get started by checking out the prompt guys so they're going to give us an array of inte... | Two Sum | two-sum | Given an array of integers `nums` and an integer `target`, return _indices of the two numbers such that they add up to `target`_.
You may assume that each input would have **_exactly_ one solution**, and you may not use the _same_ element twice.
You can return the answer in any order.
**Example 1:**
**Input:** nums... | A really brute force way would be to search for all possible pairs of numbers but that would be too slow. Again, it's best to try out brute force solutions for just for completeness. It is from these brute force solutions that you can come up with optimizations. So, if we fix one of the numbers, say x, we have to scan ... | Array,Hash Table | Easy | 15,18,167,170,560,653,1083,1798,1830,2116,2133,2320 |
6 | hi everyone let's all today's daily challenge that is zigzag conversion so in this question we are given a string and it is written in a zigzag pattern on a given number of rows like this right and then what we are doing is we are taking the first row of it and then after the first row we are appending the second row a... | 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 |
863 | or not anthony it's me and sexual what he did or didn't do in the country in game to Busquets they know a game of murray I'm fine he said and it's not up to them valdez the same as always the water although there is show credit suisse first world brown defense and trying information no there is fastball 36 modified fiv... | 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 |
108 | hello everyone welcome to learn overflow in this video we will look into today's lecture problem that is the convert sorted array to binary search tree so this is an easy level problem and we will understand how we can uh solve this problem or how can think of solving this problem so before starting this video make sur... | Convert Sorted Array to Binary Search Tree | convert-sorted-array-to-binary-search-tree | Given an integer array `nums` where the elements are sorted in **ascending order**, convert _it to a_ **_height-balanced_** _binary search tree_.
**Example 1:**
**Input:** nums = \[-10,-3,0,5,9\]
**Output:** \[0,-3,9,-10,null,5\]
**Explanation:** \[0,-10,5,null,-3,null,9\] is also accepted:
**Example 2:**
**Input... | null | Array,Divide and Conquer,Tree,Binary Search Tree,Binary Tree | Easy | 109 |
543 | hello guys welcome to study algorithms and today we would be looking at finding the diameter of a binary tree first we would be understanding what is the diameter of a binary tree and look at some sample test cases next we would discussed a brute force solution and the problems you may face next we will try to intuitiv... | Diameter of Binary Tree | diameter-of-binary-tree | Given the `root` of a binary tree, return _the length of the **diameter** of the tree_.
The **diameter** of a binary tree is the **length** of the longest path between any two nodes in a tree. This path may or may not pass through the `root`.
The **length** of a path between two nodes is represented by the number of ... | null | Tree,Depth-First Search,Binary Tree | Easy | 1665 |
114 | hey what's up guys it's Nick white here I do tack encoding stuff on twitch and YouTube and check the description for everything about me I do all the problem ly code problems and they're all on my youtube channel so just check those out same intro as every other video this one's called flattened binary free to a linked... | Flatten Binary Tree to Linked List | flatten-binary-tree-to-linked-list | Given the `root` of a binary tree, flatten the tree into a "linked list ":
* The "linked list " should use the same `TreeNode` class where the `right` child pointer points to the next node in the list and the `left` child pointer is always `null`.
* The "linked list " should be in the same order as a [**pre-order*... | If you notice carefully in the flattened tree, each node's right child points to the next node of a pre-order traversal. | Linked List,Stack,Tree,Depth-First Search,Binary Tree | Medium | 766,1796 |
69 | hello and welcome to python programming practice in this episode we are going to be covering lead code number 69 called square root x given a non-negative integer x given a non-negative integer x given a non-negative integer x compute and return the square root of x since the return type is an integer the decimal digit... | 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 |
888 | hello everyone so in this video let us talk about a easy problem from lead code the problem name is fair candy swaps okay so Alice and Bobs have different total number of candies you are given to integer array Alice size and Bob size where Alice size I is the number of candy of the ith box of the candidate Alice hold w... | Fair Candy Swap | mirror-reflection | Alice and Bob have a different total number of candies. You are given two integer arrays `aliceSizes` and `bobSizes` where `aliceSizes[i]` is the number of candies of the `ith` box of candy that Alice has and `bobSizes[j]` is the number of candies of the `jth` box of candy that Bob has.
Since they are friends, they wo... | null | Math,Geometry | Medium | null |
211 | hey everybody this is larry this is day 28 of the january lego daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about this problem which is design ad and search word status structure restrained design hopefully i've been doing all right it's still very cold here... | Design Add and Search Words Data Structure | design-add-and-search-words-data-structure | Design a data structure that supports adding new words and finding if a string matches any previously added string.
Implement the `WordDictionary` class:
* `WordDictionary()` Initializes the object.
* `void addWord(word)` Adds `word` to the data structure, it can be matched later.
* `bool search(word)` Returns ... | You should be familiar with how a Trie works. If not, please work on this problem: Implement Trie (Prefix Tree) first. | String,Depth-First Search,Design,Trie | Medium | 208,746 |
7 | hello my friends this is Alexander barmin and this is my YouTube show lead code with me where we solve coding challenges from lead code recently I conducted my first live stream and hope you enjoyed it and if you have topics for the next streams to for me to cover please don't forget to write a comment for this video a... | Reverse Integer | reverse-integer | Given a signed 32-bit integer `x`, return `x` _with its digits reversed_. If reversing `x` causes the value to go outside the signed 32-bit integer range `[-231, 231 - 1]`, then return `0`.
**Assume the environment does not allow you to store 64-bit integers (signed or unsigned).**
**Example 1:**
**Input:** x = 123
... | null | Math | Medium | 8,190,2238 |
857 | hey guys it's iran with another coding interview question and this one is called minimum cost to higher k workers this one is really popular with google probably on account of it being really difficult it's also labeled as a lit code hard and i do agree with that label so that's exactly why i wanted to make this video ... | Minimum Cost to Hire K Workers | positions-of-large-groups | There are `n` workers. You are given two integer arrays `quality` and `wage` where `quality[i]` is the quality of the `ith` worker and `wage[i]` is the minimum wage expectation for the `ith` worker.
We want to hire exactly `k` workers to form a paid group. To hire a group of `k` workers, we must pay them according to ... | null | String | Easy | 2260 |
70 | hello and welcome everyone let's continue edition prasad lists by solving climbing stairs while climbing is stick is and it takes n number of stairs steps to reach the top we can take either one or two steps and how many distinct twists can we claim to the top we can see from the first example that we have two staircas... | Climbing Stairs | climbing-stairs | You are climbing a staircase. It takes `n` steps to reach the top.
Each time you can either climb `1` or `2` steps. In how many distinct ways can you climb to the top?
**Example 1:**
**Input:** n = 2
**Output:** 2
**Explanation:** There are two ways to climb to the top.
1. 1 step + 1 step
2. 2 steps
**Example 2:**
... | To reach nth step, what could have been your previous steps? (Think about the step sizes) | Math,Dynamic Programming,Memoization | Easy | 747,1013,1236 |
1,706 | And hero Ram is being seen after a long time, today we are the ones to see Ok Ok Ok Varna, I will explain, there is no problem, see how much Ram becomes, what are you trying to say, the question is ok, the question has been raised brother. You must have been given a grade as if you are seeing that the lines cannot be r... | Where Will the Ball Fall | min-cost-to-connect-all-points | You have a 2-D `grid` of size `m x n` representing a box, and you have `n` balls. The box is open on the top and bottom sides.
Each cell in the box has a diagonal board spanning two corners of the cell that can redirect a ball to the right or to the left.
* A board that redirects the ball to the right spans the top... | Connect each pair of points with a weighted edge, the weight being the manhattan distance between those points. The problem is now the cost of minimum spanning tree in graph with above edges. | Array,Union Find,Minimum Spanning Tree | Medium | 2287 |
93 | here we go let's start the timer and read the question okay restore IP addresses four integers zero to 255 inclusive cannot have leading zeros so it cannot be zero one mm-hmm okay a string containing only digits return all possible valid IP addresses hmm okay by inserting dots not allowed to reorder or remove we can on... | 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 |
463 | hey everyone welcome back and let's write some more neat code today so today let's solve island perimeter so this is an easy problem but i would say it's more of a medium problem in terms of difficulty it's similar to a different graph problem called number of islands and you may have solved that problem before this pr... | Island Perimeter | island-perimeter | You are given `row x col` `grid` representing a map where `grid[i][j] = 1` represents land and `grid[i][j] = 0` represents water.
Grid cells are connected **horizontally/vertically** (not diagonally). The `grid` is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells)... | null | Array,Depth-First Search,Breadth-First Search,Matrix | Easy | 695,733,1104 |
981 | hey guys what's up this is steve today let's go through another legal problem 981 time based a key value stall let's take a look at the problem description first create a time-based keyword installed create a time-based keyword installed create a time-based keyword installed class time map that supports two operations ... | Time Based Key-Value Store | delete-columns-to-make-sorted | Design a time-based key-value data structure that can store multiple values for the same key at different time stamps and retrieve the key's value at a certain timestamp.
Implement the `TimeMap` class:
* `TimeMap()` Initializes the object of the data structure.
* `void set(String key, String value, int timestamp)... | null | Array,String | Easy | null |
838 | hey everybody this is Larry this is day 27 of the legal daily Challenger Tuesday hit the like button hit the Subscribe button join me on Discord let me know what you think about today's forum and yeah in the video and so forth um hope y'all are having a okay week and excellent week whatever you like um yeah end of Sept... | Push Dominoes | design-linked-list | There are `n` dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to the left or to the right.
After each second, each domino that is falling to the left pushes the adjacent domino on the left. Similarly, the dominoes falling to the righ... | null | Linked List,Design | Medium | 1337 |
34 | hey hello there so today's the binary search question that I picked as the city for fine first and last position of element in sorted array the question is just as follows we have a sorted integer arrays and we want to find the starting and ending position of a given target value the algorithm has to be in log in time ... | 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 |
1,947 | hey what's up guys this is chung here again so this time lead code number 1947 maximum compatibility score sum okay so now this time we have a survey that consists of n questions right where each question's answer is either zero or one okay and then the survey was given to m students right from zero to n minus one and ... | Maximum Compatibility Score Sum | number-of-different-subsequences-gcds | There is a survey that consists of `n` questions where each question's answer is either `0` (no) or `1` (yes).
The survey was given to `m` students numbered from `0` to `m - 1` and `m` mentors numbered from `0` to `m - 1`. The answers of the students are represented by a 2D integer array `students` where `students[i]`... | Think of how to check if a number x is a gcd of a subsequence. If there is such subsequence, then all of it will be divisible by x. Moreover, if you divide each number in the subsequence by x , then the gcd of the resulting numbers will be 1. Adding a number to a subsequence cannot increase its gcd. So, if there is a v... | Array,Math,Counting,Number Theory | Hard | 2106 |
1,286 | at all so today continuing on this be weekly contest 15 the third the problem iterator for combinations so let's see what the problem asks us to do so it's 1286 iterator for combination and the problem says we want to design an iterator class that has three things a constructor so iterators usually have just the constr... | Iterator for Combination | constrained-subsequence-sum | Design the `CombinationIterator` class:
* `CombinationIterator(string characters, int combinationLength)` Initializes the object with a string `characters` of **sorted distinct** lowercase English letters and a number `combinationLength` as arguments.
* `next()` Returns the next combination of length `combinationL... | Use dynamic programming. Let dp[i] be the solution for the prefix of the array that ends at index i, if the element at index i is in the subsequence. dp[i] = nums[i] + max(0, dp[i-k], dp[i-k+1], ..., dp[i-1]) Use a heap with the sliding window technique to optimize the dp. | Array,Dynamic Programming,Queue,Sliding Window,Heap (Priority Queue),Monotonic Queue | Hard | null |
1,968 | hey guys today we're going to talk about question array which item is not equal to average of neighbors so you are given a zero index array numbers of distinct integers you want to rearrange the elements in an array such that every element in the rear range array is not equal to the average of its neighbors okay let's ... | Array With Elements Not Equal to Average of Neighbors | maximum-building-height | You are given a **0-indexed** array `nums` of **distinct** integers. You want to rearrange the elements in the array such that every element in the rearranged array is **not** equal to the **average** of its neighbors.
More formally, the rearranged array should have the property such that for every `i` in the range `1... | Is it possible to find the max height if given the height range of a particular building? You can find the height range of a restricted building by doing 2 passes from the left and right. | Array,Math | Hard | null |
1,579 | Hello everyone welcome, you are my channel and I always suggest that if you read my graph concept playlist, then graph bill Wickham is very fine, try it once, for that remove the maximum number of cups, graph full travel is fine. The name of the question is this and what is it, after reading it from my playlist of grap... | Remove Max Number of Edges to Keep Graph Fully Traversable | active-users | Alice and Bob have an undirected graph of `n` nodes and three types of edges:
* Type 1: Can be traversed by Alice only.
* Type 2: Can be traversed by Bob only.
* Type 3: Can be traversed by both Alice and Bob.
Given an array `edges` where `edges[i] = [typei, ui, vi]` represents a bidirectional edge of type `typ... | null | Database | Medium | null |
412 | is another beginner problem called fizzbuzz it's quite popular it's a children's game where you have to keep the sound of your face or it's a buzz giving an integer ends return a string of array answer one index where these are the rules you basically had to uh return fizzbuzz if I the eye position is divisible by thre... | Fizz Buzz | fizz-buzz | Given an integer `n`, return _a string array_ `answer` _(**1-indexed**) where_:
* `answer[i] == "FizzBuzz "` if `i` is divisible by `3` and `5`.
* `answer[i] == "Fizz "` if `i` is divisible by `3`.
* `answer[i] == "Buzz "` if `i` is divisible by `5`.
* `answer[i] == i` (as a string) if none of the above condit... | null | Math,String,Simulation | Easy | 1316 |
423 | hey everybody this is larry this is day 28 of the march leeco daily challenge uh hit the like button hit the subscribe button hit me on discord let me know what you think about dave's prom yes the questions are back let me know what you think uh and today's problem is we construct original digits from english uh yeah s... | Reconstruct Original Digits from English | reconstruct-original-digits-from-english | Given a string `s` containing an out-of-order English representation of digits `0-9`, return _the digits in **ascending** order_.
**Example 1:**
**Input:** s = "owoztneoer"
**Output:** "012"
**Example 2:**
**Input:** s = "fviefuro"
**Output:** "45"
**Constraints:**
* `1 <= s.length <= 105`
* `s[i]` is one of ... | null | Hash Table,Math,String | Medium | null |
1,351 | all right let's talk about the common negative numbers in the sorted matrix so you are given an environmental grid which is stored in non-disk increasing which is stored in non-disk increasing which is stored in non-disk increasing order and you have to return a number of negative numbers in the grid so this is suppose... | Count Negative Numbers in a Sorted Matrix | replace-the-substring-for-balanced-string | Given a `m x n` matrix `grid` which is sorted in non-increasing order both row-wise and column-wise, return _the number of **negative** numbers in_ `grid`.
**Example 1:**
**Input:** grid = \[\[4,3,2,-1\],\[3,2,1,-1\],\[1,1,-1,-2\],\[-1,-1,-2,-3\]\]
**Output:** 8
**Explanation:** There are 8 negatives number in the ma... | Use 2-pointers algorithm to make sure all amount of characters outside the 2 pointers are smaller or equal to n/4. That means you need to count the amount of each letter and make sure the amount is enough. | String,Sliding Window | Medium | null |
263 | Hello children welcome to our college so today we are going to see the question its name is the next number that first let us understand the problem what is the next number the next numbers which give the number whose if you do prime factorization then you will have ₹ 2 five do prime factorization then you will have ₹ ... | Ugly Number | ugly-number | An **ugly number** is a positive integer whose prime factors are limited to `2`, `3`, and `5`.
Given an integer `n`, return `true` _if_ `n` _is an **ugly number**_.
**Example 1:**
**Input:** n = 6
**Output:** true
**Explanation:** 6 = 2 \* 3
**Example 2:**
**Input:** n = 1
**Output:** true
**Explanation:** 1 has n... | null | Math | Easy | 202,204,264 |
1,921 | Hello friends, today's problem is element maximum number of monsters. In this problem we are playing a video game. In this we have to defend our city from monsters. We have to know the distance of each monster from our city and at what speed it will come towards our city. It is a given that the distance and speed of ea... | Eliminate Maximum Number of Monsters | eliminate-maximum-number-of-monsters | You are playing a video game where you are defending your city from a group of `n` monsters. You are given a **0-indexed** integer array `dist` of size `n`, where `dist[i]` is the **initial distance** in kilometers of the `ith` monster from the city.
The monsters walk toward the city at a **constant** speed. The speed... | null | null | Medium | null |
399 | hey everybody this is Larry this is day 20th of delico day challenge hit the like button to subscribe button drop me a Discord let me know what you think about today's problem um yeah so hope you enjoyed the intro I am still in Georgia I'm right now I'm in uh an area called kaspaki um it's basically a mountain town Mou... | 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 |
131 | hello everyone i hope all of you are having a great time and welcome to day fifth of december echo challenge let's quickly talk about today's question in today's question is palindrome partitioning here we are given an input string s and we need to partition the input string such that the every possible division leads ... | Palindrome Partitioning | palindrome-partitioning | Given a string `s`, partition `s` such that every substring of the partition is a **palindrome**. Return _all possible palindrome partitioning of_ `s`.
**Example 1:**
**Input:** s = "aab"
**Output:** \[\["a","a","b"\],\["aa","b"\]\]
**Example 2:**
**Input:** s = "a"
**Output:** \[\["a"\]\]
**Constraints:**
* `1... | null | String,Dynamic Programming,Backtracking | Medium | 132,1871 |
31 | all right so in today's problem we are going to look at the problem next permutation how do we generate the next permutation given a sequence that we already have so if our sequence is 1 2 & 3 the next permutation in that 2 & 3 the next permutation in that 2 & 3 the next permutation in that sequence is goin... | Next Permutation | next-permutation | A **permutation** of an array of integers is an arrangement of its members into a sequence or linear order.
* For example, for `arr = [1,2,3]`, the following are all the permutations of `arr`: `[1,2,3], [1,3,2], [2, 1, 3], [2, 3, 1], [3,1,2], [3,2,1]`.
The **next permutation** of an array of integers is the next le... | null | Array,Two Pointers | Medium | 46,47,60,267,1978 |
1,913 | hello everyone welcome back to another video in this video we are going to solve with Lead Core problem which is named as maximum difference between two pairs so in this question you will be given an input array in which you will be given some numbers and you have to return the maximum output which will be the product ... | Maximum Product Difference Between Two Pairs | make-the-xor-of-all-segments-equal-to-zero | The **product difference** between two pairs `(a, b)` and `(c, d)` is defined as `(a * b) - (c * d)`.
* For example, the product difference between `(5, 6)` and `(2, 7)` is `(5 * 6) - (2 * 7) = 16`.
Given an integer array `nums`, choose four **distinct** indices `w`, `x`, `y`, and `z` such that the **product differ... | Let's note that for the XOR of all segments with size K to be equal to zeros, nums[i] has to be equal to nums[i+k] Basically, we need to make the first K elements have XOR = 0 and then modify them. | Array,Dynamic Programming,Bit Manipulation | Hard | null |
382 | daily challenge which is 382 English random number so as per this question uh we have given a single linked list written the random nodes value from the linked list each node must have the same probability of being chosen so uh there are two methods we need to implement solution and one is and get random okay so if you... | 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 |
1,759 | hey there welcome to pomodora Jo for Thursday November 9th 2023 today we're looking at lead Cod problem 1759 count number of homogeneous substrings this is a medium problem all right so we're given a string s we need to return the number of homogeneous substrings of s since the answer may be too large return it modulo ... | Count Number of Homogenous Substrings | find-the-missing-ids | Given a string `s`, return _the number of **homogenous** substrings of_ `s`_._ Since the answer may be too large, return it **modulo** `109 + 7`.
A string is **homogenous** if all the characters of the string are the same.
A **substring** is a contiguous sequence of characters within a string.
**Example 1:**
**Inpu... | null | Database | Medium | 1357,1420,1467 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.