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 |
|---|---|---|---|---|---|---|---|---|
417 | in this video we're going to take a look at a legal problem called pacific atlantic water flow so we're given an m times an integer matrix heights representing the height of each unit cell in the continent uh the pacific ocean touches the continent's left and the top edges and the atlantic ocean touches the continent's... | 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 |
1,290 | Hello hello everyone welcome and welcome back to my channel soft person saal bana do problem yes-yes convert binary number in at least to problem yes-yes convert binary number in at least to problem yes-yes convert binary number in at least to wait is very easy problem liquid problem isse jeevan head with reference not... | Convert Binary Number in a Linked List to Integer | make-array-strictly-increasing | Given `head` which is a reference node to a singly-linked list. The value of each node in the linked list is either `0` or `1`. The linked list holds the binary representation of a number.
Return the _decimal value_ of the number in the linked list.
The **most significant bit** is at the head of the linked list.
**E... | Use dynamic programming. The state would be the index in arr1 and the index of the previous element in arr2 after sorting it and removing duplicates. | Array,Binary Search,Dynamic Programming | Hard | null |
132 | Hello hello friends in this video will solve problem number 132 talent room partition * super will understand your partition * super will understand your partition * super will understand your problem statement after death will see how to solve this problem in this code in java subscribe again play * subscribe and agai... | Palindrome Partitioning II | palindrome-partitioning-ii | Given a string `s`, partition `s` such that every substring of the partition is a palindrome.
Return _the **minimum** cuts needed for a palindrome partitioning of_ `s`.
**Example 1:**
**Input:** s = "aab "
**Output:** 1
**Explanation:** The palindrome partitioning \[ "aa ", "b "\] could be produced using 1 cut.
**... | null | String,Dynamic Programming | Hard | 131,1871 |
983 | Hello everyone welcome you are going to do video number 17 of me channel programming ok and liquid number 983 is medium level question but it should be pretty but this question is good remember this question dig type se question and cute good ok The name of the very good question for your DP practice is 'Tickets at Min... | Minimum Cost For Tickets | validate-stack-sequences | You have planned some train traveling one year in advance. The days of the year in which you will travel are given as an integer array `days`. Each day is an integer from `1` to `365`.
Train tickets are sold in **three different ways**:
* a **1-day** pass is sold for `costs[0]` dollars,
* a **7-day** pass is sold... | null | Array,Stack,Simulation | Medium | null |
1,880 | all right so this question is check if words equal sumission of two word so all right this is the concept so you want to return to if the sumission of the numeric value of the first FL and the second L are equal to the Target so first one is AB ACB and then second one is CBA so ACB is going to be represent zero ask tab... | Check if Word Equals Summation of Two Words | largest-merge-of-two-strings | The **letter value** of a letter is its position in the alphabet **starting from 0** (i.e. `'a' -> 0`, `'b' -> 1`, `'c' -> 2`, etc.).
The **numerical value** of some string of lowercase English letters `s` is the **concatenation** of the **letter values** of each letter in `s`, which is then **converted** into an inte... | Build the result character by character. At each step, you choose a character from one of the two strings. If the next character of the first string is larger than that of the second string, or vice versa, it's optimal to use the larger one. If both are equal, think of a criteria that lets you decide which string to co... | Two Pointers,String,Greedy | Medium | null |
1,372 | hi guys good morning welcome back to the next video I hope that you guys are doing well let's look on to the next problem which is longest zigzag path in a binary it's a pretty easy to medium problem but it is very helpful in many other hard problems so basically it can be acted as a sub problem of a heart problem so p... | Longest ZigZag Path in a Binary Tree | check-if-it-is-a-good-array | You are given the `root` of a binary tree.
A ZigZag path for a binary tree is defined as follow:
* Choose **any** node in the binary tree and a direction (right or left).
* If the current direction is right, move to the right child of the current node; otherwise, move to the left child.
* Change the direction f... | Eq. ax+by=1 has solution x, y if gcd(a,b) = 1. Can you generalize the formula?. Check Bézout's lemma. | Array,Math,Number Theory | Hard | null |
977 | in this video we're going to look at a legal problem called squares of a sort array so a given array of integer nums stored in non-decreasing order return an array in non-decreasing order return an array in non-decreasing order return an array of the squares of each number sorted in non-decreasing order so you can see ... | 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 |
1,531 | hey what's up guys john here again so today let's take a look at uh this week's weekly contest problem the last one number 1500 and 531 it's hard to believe over 1500 problems on lead code now okay so it's a hard problem so string compression number two i'm gonna give it my own upvote all right you're given a string an... | String Compression II | number-of-ways-to-wear-different-hats-to-each-other | [Run-length encoding](http://en.wikipedia.org/wiki/Run-length_encoding) is a string compression method that works by replacing consecutive identical characters (repeated 2 or more times) with the concatenation of the character and the number marking the count of the characters (length of the run). For example, to compr... | Dynamic programming + bitmask. dp(peopleMask, idHat) number of ways to wear different hats given a bitmask (people visited) and used hats from 1 to idHat-1. | Array,Dynamic Programming,Bit Manipulation,Bitmask | Hard | 2105 |
148 | Hello Hi Everyone Welcome To My Channel Today In This Video Will Solve The Problems Of At Least 100 Given Her Lips And They Have To Return List Of Sorting In Ascending Order Should Desist Part 2 F 3 Patience 1234 Subscribe Algorithm Chief Shoes In Settings Can Be Applied For Voting Key First Floor Solution Should Avoid... | Sort List | sort-list | Given the `head` of a linked list, return _the list after sorting it in **ascending order**_.
**Example 1:**
**Input:** head = \[4,2,1,3\]
**Output:** \[1,2,3,4\]
**Example 2:**
**Input:** head = \[-1,5,3,4,0\]
**Output:** \[-1,0,3,4,5\]
**Example 3:**
**Input:** head = \[\]
**Output:** \[\]
**Constraints:**
* ... | null | Linked List,Two Pointers,Divide and Conquer,Sorting,Merge Sort | Medium | 21,75,147,1992 |
1,309 | hello so continuing on this little code contest 117 we are doing the first problem which is given a number 1309 bcrypt string from alphabet to integer mapping so the problem is essentially it says that we get a string s that is formed by digits that range from 0 to 9 and hash tag and we want to map as to English lowerc... | Decrypt String from Alphabet to Integer Mapping | sort-items-by-groups-respecting-dependencies | You are given a string `s` formed by digits and `'#'`. We want to map `s` to English lowercase characters as follows:
* Characters (`'a'` to `'i'`) are represented by (`'1'` to `'9'`) respectively.
* Characters (`'j'` to `'z'`) are represented by (`'10#'` to `'26#'`) respectively.
Return _the string formed after ... | Think of it as a graph problem. We need to find a topological order on the dependency graph. Build two graphs, one for the groups and another for the items. | Depth-First Search,Breadth-First Search,Graph,Topological Sort | Hard | null |
1,702 | hey everybody this is larry this is me going over q3 of the bi-weekly contest 42 q3 of the bi-weekly contest 42 q3 of the bi-weekly contest 42 on lead code um maximum binary string after change so well before i say anything hit the like button hit the subscribe button join me on discord uh and ask me questions there or... | Maximum Binary String After Change | bank-account-summary | You are given a binary string `binary` consisting of only `0`'s or `1`'s. You can apply each of the following operations any number of times:
* Operation 1: If the number contains the substring `"00 "`, you can replace it with `"10 "`.
* For example, `"00010 " -> "10010` "
* Operation 2: If the number contai... | null | Database | Medium | null |
352 | this video I will discuss about lead code problem number 352. in this problem you are given a data stream what is a data stream unlike other problems where you are directly given an array in data stream you are not given all the numbers at once instead the problem passes one number at a time for example in this instead... | 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 |
95 | hey everyone welcome back and let's write some more neat code today it's been a while since we did one of these so I might be a little rusty but we are solving unique binary search trees too we already solved the first one of this I think actually like three years ago now but better late than never to solve the second ... | 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 |
949 | yeahyeah Hi everyone, I'm a programmer. Today I'm going to introduce to you a math problem with the following title: The you a math problem with the following title: The you a math problem with the following title: The largest hour combined from the given numbers. The following details give us a four-digit piece of giv... | Largest Time for Given Digits | cat-and-mouse | Given an array `arr` of 4 digits, find the latest 24-hour time that can be made using each digit **exactly once**.
24-hour times are formatted as `"HH:MM "`, where `HH` is between `00` and `23`, and `MM` is between `00` and `59`. The earliest 24-hour time is `00:00`, and the latest is `23:59`.
Return _the latest 24-h... | null | Math,Dynamic Programming,Breadth-First Search,Graph,Memoization,Game Theory | Hard | 1727 |
1,319 | hey everyone welcome back to the channel I hope you guys are doing extremely well so today we will be solving the problem uh connecting the graph it states a given a graph with n vertices and M edges you can remove one Edge from anywhere and add that edge between any two vertices in one operation okay that is what the ... | Number of Operations to Make Network Connected | unique-number-of-occurrences | There are `n` computers numbered from `0` to `n - 1` connected by ethernet cables `connections` forming a network where `connections[i] = [ai, bi]` represents a connection between computers `ai` and `bi`. Any computer can reach any other computer directly or indirectly through the network.
You are given an initial com... | Find the number of occurrences of each element in the array using a hash map. Iterate through the hash map and check if there is a repeated value. | Array,Hash Table | Easy | null |
1,624 | we are going to see the today LOD daily problem that is the largest subing between the two a characters so let's first see what is the problem so we are given a string s and we have to return the length of the longest substring between the two equal character so the substring is nothing but the string which has charact... | Largest Substring Between Two Equal Characters | clone-binary-tree-with-random-pointer | Given a string `s`, return _the length of the longest substring between two equal characters, excluding the two characters._ If there is no such substring return `-1`.
A **substring** is a contiguous sequence of characters within a string.
**Example 1:**
**Input:** s = "aa "
**Output:** 0
**Explanation:** The optim... | Traverse the tree, keep a hashtable with you and create a nodecopy for each node in the tree. Start traversing the original tree again and connect the left, right and random pointers in the cloned tree the same way as the original tree with the help of the hashtable. | Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree | Medium | 133,138,1634 |
72 | hey how's it going on guys so in this video dispersed about this problem added distance given towards what one and were to find the minimum number of operations required to convert afford one two you have the following three operations permitted on a word insert a character delete a character deeply a character so let ... | Edit Distance | edit-distance | Given two strings `word1` and `word2`, return _the minimum number of operations required to convert `word1` to `word2`_.
You have the following three operations permitted on a word:
* Insert a character
* Delete a character
* Replace a character
**Example 1:**
**Input:** word1 = "horse ", word2 = "ros "
**O... | null | String,Dynamic Programming | Hard | 161,583,712,1105,2311 |
62 | hey-ho there today's li coding challenge hey-ho there today's li coding challenge hey-ho there today's li coding challenge question has got unique pauses we have a 2d grid M rows and columns we're starting out on the top left corner and we want to go to the bottom right corner and now a move set is that for one step we... | Unique Paths | unique-paths | There is a robot on an `m x n` grid. The robot is initially located at the **top-left corner** (i.e., `grid[0][0]`). The robot tries to move to the **bottom-right corner** (i.e., `grid[m - 1][n - 1]`). The robot can only move either down or right at any point in time.
Given the two integers `m` and `n`, return _the nu... | null | Math,Dynamic Programming,Combinatorics | Medium | 63,64,174,2192 |
1,030 | Oh 10:30 matrix L in distance order the Oh 10:30 matrix L in distance order the Oh 10:30 matrix L in distance order the Kipner matrix are all rows and C columns within ourselves that has cells with integer coordinates RC men have trouble reading we're always RNC's our insider the matrix additionally we're given a cell ... | Matrix Cells in Distance Order | smallest-string-starting-from-leaf | You are given four integers `row`, `cols`, `rCenter`, and `cCenter`. There is a `rows x cols` matrix and you are on the cell with the coordinates `(rCenter, cCenter)`.
Return _the coordinates of all cells in the matrix, sorted by their **distance** from_ `(rCenter, cCenter)` _from the smallest distance to the largest ... | null | String,Tree,Depth-First Search,Binary Tree | Medium | 129,257 |
1,312 | I had also continuing on this slate coat contest 117 let's do the last problem which is a little code hard so the problem is number one 1312 minimum insertion steps to make a string a palindrome and so the problem says given a string s in one step you can insert any character at any particular index of the string and w... | Minimum Insertion Steps to Make a String Palindrome | count-artifacts-that-can-be-extracted | Given a string `s`. In one step you can insert any character at any index of the string.
Return _the minimum number of steps_ to make `s` palindrome.
A **Palindrome String** is one that reads the same backward as well as forward.
**Example 1:**
**Input:** s = "zzazz "
**Output:** 0
**Explanation:** The string "zz... | Check if each coordinate of each artifact has been excavated. How can we do this quickly without iterating over the dig array every time? Consider marking all excavated cells in a 2D boolean array. | Array,Hash Table,Simulation | Medium | 221 |
148 | i want to have a solution called a sort list so human linked list we want to return the linked list after sorting the link list in ascending order in other words from a small segment to large assembly for example one here as the original link is not sorry if certain english will go from the small segment one all the wa... | Sort List | sort-list | Given the `head` of a linked list, return _the list after sorting it in **ascending order**_.
**Example 1:**
**Input:** head = \[4,2,1,3\]
**Output:** \[1,2,3,4\]
**Example 2:**
**Input:** head = \[-1,5,3,4,0\]
**Output:** \[-1,0,3,4,5\]
**Example 3:**
**Input:** head = \[\]
**Output:** \[\]
**Constraints:**
* ... | null | Linked List,Two Pointers,Divide and Conquer,Sorting,Merge Sort | Medium | 21,75,147,1992 |
278 | That Aapke Ajay Ko Hua Hai Hello Everyone Welcome to Our New Video English Video Let's Introduce You Another Problem from Its Core and Problem Miss Call Number 28.51 Different Problem Statement Problem 28.51 Different Problem Statement Problem 28.51 Different Problem Statement Problem You are Product Manager at Liberty... | First Bad Version | first-bad-version | You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.
Suppose you have `n` versions `[1, 2, ..., n]` an... | null | Binary Search,Interactive | Easy | 34,35,374 |
146 | That is before proceeding further Absolute Truth and Sponsor of this Video Calling Ujaas Kuntha Aapke Many Affordable Courses Available 400 Means Really For All According To The Content Which The Provide Is Okay Chicken Chokor Se Status Channel Quantum Computer Programming Interview Preparation For Development Machine ... | LRU Cache | lru-cache | Design a data structure that follows the constraints of a **[Least Recently Used (LRU) cache](https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU)**.
Implement the `LRUCache` class:
* `LRUCache(int capacity)` Initialize the LRU cache with **positive** size `capacity`.
* `int get(int key)` Return the valu... | null | Hash Table,Linked List,Design,Doubly-Linked List | Medium | 460,588,604,1903 |
792 | um hello so today we are going to do this problem part of lead code july challenge number of matching subsequences um so the problem says that we get a string s and an array of words and we want to return the number of words that are um subsequences of s right so a subsequence is of course um a set of indic the letters... | Number of Matching Subsequences | binary-search | Given a string `s` and an array of strings `words`, return _the number of_ `words[i]` _that is a subsequence of_ `s`.
A **subsequence** of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.
* For exa... | null | Array,Binary Search | Easy | 786 |
82 | hi everyone in this video we're gonna go over another lead code question remove duplicates from sorted list two major tech companies like google facebook microsoft linkedin are asking this question while they're conducting their technical interviews i hope you will find this video tutorial helpful for your technical en... | Remove Duplicates from Sorted List II | remove-duplicates-from-sorted-list-ii | Given the `head` of a sorted linked list, _delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list_. Return _the linked list **sorted** as well_.
**Example 1:**
**Input:** head = \[1,2,3,3,4,4,5\]
**Output:** \[1,2,5\]
**Example 2:**
**Input:** head = \[1,1,1,2,3\]
**Outpu... | null | Linked List,Two Pointers | Medium | 83,1982 |
140 | hi guys welcome to algorithms made easy today we will go through the day 30 problem from the july lead coding challenge word break 2. 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 non-empty string s and a given a non-empty string s and a give... | Word Break II | word-break-ii | Given a string `s` and a dictionary of strings `wordDict`, add spaces in `s` to construct a sentence where each word is a valid dictionary word. Return all such possible sentences in **any order**.
**Note** that the same word in the dictionary may be reused multiple times in the segmentation.
**Example 1:**
**Input:... | null | Hash Table,String,Dynamic Programming,Backtracking,Trie,Memoization | Hard | 139,472 |
472 | hey everyone welcome to techwired in this video we are going to see another liquid problem 472 concatenated words in this particular problem we need to cons find the word which can be formed by other words in the given input for example we are given cat dog in the second example we are given cat dog as the result right... | Concatenated Words | concatenated-words | Given an array of strings `words` (**without duplicates**), return _all the **concatenated words** in the given list of_ `words`.
A **concatenated word** is defined as a string that is comprised entirely of at least two shorter words (not necesssarily distinct) in the given array.
**Example 1:**
**Input:** words = \... | null | Array,String,Dynamic Programming,Depth-First Search,Trie | Hard | 140 |
201 | um hello so today we are going to do this problem which is part of lead code daily challenge bitwise and for four numbers range so basically we get two numbers left and right so basically they represent a range closed range from left to right so including left and including right and what we want to do is return the bi... | Bitwise AND of Numbers Range | bitwise-and-of-numbers-range | Given two integers `left` and `right` that represent the range `[left, right]`, return _the bitwise AND of all numbers in this range, inclusive_.
**Example 1:**
**Input:** left = 5, right = 7
**Output:** 4
**Example 2:**
**Input:** left = 0, right = 0
**Output:** 0
**Example 3:**
**Input:** left = 1, right = 2147... | null | Bit Manipulation | Medium | null |
1,637 | today we're going to solve a problem that is perhaps the easiest simplest most intuitive just ridiculously trivial medium elak code problem in the history of all the leak code problems that at least I've solved okay um so let's go ahead and get right into it shouldn't take even more than five minutes so 1637 widest ver... | Widest Vertical Area Between Two Points Containing No Points | string-compression-ii | Given `n` `points` on a 2D plane where `points[i] = [xi, yi]`, Return _the **widest vertical area** between two points such that no points are inside the area._
A **vertical area** is an area of fixed-width extending infinitely along the y-axis (i.e., infinite height). The **widest vertical area** is the one with the ... | Use dynamic programming. The state of the DP can be the current index and the remaining characters to delete. Having a prefix sum for each character can help you determine for a certain character c in some specific range, how many characters you need to delete to merge all occurrences of c in that range. | String,Dynamic Programming | Hard | null |
113 | what's up guys this is lit called 113 bath some chow given a binary tree and a Sun find out route to live paths where each path Sun equals to the given Sun a leaf is a node with no children given the below binary tree and a Sun 20 to return in list with all the paths so here the result is a list of lists so we have a l... | Path Sum II | path-sum-ii | Given the `root` of a binary tree and an integer `targetSum`, return _all **root-to-leaf** paths where the sum of the node values in the path equals_ `targetSum`_. Each path should be returned as a list of the node **values**, not node references_.
A **root-to-leaf** path is a path starting from the root and ending at... | null | Backtracking,Tree,Depth-First Search,Binary Tree | Medium | 112,257,437,666,2217 |
66 | hello guys myself Amrita welcome back to our Channel techno Siege so in today's video we are going to discuss lead code problem number 66 that is plus one so let's get started let's first understand the problem you are given a large integer represented as an integer array digits where each digits of I is the ith digit ... | Plus One | plus-one | You are given a **large integer** represented as an integer array `digits`, where each `digits[i]` is the `ith` digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading `0`'s.
Increment the large integer by one and re... | null | Array,Math | Easy | 43,67,369,1031 |
141 | So let's see today's lead code question. Question number 141 Link List Cycle. So read the question. Given head is the head of the link list. Determine if the link list is cycle in it. They cycle and link list if there is some node in the list. can be reached again by continuously following the next pointer internally. ... | 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 |
190 | hey guys welcome to lead code along in today's question i'll be solving the reverse bits question basically we're given a 32-bit unsigned integer and have to a 32-bit unsigned integer and have to a 32-bit unsigned integer and have to reverse the bits and return the integer basically so that's the example let's go ahead... | Reverse Bits | reverse-bits | Reverse bits of a given 32 bits unsigned integer.
**Note:**
* Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer's internal binary representation is the s... | null | Divide and Conquer,Bit Manipulation | Easy | 7,191,2238 |
1,287 | given an integer array that sorted in non-decreasing order there is exactly non-decreasing order there is exactly non-decreasing order there is exactly one element that appears more than 25% one element that appears more than 25% one element that appears more than 25% of the time find that annamund that's about today's... | Element Appearing More Than 25% In Sorted Array | distance-between-bus-stops | Given an integer array **sorted** in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.
**Example 1:**
**Input:** arr = \[1,2,2,6,6,6,6,7,10\]
**Output:** 6
**Example 2:**
**Input:** arr = \[1,1\]
**Output:** 1
**Constraints:**
* `1 <= arr... | Find the distance between the two stops if the bus moved in clockwise or counterclockwise directions. | Array | Easy | null |
1,793 | hello everyone welcome back here is vamson with another live coding uh challenge so today uh L code challenge a maximum score of good subarray number uh 1,793 it's Mark as heart so uh today we 1,793 it's Mark as heart so uh today we 1,793 it's Mark as heart so uh today we are unpacking an intriguing problem that challe... | Maximum Score of a Good Subarray | minimum-moves-to-make-array-complementary | You are given an array of integers `nums` **(0-indexed)** and an integer `k`.
The **score** of a subarray `(i, j)` is defined as `min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1)`. A **good** subarray is a subarray where `i <= k <= j`.
Return _the maximum possible **score** of a **good** subarray._
**Example 1:**... | Given a target sum x, each pair of nums[i] and nums[n-1-i] would either need 0, 1, or 2 modifications. Can you find the optimal target sum x value such that the sum of modifications is minimized? Create a difference array to efficiently sum all the modifications. | Array,Hash Table,Prefix Sum | Medium | null |
1,921 | hey there welcome to Pomodoro for Tuesday November 7th 2023 today we're looking at lead Cod problem 1921 eliminate maximum number of monsters this is a medium problem all right so in this one we're playing a video game and we're defending a city from a group of monsters now these monsters are given to us as distances a... | 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 |
684 | hi guys welcome to algorithms made easy my name is khushpur and in this video we are going to see the question redundant connections in this problem a tree is an undirected graph that is connected and has no cycle you are given a graph that started as a tree with n number of nodes labeled from 1 to n with one additiona... | Redundant Connection | redundant-connection | In this problem, a tree is an **undirected graph** that is connected and has no cycles.
You are given a graph that started as a tree with `n` nodes labeled from `1` to `n`, with one additional edge added. The added edge has two **different** vertices chosen from `1` to `n`, and was not an edge that already existed. Th... | null | Depth-First Search,Breadth-First Search,Union Find,Graph | Medium | 685,721,2246 |
343 | hi friends so in this video we'll be looking at how to approach the problem 343 integer break now let us just review the problem statement given any in integer n break it into the sum of K positive integers that K is greater than or equals to 2 and maximize the product of those integers okay so here the essentially wha... | Integer Break | integer-break | Given an integer `n`, break it into the sum of `k` **positive integers**, where `k >= 2`, and maximize the product of those integers.
Return _the maximum product you can get_.
**Example 1:**
**Input:** n = 2
**Output:** 1
**Explanation:** 2 = 1 + 1, 1 \* 1 = 1.
**Example 2:**
**Input:** n = 10
**Output:** 36
**Exp... | There is a simple O(n) solution to this problem. You may check the breaking results of n ranging from 7 to 10 to discover the regularities. | Math,Dynamic Programming | Medium | 1936 |
961 | yes so I'll be solving from 1961 called any repeated elements in a to an array so the comp states that an array of in a array 8 size to n there are n plus 1 unique elements in exactly one element of these elements is repeated n times return the element repeated n times for example 1 2 3 the output would be 3 & exam... | N-Repeated Element in Size 2N Array | long-pressed-name | You are given an integer array `nums` with the following properties:
* `nums.length == 2 * n`.
* `nums` contains `n + 1` **unique** elements.
* Exactly one element of `nums` is repeated `n` times.
Return _the element that is repeated_ `n` _times_.
**Example 1:**
**Input:** nums = \[1,2,3,3\]
**Output:** 3
**... | null | Two Pointers,String | Easy | null |
232 | Okay so hello everyone this is Akshay here and today we will see implement queue using stacks so this question is also a part of our interview preparation so we will solve it today itself because this is also a question of lead code PO TD today's write problem The Day 29 January This is our playlist actually in which w... | Implement Queue using Stacks | implement-queue-using-stacks | Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (`push`, `peek`, `pop`, and `empty`).
Implement the `MyQueue` class:
* `void push(int x)` Pushes element x to the back of the queue.
* `int pop()` Removes the element from th... | null | Stack,Design,Queue | Easy | 225 |
1,190 | hello everyone so in this video let us talk about a media level problem from lead code the problem name is reverse substring between each pair of parentheses the problem statement goes like this that you are given a string s that consists of lowercase English letters and brackets now you have to reverse the string in e... | Reverse Substrings Between Each Pair of Parentheses | smallest-common-region | You are given a string `s` that consists of lower case English letters and brackets.
Reverse the strings in each pair of matching parentheses, starting from the innermost one.
Your result should **not** contain any brackets.
**Example 1:**
**Input:** s = "(abcd) "
**Output:** "dcba "
**Example 2:**
**Input:** s... | Try to model the problem as a graph problem. The given graph is a tree. The problem is reduced to finding the lowest common ancestor of two nodes in a tree. | Array,Hash Table,String,Tree,Depth-First Search,Breadth-First Search | Medium | 235,236 |
124 | hey guys how's everything going this is Jay sir who is not in good our algorithm us today let's continue our jury on need code to solve the Facebook questions it should be 1 to 4 yeah binary tree maximum path song okay we're given a non empty binary tree find the maximum path sound wow it should be recursion for this p... | Binary Tree Maximum Path Sum | binary-tree-maximum-path-sum | A **path** in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence **at most once**. Note that the path does not need to pass through the root.
The **path sum** of a path is the sum of the node's values in the path.
... | null | Dynamic Programming,Tree,Depth-First Search,Binary Tree | Hard | 112,129,666,687,1492 |
129 | Hello everyone, welcome to my channel, it is very easy, okay, if I explain it to you, then you will feel that yes, it should have been easy, okay, the name of the question is, Some Route, You Leave Number, okay, you will also see the list of all the companies in the description, either in my Github here. Look at the qu... | 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 |
1,047 | hi guys this is sanjay and today we are going to solve lead code problem 1047 which is remove all adjacent duplicates and string let's see what the problem says so you are given a string s consisting of lowercase english letters a duplicate removal consists of choosing two adjacent and equal letters and removing them w... | Remove All Adjacent Duplicates In String | maximize-sum-of-array-after-k-negations | You are given a string `s` consisting of lowercase English letters. A **duplicate removal** consists of choosing two **adjacent** and **equal** letters and removing them.
We repeatedly make **duplicate removals** on `s` until we no longer can.
Return _the final string after all such duplicate removals have been made_... | null | Array,Greedy,Sorting | Easy | 2204 |
1,689 | hi everyone welcome to lead code programming in this video i would like to discuss about the problem partitioning into minimum number of dc binary numbers so this is a problem from today's weekly challenge and as you can see this is a medium level problem so let's look at the problem a decimal number is called a dc bin... | Partitioning Into Minimum Number Of Deci-Binary Numbers | detect-pattern-of-length-m-repeated-k-or-more-times | A decimal number is called **deci-binary** if each of its digits is either `0` or `1` without any leading zeros. For example, `101` and `1100` are **deci-binary**, while `112` and `3001` are not.
Given a string `n` that represents a positive decimal integer, return _the **minimum** number of positive **deci-binary** n... | Use a three-layer loop to check all possible patterns by iterating through all possible starting positions, all indexes less than m, and if the character at the index is repeated k times. | Array,Enumeration | Easy | 1764 |
949 | Today's question in Jai Hind series is Rise Today's question in Jai Hind series is Rise Today's question in Jai Hind series is Rise Time Forgiveness Digit Question and the link of which is given in the description, it is something like this, we will get the question by subscribing to it, yes this and this which is from... | Largest Time for Given Digits | cat-and-mouse | Given an array `arr` of 4 digits, find the latest 24-hour time that can be made using each digit **exactly once**.
24-hour times are formatted as `"HH:MM "`, where `HH` is between `00` and `23`, and `MM` is between `00` and `59`. The earliest 24-hour time is `00:00`, and the latest is `23:59`.
Return _the latest 24-h... | null | Math,Dynamic Programming,Breadth-First Search,Graph,Memoization,Game Theory | Hard | 1727 |
3 | hello everyone it's bright and early 6 a.m. and I was just so excited mmm to be a.m. and I was just so excited mmm to be a.m. and I was just so excited mmm to be somehow rhythms and just couldn't sleep so I thought I would do a video on Lea code number three along a substring without repeating characters let's read thr... | Longest Substring Without Repeating Characters | longest-substring-without-repeating-characters | Given a string `s`, find the length of the **longest** **substring** without repeating characters.
**Example 1:**
**Input:** s = "abcabcbb "
**Output:** 3
**Explanation:** The answer is "abc ", with the length of 3.
**Example 2:**
**Input:** s = "bbbbb "
**Output:** 1
**Explanation:** The answer is "b ", with t... | null | Hash Table,String,Sliding Window | Medium | 159,340,1034,1813,2209 |
352 | hello everyone welcome to coding decoded my name is H today I'm working at sd4 at Adobe and here I present solution to day 28th of January lead Cod Challenge I was quite occupied with office work then I had a family event and after that I got ill and as a result of which I couldn't upload the daily de code problem from... | 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 |
977 | The Dream II bike has a family. I know I 'm in this row. I'll wear it and solve a 'm in this row. I'll wear it and solve a 'm in this row. I'll wear it and solve a math problem. For more detailed information, please go to the list of available dislikes. I'll put it on both sides to understand. okay the way we operate t... | 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 |
724 | hello coders today I'm solving liquid problem number 724 find pivot index here we are given an area of integer norms and we need to calculate its pivot index so the pivot index is the index where the sum of all the elements to its left is strictly equals to sum of all the elements to its right and the index would not f... | 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 |
253 | hello everyone hope you are doing well let's all meeting rooms too you will be given array of meeting intervals where each index represents meeting start time and end time we need to return minimum number of conference rooms required to schedule all the meetings let's see here the first meeting starts at 0 ends at 30 s... | Meeting Rooms II | meeting-rooms-ii | Given an array of meeting time intervals `intervals` where `intervals[i] = [starti, endi]`, return _the minimum number of conference rooms required_.
**Example 1:**
**Input:** intervals = \[\[0,30\],\[5,10\],\[15,20\]\]
**Output:** 2
**Example 2:**
**Input:** intervals = \[\[7,10\],\[2,4\]\]
**Output:** 1
**Constr... | Think about how we would approach this problem in a very simplistic way. We will allocate rooms to meetings that occur earlier in the day v/s the ones that occur later on, right? If you've figured out that we have to sort the meetings by their start time, the next thing to think about is how do we do the allocation? Th... | Array,Two Pointers,Greedy,Sorting,Heap (Priority Queue) | Medium | 56,252,452,1184 |
54 | hi guys good morning welcome back to the next video so basically in this video this is a problem spiral Matrix before you start on this although it's a very easy problem very Shadow problem but back when I was in college when I was young uh young oh am I not in yeah right now who knows so back when I was in college uh ... | Spiral Matrix | spiral-matrix | Given an `m x n` `matrix`, return _all elements of the_ `matrix` _in spiral order_.
**Example 1:**
**Input:** matrix = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\]
**Output:** \[1,2,3,6,9,8,7,4,5\]
**Example 2:**
**Input:** matrix = \[\[1,2,3,4\],\[5,6,7,8\],\[9,10,11,12\]\]
**Output:** \[1,2,3,4,8,12,11,10,9,5,6,7\]
**Const... | Well for some problems, the best way really is to come up with some algorithms for simulation. Basically, you need to simulate what the problem asks us to do. We go boundary by boundary and move inwards. That is the essential operation. First row, last column, last row, first column and then we move inwards by 1 and th... | Array,Matrix,Simulation | Medium | 59,921 |
71 | in this video we'll be going over simplified paths so given a string path which is an absolute path starting with a slash to a file or directory in a unix style file system converted to a simplified canonical path in a unix file system a period refers to the current directory a double period refers to a directory upper... | Simplify Path | simplify-path | Given a string `path`, which is an **absolute path** (starting with a slash `'/'`) to a file or directory in a Unix-style file system, convert it to the simplified **canonical path**.
In a Unix-style file system, a period `'.'` refers to the current directory, a double period `'..'` refers to the directory up a level,... | null | String,Stack | Medium | null |
1,460 | Hello Hi Guys How Are You I Am Positive Doing What Should We Do 12 Areas Equal Family Singer Survey And See The Question In Our Play List I Hope You All Are Doing This Play List And I Am Here Dwing Effect From Your Site So Refueling so nutrition respiration like subscribe and comment and not forget to share this place ... | Make Two Arrays Equal by Reversing Subarrays | number-of-substrings-containing-all-three-characters | You are given two integer arrays of equal length `target` and `arr`. In one step, you can select any **non-empty subarray** of `arr` and reverse it. You are allowed to make any number of steps.
Return `true` _if you can make_ `arr` _equal to_ `target` _or_ `false` _otherwise_.
**Example 1:**
**Input:** target = \[1,... | For each position we simply need to find the first occurrence of a/b/c on or after this position. So we can pre-compute three link-list of indices of each a, b, and c. | Hash Table,String,Sliding Window | Medium | 2187 |
1,043 | I do a problem every day because it's actually fun this is partition array for maximum sum let's go ahead and get right into the problem so you're given an integer array or ARR you want to partition the array into sub arrays of a length at most k so partitioning an array just basically means for any array like uh you k... | Partition Array for Maximum Sum | grid-illumination | Given an integer array `arr`, partition the array into (contiguous) subarrays of length **at most** `k`. After partitioning, each subarray has their values changed to become the maximum value of that subarray.
Return _the largest sum of the given array after partitioning. Test cases are generated so that the answer fi... | null | Array,Hash Table | Hard | 51 |
847 | Hello everyone welcome to my channel with Mike, so today before our graph we are going to do its video number 36, okay you can follow my graph concession question playlist, if you want to understand the graph completely and basic, okay that. You will get the playlist if you go to my profile, if you go to my channel on ... | Shortest Path Visiting All Nodes | shortest-path-visiting-all-nodes | You have an undirected, connected graph of `n` nodes labeled from `0` to `n - 1`. You are given an array `graph` where `graph[i]` is a list of all the nodes connected with node `i` by an edge.
Return _the length of the shortest path that visits every node_. You may start and stop at any node, you may revisit nodes mul... | null | null | Hard | null |
1,048 | Hello everyone welcome to our channel tweet sunny in this video you will be talking mode on mother google interview coding questions till problem in longest-serving chief kaise is in longest-serving chief kaise is in longest-serving chief kaise is problem needs to intervene longest-serving chief by the subscribe and lo... | Longest String Chain | clumsy-factorial | You are given an array of `words` where each word consists of lowercase English letters.
`wordA` is a **predecessor** of `wordB` if and only if we can insert **exactly one** letter anywhere in `wordA` **without changing the order of the other characters** to make it equal to `wordB`.
* For example, `"abc "` is a **... | null | Math,Stack,Simulation | Medium | null |
99 | hi everyone welcome back to this Channel and I hope you guys are doing well today we are going to solve another lead code problem uh that is recover binary sry okay this is another one of the lead code famous problems we can judge it at least based on the number of likes okay so we are given the root of a binary s tree... | Recover Binary Search Tree | recover-binary-search-tree | You are given the `root` of a binary search tree (BST), where the values of **exactly** two nodes of the tree were swapped by mistake. _Recover the tree without changing its structure_.
**Example 1:**
**Input:** root = \[1,3,null,null,2\]
**Output:** \[3,1,null,null,2\]
**Explanation:** 3 cannot be a left child of 1 ... | null | Tree,Depth-First Search,Binary Search Tree,Binary Tree | Medium | null |
1,773 | MP3 A Question is Bank Account Items Matching and Rule One Today They Are Giving Me Pass is OK Today Hey Phone is Blue Color Picture Company's Computer is Silver Color Lenovo Company's Phone is Gold Color Tiffin Company 's Rule What is the Rule person this field should be different color I get the second number on the ... | Count Items Matching a Rule | percentage-of-users-attended-a-contest | You are given an array `items`, where each `items[i] = [typei, colori, namei]` describes the type, color, and name of the `ith` item. You are also given a rule represented by two strings, `ruleKey` and `ruleValue`.
The `ith` item is said to match the rule if **one** of the following is true:
* `ruleKey == "type "` ... | null | Database | Easy | 1338 |
380 | hey guys welcome to today's video in today's video we're going to look at lead code problem and the problem's name is insert delete get random B go of one so in this question we have to implement the randomized set class so the first is the Constructor randomized set which initializes the randomized set object here we ... | Insert Delete GetRandom O(1) | insert-delete-getrandom-o1 | Implement the `RandomizedSet` class:
* `RandomizedSet()` Initializes the `RandomizedSet` object.
* `bool insert(int val)` Inserts an item `val` into the set if not present. Returns `true` if the item was not present, `false` otherwise.
* `bool remove(int val)` Removes an item `val` from the set if present. Retur... | null | Array,Hash Table,Math,Design,Randomized | Medium | 381 |
1,624 | Namaskar Aadab and Sat Shri Akal, today is the date 31st and Bava month means just one day more for our New Year to start in 2024. So let's see today's daily challenge problem of lead quote 16 24 Largest sub string between the two equals. Character so let's see question what are you trying to say question is saying tha... | Largest Substring Between Two Equal Characters | clone-binary-tree-with-random-pointer | Given a string `s`, return _the length of the longest substring between two equal characters, excluding the two characters._ If there is no such substring return `-1`.
A **substring** is a contiguous sequence of characters within a string.
**Example 1:**
**Input:** s = "aa "
**Output:** 0
**Explanation:** The optim... | Traverse the tree, keep a hashtable with you and create a nodecopy for each node in the tree. Start traversing the original tree again and connect the left, right and random pointers in the cloned tree the same way as the original tree with the help of the hashtable. | Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree | Medium | 133,138,1634 |
227 | hey everybody this is larry this is day 24 of delete code daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's problem basic calculator 2. implement a basic calculator to evaluate a symbol expression string uh in division empty spaces is the order of o... | Basic Calculator II | basic-calculator-ii | Given a string `s` which represents an expression, _evaluate this expression and return its value_.
The integer division should truncate toward zero.
You may assume that the given expression is always valid. All intermediate results will be in the range of `[-231, 231 - 1]`.
**Note:** You are not allowed to use any ... | null | Math,String,Stack | Medium | 224,282,785 |
1,357 | hello viewers welcome back to my channel I hope you are enjoying the videos I am back with another problem for this week from lead code applied discount every n errors there is a sale in supermarket there will be a discount every end customer there are some products in supermarket where the idea of the eighth product i... | Apply Discount Every n Orders | report-contiguous-dates | There is a supermarket that is frequented by many customers. The products sold at the supermarket are represented as two parallel integer arrays `products` and `prices`, where the `ith` product has an ID of `products[i]` and a price of `prices[i]`.
When a customer is paying, their bill is represented as two parallel i... | null | Database | Hard | 1420,1759 |
403 | cool 403 5 jump a frog is crossing a river the river is divided into X units and added unit there may or may not exist a stone the Jamuna stone but must not jump into the water mix and so far given a list of stone positions in units in sorted ascending order determine if the Frog is able to cross the river by landing o... | Frog Jump | frog-jump | A frog is crossing a river. The river is divided into some number of units, and at each unit, there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water.
Given a list of `stones`' positions (in units) in sorted **ascending order**, determine if the frog can cross the river by... | null | Array,Dynamic Programming | Hard | 1952,2262 |
1,400 | hello everyone welcome to question coder so in this video we will see the question 1400 that is construct k palindromic strings so this is not a light question on the code but it can be asked in interview for a basic uh string question so it is a medium question you can see and that's the wrong statement then i will ex... | Construct K Palindrome Strings | find-winner-on-a-tic-tac-toe-game | Given a string `s` and an integer `k`, return `true` _if you can use all the characters in_ `s` _to construct_ `k` _palindrome strings or_ `false` _otherwise_.
**Example 1:**
**Input:** s = "annabelle ", k = 2
**Output:** true
**Explanation:** You can construct two palindromes using all characters in s.
Some possibl... | It's straightforward to check if A or B won or not, check for each row/column/diag if all the three are the same. Then if no one wins, the game is a draw iff the board is full, i.e. moves.length = 9 otherwise is pending. | Array,Hash Table,Matrix,Simulation | Easy | null |
737 | Hello hi friends welcome back today we are going to solve list to problem 856 center similarity and dare is another similar problem only it's good wishes its interface almost similar problem to this problem but also were going to discuss dialogue with solution because both problem sir very similar And one solution can ... | Sentence Similarity II | sentence-similarity-ii | We can represent a sentence as an array of words, for example, the sentence `"I am happy with leetcode "` can be represented as `arr = [ "I ", "am ",happy ", "with ", "leetcode "]`.
Given two sentences `sentence1` and `sentence2` each represented as a string array and given an array of string pairs `similarPairs` wher... | Consider the graphs where each pair in "pairs" is an edge. Two words are similar if they are the same, or are in the same connected component of this graph. | Array,Hash Table,String,Depth-First Search,Breadth-First Search,Union Find | Medium | 547,721,734 |
1,647 | hello and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem 1647 minimum deletions to make character frequencies unique let's read the question prompt a string s is called good if there are no two different characters in s that have the same frequency given a string s r... | Minimum Deletions to Make Character Frequencies Unique | can-convert-string-in-k-moves | A string `s` is called **good** if there are no two different characters in `s` that have the same **frequency**.
Given a string `s`, return _the **minimum** number of characters you need to delete to make_ `s` _**good**._
The **frequency** of a character in a string is the number of times it appears in the string. F... | Observe that shifting a letter x times has the same effect of shifting the letter x + 26 times. You need to check whether k is large enough to cover all shifts with the same remainder after modulo 26. | Hash Table,String | Medium | null |
1,038 | iphone 5 smartphones somewhere not for the lesson was just by and fixed Richard of someone or five six light analytical photos of set if your absolutely fantastic suffer from the letter stands for a long time this had actually received flight of her cheek trade magazine by step a bit more red no wait ring once a smalle... | Binary Search Tree to Greater Sum Tree | number-of-squareful-arrays | Given the `root` of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all keys greater than the original key in BST.
As a reminder, a _binary search tree_ is a tree that satisfies these constraints:
* The left subtree of a... | null | Array,Math,Dynamic Programming,Backtracking,Bit Manipulation,Bitmask | Hard | 47 |
1,190 | okay so hello and welcome here we are another problem this is going to be number 1190 reverse substrings between each pair of parentheses um forgive me I uh sometimes just kind of think I might feel like a little overwhelmed uh let me check the audio is it working forgive me I uh sometimes yeah I just you know there's ... | Reverse Substrings Between Each Pair of Parentheses | smallest-common-region | You are given a string `s` that consists of lower case English letters and brackets.
Reverse the strings in each pair of matching parentheses, starting from the innermost one.
Your result should **not** contain any brackets.
**Example 1:**
**Input:** s = "(abcd) "
**Output:** "dcba "
**Example 2:**
**Input:** s... | Try to model the problem as a graph problem. The given graph is a tree. The problem is reduced to finding the lowest common ancestor of two nodes in a tree. | Array,Hash Table,String,Tree,Depth-First Search,Breadth-First Search | Medium | 235,236 |
83 | hello everyone let's look at remove duplicates from sorted list the problem statement is we are giving unsorted linked lists delete all duplicates such that each element appears only once the problem is really straightforward let's get into the code we have this dummy and this is the variable we're going to return and ... | 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 |
234 | A everyone welcome back you take with Rana and this video will be discussing problem statement so what we have given in this question is we have given head note in the question of singular linked list and what we have to return is our linked list. If it is palindromic or not, then if it is in English then we have to re... | Palindrome Linked List | palindrome-linked-list | Given the `head` of a singly linked list, return `true` _if it is a_ _palindrome_ _or_ `false` _otherwise_.
**Example 1:**
**Input:** head = \[1,2,2,1\]
**Output:** true
**Example 2:**
**Input:** head = \[1,2\]
**Output:** false
**Constraints:**
* The number of nodes in the list is in the range `[1, 105]`.
* ... | null | Linked List,Two Pointers,Stack,Recursion | Easy | 9,125,206,2236 |
451 | welcome back everyone we're going to be solving leeco to 451 sort characters by frequency so we're given a string s we need to 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 and we need to return the sorted string if ther... | 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,027 | hey everybody this is Larry this is day 23. right of the legal day challenge hit the like button hit the Subscribe button drop me a Discord let me know what you think about today's Farm uh 10 27 longest arithmetic subsequence giving away nums return the link of the Blogger so we're okay uh can N squared do it N is a th... | Longest Arithmetic Subsequence | sum-of-even-numbers-after-queries | Given an array `nums` of integers, return _the length of the longest arithmetic subsequence in_ `nums`.
**Note** that:
* A **subsequence** is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.
* A sequence `seq` is arithmetic if `s... | null | Array,Simulation | Medium | null |
1,743 | hello everyone and welcome back today we have 743 restore the array from adjacent pairs it says here that there is an integer array nums that consists of n unique elements but you have forgotten it however you do remember every pair of adjacent elements in nums and we are given a 2d integer array adjacent pairs of size... | Restore the Array From Adjacent Pairs | count-substrings-that-differ-by-one-character | There is an integer array `nums` that consists of `n` **unique** elements, but you have forgotten it. However, you do remember every pair of adjacent elements in `nums`.
You are given a 2D integer array `adjacentPairs` of size `n - 1` where each `adjacentPairs[i] = [ui, vi]` indicates that the elements `ui` and `vi` a... | Take every substring of s, change a character, and see how many substrings of t match that substring. Use a Trie to store all substrings of t as a dictionary. | Hash Table,String,Dynamic Programming | Medium | 2256 |
97 | On Ajay's side, in this video we will discuss, so the solution of internet in order to spread, the question comes, we have to put makeup in the third part, into your strength in these two, whether the woman to tell us is made of the interleaving of youth and Vaastu or No otherwise when will we call remove C as interlea... | 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 |
215 | hey guys welcome or welcome back to my channel today we are going to discuss another problem is careth largest element in an array so very basic problem uh in this problem we are given array and an integer k we return the kth largest element in the array note that it is the clear largest element in the sorted order not... | Kth Largest Element in an Array | kth-largest-element-in-an-array | Given an integer array `nums` and an integer `k`, return _the_ `kth` _largest element in the array_.
Note that it is the `kth` largest element in the sorted order, not the `kth` distinct element.
You must solve it in `O(n)` time complexity.
**Example 1:**
**Input:** nums = \[3,2,1,5,6,4\], k = 2
**Output:** 5
**Ex... | null | Array,Divide and Conquer,Sorting,Heap (Priority Queue),Quickselect | Medium | 324,347,414,789,1014,2113,2204,2250 |
767 | hey everybody this is larry it's august 1st in 2020 one uh 22 wow i forgot the year for a second that is actually very awkward but anyway uh this is the extra bonus problem that i promised to do and hope i don't know how long i'm going to keep this up depends on how many people like this if you do like this uh leave a ... | 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,290 | hey guys welcome back to another video and today we're going to be solving the lead code question convert binary number in a linked list to an integer all right so in this question we're going to be given the head which is the reference node to a singly linked list the value of each node in the linked list is either 0 ... | Convert Binary Number in a Linked List to Integer | make-array-strictly-increasing | Given `head` which is a reference node to a singly-linked list. The value of each node in the linked list is either `0` or `1`. The linked list holds the binary representation of a number.
Return the _decimal value_ of the number in the linked list.
The **most significant bit** is at the head of the linked list.
**E... | Use dynamic programming. The state would be the index in arr1 and the index of the previous element in arr2 after sorting it and removing duplicates. | Array,Binary Search,Dynamic Programming | Hard | null |
155 | hi in this video i will show you how to implement the min stack now as usual i will start with the low hanging fruits on how to solve this and then i'm going to build up to the full solution so how do i push something to a stack well this basically means appending something and in this case i will say i have a variable... | Min Stack | min-stack | Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
Implement the `MinStack` class:
* `MinStack()` initializes the stack object.
* `void push(int val)` pushes the element `val` onto the stack.
* `void pop()` removes the element on the top of the stack.
* `int top(... | Consider each node in the stack having a minimum value. (Credits to @aakarshmadhavan) | Stack,Design | Easy | 239,716 |
1,961 | hi there and thanks for tuning in i am texastim.dev and welcome back to my i am texastim.dev and welcome back to my i am texastim.dev and welcome back to my ongoing quest to grind through all of the leak code algorithm problems i've done all the easy ones although sometimes you know leak code posts a new one so i picke... | Check If String Is a Prefix of Array | maximum-ice-cream-bars | Given a string `s` and an array of strings `words`, determine whether `s` is a **prefix string** of `words`.
A string `s` is a **prefix string** of `words` if `s` can be made by concatenating the first `k` strings in `words` for some **positive** `k` no larger than `words.length`.
Return `true` _if_ `s` _is a **prefi... | It is always optimal to buy the least expensive ice cream bar first. Sort the prices so that the cheapest ice cream bar comes first. | Array,Greedy,Sorting | Medium | null |
95 | um hello so today we are going to do this problem which is part of Fleet code daily challenge unique binary search trees number two so basically we have an integer n and we want to return all the structurally unique bsts so basically it means bsts that are unique where when you have a node the left child and the right ... | 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 |
92 | hello friends uh welcome to my channel let's have a look at problem 92 reverse linked list 2. uh in this video we're going to share a solution based on the linear traversal method so first let's read through the statement and then let's analyze the procedure and finally share the code first let's look at the statement ... | Reverse Linked List II | reverse-linked-list-ii | Given the `head` of a singly linked list and two integers `left` and `right` where `left <= right`, reverse the nodes of the list from position `left` to position `right`, and return _the reversed list_.
**Example 1:**
**Input:** head = \[1,2,3,4,5\], left = 2, right = 4
**Output:** \[1,4,3,2,5\]
**Example 2:**
**I... | null | Linked List | Medium | 206 |
95 | hello everyone welcome to our channel code with sunny and in this video i will be talking about uh like medium type problem by unique binary search trees and it is the second type problem of the series of problems you need one research trees okay so the only thing that i will recommend you before solving this problem i... | 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 |
931 | Hello friends today I'm going to solve with good problem number 931 minimum falling path sum in this problem we are given an N by n array of integers and we need to return the minimum sum of the following path now what's a falling path is for a given Row the falling path lies such that it lies in the next row and the c... | 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 |
237 | Hello guys welcome to disrespect interesting video not just coding that time behave with others problem but asked why did no dinner english so let's get started flight function two days later no dinner singly linked list and will not be given access to the head of the List Will Be Given As A Student Made A Stupid Direc... | 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 |
1,913 | hey guys welcome to a new video in today's video we're going to look at a elad quote problem and the problem's name is maximum product difference between two pairs so in this question we are given a array called nums and we have to find two pairs the first pair is a comma B and the second pair is C comma D and we have ... | 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 |
144 | hey what's up guys welcome back to this video in this video we're going to solve this scoring question pre-order traversal of scoring question pre-order traversal of scoring question pre-order traversal of a binary tree in order to master trees problems you have to uh understand the three traversal techniques we can tr... | Binary Tree Preorder Traversal | binary-tree-preorder-traversal | Given the `root` of a binary tree, return _the preorder traversal of its nodes' values_.
**Example 1:**
**Input:** root = \[1,null,2,3\]
**Output:** \[1,2,3\]
**Example 2:**
**Input:** root = \[\]
**Output:** \[\]
**Example 3:**
**Input:** root = \[1\]
**Output:** \[1\]
**Constraints:**
* The number of nodes ... | null | Stack,Tree,Depth-First Search,Binary Tree | Easy | 94,255,775 |
51 | okay let's talk about earn queens so the unqueen puzzle is the problem of placing on queens on the um by unchaste ball such that no two queens attack each other so you are given indigene and you have to re return a value for the ball that is satisfied for every single queen which is four queens on the board so no queen... | N-Queens | n-queens | The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other.
Given an integer `n`, return _all distinct solutions to the **n-queens puzzle**_. You may return the answer in **any order**.
Each solution contains a distinct board configuration of the n-... | null | Array,Backtracking | Hard | 52,1043 |
243 | hey YouTube Welcome Back uh today we have this problem it's um shortest for distance and the problem goes like that give it an array of strings or the word text vertex okay and two or two different strings that uh already exist in the array word one and uh or two return the shortest distance between these two words in ... | Shortest Word Distance | shortest-word-distance | Given an array of strings `wordsDict` and two different strings that already exist in the array `word1` and `word2`, return _the shortest distance between these two words in the list_.
**Example 1:**
**Input:** wordsDict = \[ "practice ", "makes ", "perfect ", "coding ", "makes "\], word1 = "coding ", word2 = "... | null | Array,String | Easy | 244,245,2320 |
47 | 47 permutations - actually we have done 47 permutations - actually we have done 47 permutations - actually we have done that 46 permutations this problem is a similar but with a slight difference we're given a collection of numbers and might contain duplicates return all possible unique permutation in the problems the ... | Permutations II | permutations-ii | Given a collection of numbers, `nums`, that might contain duplicates, return _all possible unique permutations **in any order**._
**Example 1:**
**Input:** nums = \[1,1,2\]
**Output:**
\[\[1,1,2\],
\[1,2,1\],
\[2,1,1\]\]
**Example 2:**
**Input:** nums = \[1,2,3\]
**Output:** \[\[1,2,3\],\[1,3,2\],\[2,1,3\],\[2,3,... | null | Array,Backtracking | Medium | 31,46,267,1038 |
70 | in there today we'll solve one of the liquid problem climbing stairs you are climbing stairs it takes another step to reach to the top so each time you can take either one or two steps so in the example you uh it's given if n is equal to 2 then you can reach there by going from step one and two or either directly you c... | 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 |
485 | From here also we welcome back to my channel beauty adding this time you will today will be solving the problem of its constitutive 150 moving onto this YouTube channel piece which cancer subscribe our Channel all the problems states that you will give in binary this Baba Na Poriya Re Means It Will To Behave In One Or ... | Max Consecutive Ones | max-consecutive-ones | Given a binary array `nums`, return _the maximum number of consecutive_ `1`_'s in the array_.
**Example 1:**
**Input:** nums = \[1,1,0,1,1,1\]
**Output:** 3
**Explanation:** The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3.
**Example 2:**
**Input:** nums = ... | You need to think about two things as far as any window is concerned. One is the starting point for the window. How do you detect that a new window of 1s has started? The next part is detecting the ending point for this window.
How do you detect the ending point for an existing window? If you figure these two things... | Array | Easy | 487,1046,1542,1999 |
1,993 | hey everybody this is larry just me coming q3 of the bi-weekly contest 60 coming q3 of the bi-weekly contest 60 coming q3 of the bi-weekly contest 60 operations on the tree hit the like button hit the subscribe button join me or discord especially if you like contest problems and we'll you know just mess around and tal... | Operations on Tree | sum-of-all-subset-xor-totals | You are given a tree with `n` nodes numbered from `0` to `n - 1` in the form of a parent array `parent` where `parent[i]` is the parent of the `ith` node. The root of the tree is node `0`, so `parent[0] = -1` since it has no parent. You want to design a data structure that allows users to lock, unlock, and upgrade node... | Is there a way to iterate through all the subsets of the array? Can we use recursion to efficiently iterate through all the subsets? | Array,Math,Backtracking,Bit Manipulation,Combinatorics | Easy | null |
5 | hey what's up guys babybjorn4812 coming at you one more time and today we're doing the longest palindromic subsequence problem uh i know this one's been around the block quite a bit it's a very classic problem uh it's not it hasn't been asked much recently it seems but the reason that i picked it is because it like i s... | 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 |
93 | in this video we're going to take a look at a legal problem called restore ip address given a string as containing only digits return all possible valid ip address that can be contained from s you can return them in any order so a valid ip address can contains or consists of exactly four digits or four integers each in... | 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 |
724 | hey everybody this is larry this is me trying to do an extra problem for today so we'll see how that goes uh one that i haven't done before because very often the daily problems now i've done already so this is a little bit additional practice um and unfortunately i don't have uh i don't have what you record i don't ha... | 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 |
258 | welcome back for another video we are going to do another legal question the question is 2 5a add digits given an integer noun repeatedly add only its digits until the result has only one digit and return it for example one non equal 38 the output is 2 for the explanation the process is 30a become 3 plus a become 11 be... | Add Digits | add-digits | Given an integer `num`, repeatedly add all its digits until the result has only one digit, and return it.
**Example 1:**
**Input:** num = 38
**Output:** 2
**Explanation:** The process is
38 --> 3 + 8 --> 11
11 --> 1 + 1 --> 2
Since 2 has only one digit, return it.
**Example 2:**
**Input:** num = 0
**Output:** 0
*... | A naive implementation of the above process is trivial. Could you come up with other methods? What are all the possible results? How do they occur, periodically or randomly? You may find this Wikipedia article useful. | Math,Simulation,Number Theory | Easy | 202,1082,2076,2264 |
1,679 | Hello hi everyone welcome to my channel it's all the problem max number of contact se zara k in one of you can two numbers from removed from the maximum number of operations you can only are some examples 12345 which will subscribe comment and subscribe to operation Head on that feminism paltu hair behavior 314 se zakh... | 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,585 | hey what is up guys today we're back with another elite code video we're going to be doing problem 1585 check if string is transformable with substring sort operations so we're given two strings s and t you want to transform string s into string t using the following operation any number of times choose a nine fp subst... | Check If String Is Transformable With Substring Sort Operations | the-kth-factor-of-n | Given two strings `s` and `t`, transform string `s` into string `t` using the following operation any number of times:
* Choose a **non-empty** substring in `s` and sort it in place so the characters are in **ascending order**.
* For example, applying the operation on the underlined substring in `"14234 "` res... | The factors of n will be always in the range [1, n]. Keep a list of all factors sorted. Loop i from 1 to n and add i if n % i == 0. Return the kth factor if it exist in this list. | Math | Medium | null |
905 | Hello Hi Guys Welcome To Your Deeds And Such Today Will Go Through 121 Problems From Absolute Coding Challenge Shot Amazing Please Like Video And When You Don't Forget To Subscribe To Channel Sudarshan And Shani Update On A Given Ender Of Negativities That Return Are Consisting Of All The even elements of s followed by... | Sort Array By Parity | length-of-longest-fibonacci-subsequence | Given an integer array `nums`, move all the even integers at the beginning of the array followed by all the odd integers.
Return _**any array** that satisfies this condition_.
**Example 1:**
**Input:** nums = \[3,1,2,4\]
**Output:** \[2,4,3,1\]
**Explanation:** The outputs \[4,2,3,1\], \[2,4,1,3\], and \[4,2,1,3\] w... | null | Array,Hash Table,Dynamic Programming | Medium | 1013 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.