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 |
|---|---|---|---|---|---|---|---|---|
78 | are you recording hey everyone ali here today's problem is called subsets and it's been asked by these companies now let's take a look at the question together so the problem gave us an integer array called nums which consists of unique elements and it asked us to return all possible subsets or in other words the power... | Subsets | subsets | Given an integer array `nums` of **unique** elements, return _all possible_ _subsets_ _(the power set)_.
The solution set **must not** contain duplicate subsets. Return the solution in **any order**.
**Example 1:**
**Input:** nums = \[1,2,3\]
**Output:** \[\[\],\[1\],\[2\],\[1,2\],\[3\],\[1,3\],\[2,3\],\[1,2,3\]\]
... | null | Array,Backtracking,Bit Manipulation | Medium | 90,320,800,2109,2170 |
1,508 | In the shift of flash lights of liberty, we are this relationship, that soft morning, Samsung, I am the bank garage, by the way, here it is 1234, given that it can become many of its mornings, DJ Seven is a question in itself, so pay attention to it, then its 1234 Its time starting from two is like two three four earth... | Range Sum of Sorted Subarray Sums | longest-happy-prefix | You are given the array `nums` consisting of `n` positive integers. You computed the sum of all non-empty continuous subarrays from the array and then sorted them in non-decreasing order, creating a new array of `n * (n + 1) / 2` numbers.
_Return the sum of the numbers from index_ `left` _to index_ `right` (**indexed ... | Use Longest Prefix Suffix (KMP-table) or String Hashing. | String,Rolling Hash,String Matching,Hash Function | Hard | 2326 |
125 | hey guys Greg here and let's solve valid pal drum so a phrase is a pal drum if after converting all the uppercase letters into lowercase letters and then you remove all the non-alpha numeric you remove all the non-alpha numeric you remove all the non-alpha numeric characters it's a palindrome if it reads the same forwa... | Valid Palindrome | valid-palindrome | A phrase is a **palindrome** if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers.
Given a string `s`, return `true` _if it is a **palindrome**, or_ `false` _otherwise_... | null | Two Pointers,String | Easy | 234,680,2130,2231 |
377 | hello and welcome to another video today we're going to be working on combination sum 4. in this problem you're given an array of distinct integers in a Target and you want to return the number of possible combinations that add up to the Target test cases are generated so the answer can fit in a 32-bit integer so for t... | Combination Sum IV | combination-sum-iv | Given an array of **distinct** integers `nums` and a target integer `target`, return _the number of possible combinations that add up to_ `target`.
The test cases are generated so that the answer can fit in a **32-bit** integer.
**Example 1:**
**Input:** nums = \[1,2,3\], target = 4
**Output:** 7
**Explanation:**
Th... | null | Array,Dynamic Programming | Medium | 39 |
399 | hey yo how's it going guys babybear4812 here coming at you one more time today with uh what i think is a tricky problem actually the problem is evaluate division problem number 399 only code it's tagged as medium uh i really think this one should be tagged hard but i don't make the rules uh so it's currently being aske... | 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 |
452 | hey everybody this is Larry this is day 18 of the leco d challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's F and uh yeah if you're celebrating it or maybe I'm a little bit late anyway happy St Patrick's Day uh New York it's apparently a big thing chaos ev... | Minimum Number of Arrows to Burst Balloons | minimum-number-of-arrows-to-burst-balloons | There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array `points` where `points[i] = [xstart, xend]` denotes a balloon whose **horizontal diameter** stretches between `xstart` and `xend`. You do not know the exact y-coordinates of the ball... | null | Array,Greedy,Sorting | Medium | 253,435 |
1,567 | hi everyone welcome back so it's quite a tough contest this week and i'm planning to make videos for question two and question three so stay tuned and today let's solve the question uh maximum length of sub array with positive product okay the question statement so given an array on nums we have to find the maximum len... | Maximum Length of Subarray With Positive Product | maximum-number-of-vowels-in-a-substring-of-given-length | Given an array of integers `nums`, find the maximum length of a subarray where the product of all its elements is positive.
A subarray of an array is a consecutive sequence of zero or more values taken out of that array.
Return _the maximum length of a subarray with positive product_.
**Example 1:**
**Input:** nums... | Keep a window of size k and maintain the number of vowels in it. Keep moving the window and update the number of vowels while moving. Answer is max number of vowels of any window. | String,Sliding Window | Medium | null |
844 | hey guys this is Jay so how's everything going in this video I'm going to take another easy problem eight four backspacing string compare we're given two strings as ante return if they're equal when they both are type in the empty text editors hash ming's backspace character know that after backspacing and empty text t... | Backspace String Compare | backspace-string-compare | Given two strings `s` and `t`, return `true` _if they are equal when both are typed into empty text editors_. `'#'` means a backspace character.
Note that after backspacing an empty text, the text will continue empty.
**Example 1:**
**Input:** s = "ab#c ", t = "ad#c "
**Output:** true
**Explanation:** Both s and t... | null | null | Easy | null |
1,837 | welcome guys welcome to my lego summit section so today let's talk about this 1837 sun of dj in base k okay so a given integer array and the base k return sum of digits of and after converting and from 10 to base k so idea is that uh right so for example only goes to 34 which is in base 10 if you change it to base 6 th... | Sum of Digits in Base K | daily-leads-and-partners | Given an integer `n` (in base `10`) and a base `k`, return _the **sum** of the digits of_ `n` _**after** converting_ `n` _from base_ `10` _to base_ `k`.
After converting, each digit should be interpreted as a base `10` number, and the sum should be returned in base `10`.
**Example 1:**
**Input:** n = 34, k = 6
**Out... | null | Database | Easy | null |
1,770 | 1777 maximum score from performing multiplication operations yeah let's first try to understand the problem so we are giving an array of nums and another array of multipliers and this nums is the length of the nums is more than equal to multipliers yeah so this is also reasonable yeah because we're going to use the mul... | Maximum Score from Performing Multiplication Operations | minimum-deletions-to-make-character-frequencies-unique | You are given two **0-indexed** integer arrays `nums` and `multipliers` of size `n` and `m` respectively, where `n >= m`.
You begin with a score of `0`. You want to perform **exactly** `m` operations. On the `ith` operation (**0-indexed**) you will:
* Choose one integer `x` from **either the start or the end** of t... | As we can only delete characters, if we have multiple characters having the same frequency, we must decrease all the frequencies of them, except one. Sort the alphabet characters by their frequencies non-increasingly. Iterate on the alphabet characters, keep decreasing the frequency of the current character until it re... | String,Greedy,Sorting | Medium | 1355,2212 |
26 | Loot Hi Everyone For Today We Are Going To Solve This Problem Point To Remove Duplicates Dark Clean Problems The Giver Shot Dead Cells Remove Duplicates In Place Which Element Of Years Old And New Length Of The Space For Adv You Must Be Modified Into The River In The Term Memory So One Example That They Can See The Giv... | Remove Duplicates from Sorted Array | remove-duplicates-from-sorted-array | Given an integer array `nums` sorted in **non-decreasing order**, remove the duplicates [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm) such that each unique element appears only **once**. The **relative order** of the elements should be kept the **same**. Then return _the number of unique elements in_... | In this problem, the key point to focus on is the input array being sorted. As far as duplicate elements are concerned, what is their positioning in the array when the given array is sorted? Look at the image above for the answer. If we know the position of one of the elements, do we also know the positioning of all th... | Array,Two Pointers | Easy | 27,80 |
1,920 | Ajay Ko Hua [ Hua [ Hua Hello One And Welcome To New Video English Video Viewers Problem Number 90 From The Problem 000 Have to agree here and today let's come in the middle of this in the name of That will be there at once and from the railway station duty reduce 2002 number of clans given till minus one ok ghee probl... | Build Array from Permutation | determine-color-of-a-chessboard-square | Given a **zero-based permutation** `nums` (**0-indexed**), build an array `ans` of the **same length** where `ans[i] = nums[nums[i]]` for each `0 <= i < nums.length` and return it.
A **zero-based permutation** `nums` is an array of **distinct** integers from `0` to `nums.length - 1` (**inclusive**).
**Example 1:**
*... | Convert the coordinates to (x, y) - that is, "a1" is (1, 1), "d7" is (4, 7). Try add the numbers together and look for a pattern. | Math,String | Easy | null |
61 | foreign with the lonely Dash and today we're going over lead code question 61 rotate list which says given the head of a linked list rotate the list to the right by K places okay so we know that k equals 2 and we have a linked list right here which we are going to rotate by two so what does that mean well if our linked... | Rotate List | rotate-list | Given the `head` of a linked list, rotate the list to the right by `k` places.
**Example 1:**
**Input:** head = \[1,2,3,4,5\], k = 2
**Output:** \[4,5,1,2,3\]
**Example 2:**
**Input:** head = \[0,1,2\], k = 4
**Output:** \[2,0,1\]
**Constraints:**
* The number of nodes in the list is in the range `[0, 500]`.
* ... | null | Linked List,Two Pointers | Medium | 189,725 |
110 | hello fellow YouTubers today we're going to look at balanced binary tree which is lead code problem 110 this problem states that given a binary tree determine if it is height balanced for this problem a height balanced binary tree is defined as a binary tree in which the left and right sub trees of every node differ in... | Balanced Binary Tree | balanced-binary-tree | Given a binary tree, determine if it is **height-balanced**.
**Example 1:**
**Input:** root = \[3,9,20,null,null,15,7\]
**Output:** true
**Example 2:**
**Input:** root = \[1,2,2,3,3,null,null,4,4\]
**Output:** false
**Example 3:**
**Input:** root = \[\]
**Output:** true
**Constraints:**
* The number of nodes ... | null | Tree,Depth-First Search,Binary Tree | Easy | 104 |
1,461 | hey guys let's paws Finnegan is chaser in this video I'm going to take a look at 1 4 6 1 check away the string contains all binary codes of size k give me the binary string s and integer K return true if all binary codes from this K is a substring chops as otherwise return false while the battery codes up to R then to ... | Check If a String Contains All Binary Codes of Size K | count-all-valid-pickup-and-delivery-options | Given a binary string `s` and an integer `k`, return `true` _if every binary code of length_ `k` _is a substring of_ `s`. Otherwise, return `false`.
**Example 1:**
**Input:** s = "00110110 ", k = 2
**Output:** true
**Explanation:** The binary codes of length 2 are "00 ", "01 ", "10 " and "11 ". They can be all f... | Use the permutation and combination theory to add one (P, D) pair each time until n pairs. | Math,Dynamic Programming,Combinatorics | Hard | null |
1,796 | welcome back for another video we are going to do another legal question the question is second largest digit in a string given an alphanumeric string s return the second largest numerical digi that appears in s or negative one if it does not exist a alphanumeric string is a string consisting of lowercase english lette... | Second Largest Digit in a String | correct-a-binary-tree | Given an alphanumeric string `s`, return _the **second largest** numerical digit that appears in_ `s`_, or_ `-1` _if it does not exist_.
An **alphanumeric** string is a string consisting of lowercase English letters and digits.
**Example 1:**
**Input:** s = "dfa12321afd "
**Output:** 2
**Explanation:** The digits t... | If you traverse the tree from right to left, the invalid node will point to a node that has already been visited. | Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree | Medium | 114,766 |
1,740 | hello and welcome back to the cracking Fang YouTube channel today we're solving lead code problem 1,740 find distance in binary tree given 1,740 find distance in binary tree given 1,740 find distance in binary tree given the root of a binary tree and two integers p and Q return the distance between the nodes of p and v... | Find Distance in a Binary Tree | count-subtrees-with-max-distance-between-cities | Given the root of a binary tree and two integers `p` and `q`, return _the **distance** between the nodes of value_ `p` _and value_ `q` _in the tree_.
The **distance** between two nodes is the number of edges on the path from one to the other.
**Example 1:**
**Input:** root = \[3,5,1,6,2,0,8,null,null,7,4\], p = 5, q... | Iterate through every possible subtree by doing a bitmask on which vertices to include. How can you determine if a subtree is valid (all vertices are connected)? To determine connectivity, count the number of reachable vertices starting from any included vertex and only traveling on edges connecting 2 vertices in the s... | Dynamic Programming,Bit Manipulation,Tree,Enumeration,Bitmask | Hard | 1177 |
173 | tree iterator problem number 173 on leak code and you are to implement the bst iterator class so you have to implement the constructor for this class and then two methods one called next and the one next is called has next so um you're given uh the root of the tree in your constructor and then you're supposed to keep t... | Binary Search Tree Iterator | binary-search-tree-iterator | Implement the `BSTIterator` class that represents an iterator over the **[in-order traversal](https://en.wikipedia.org/wiki/Tree_traversal#In-order_(LNR))** of a binary search tree (BST):
* `BSTIterator(TreeNode root)` Initializes an object of the `BSTIterator` class. The `root` of the BST is given as part of the co... | null | Stack,Tree,Design,Binary Search Tree,Binary Tree,Iterator | Medium | 94,251,281,284,285,1729 |
81 | welcome to tim's leco challenge this problem is called search and rotated sorted array 2. there is an android num sorted in non-decreasing order but not necessarily non-decreasing order but not necessarily non-decreasing order but not necessarily with distinct values before being passed to your function nums is rotated... | Search in Rotated Sorted Array II | search-in-rotated-sorted-array-ii | There is an integer array `nums` sorted in non-decreasing order (not necessarily with **distinct** values).
Before being passed to your function, `nums` is **rotated** at an unknown pivot index `k` (`0 <= k < nums.length`) such that the resulting array is `[nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nu... | null | Array,Binary Search | Medium | 33 |
920 | hey everyone today we are going to solve the readable question number of Music playlist so your music player contains any different songs so you want to listen to your gold songs not necessarily different during your trip to avoid your boredom you will create a playlist so that every song is played at least once a song... | Number of Music Playlists | uncommon-words-from-two-sentences | Your music player contains `n` different songs. You want to listen to `goal` songs (not necessarily different) during your trip. To avoid boredom, you will create a playlist so that:
* Every song is played **at least once**.
* A song can only be played again only if `k` other songs have been played.
Given `n`, `g... | null | Hash Table,String | Easy | 2190 |
46 | hi guys today let's discuss the lead code question 46 permutations given an array nums of distinct integers return all possible permutations you can return the answer in any order so permutations is the arrangement of the given numbers so let's go to the example one so the example one nums is equal to 1A 2A 3 since the... | Permutations | permutations | Given an array `nums` of distinct integers, return _all the possible permutations_. You can return the answer in **any order**.
**Example 1:**
**Input:** nums = \[1,2,3\]
**Output:** \[\[1,2,3\],\[1,3,2\],\[2,1,3\],\[2,3,1\],\[3,1,2\],\[3,2,1\]\]
**Example 2:**
**Input:** nums = \[0,1\]
**Output:** \[\[0,1\],\[1,0\... | null | Array,Backtracking | Medium | 31,47,60,77 |
1,816 | hello uh hello to all and welcome to my youtube channel today we will be going to solve uh another lead code problem for problem number 18 16 the problem name is truncate sentence so let's just read the problem sentence is a list of words that is separated by single space with no leading or training spaces each of the ... | Truncate Sentence | lowest-common-ancestor-of-a-binary-tree-iv | A **sentence** is a list of words that are separated by a single space with no leading or trailing spaces. Each of the words consists of **only** uppercase and lowercase English letters (no punctuation).
* For example, `"Hello World "`, `"HELLO "`, and `"hello world hello world "` are all sentences.
You are given a... | Starting from the root, traverse the left and the right subtrees, checking if one of the nodes exist there. If one of the subtrees doesn't contain any given node, the LCA can be the node returned from the other subtree If both subtrees contain nodes, the LCA node is the current node. | Tree,Depth-First Search,Binary Tree | Medium | 235,236,1218,1780,1790,1816 |
1,887 | hey everyone today we are going to solve the reduction operations to make the array elements equal okay so first of all look at this so I always think about the solutions with a small and simple input so let's focus on one two in this case if we uh reduce one from two so we will get the output right in this case one ti... | Reduction Operations to Make the Array Elements Equal | minimum-degree-of-a-connected-trio-in-a-graph | Given an integer array `nums`, your goal is to make all elements in `nums` equal. To complete one operation, follow these steps:
1. Find the **largest** value in `nums`. Let its index be `i` (**0-indexed**) and its value be `largest`. If there are multiple elements with the largest value, pick the smallest `i`.
2. F... | Consider a trio with nodes u, v, and w. The degree of the trio is just degree(u) + degree(v) + degree(w) - 6. The -6 comes from subtracting the edges u-v, u-w, and v-w, which are counted twice each in the vertex degree calculation. To get the trios (u,v,w), you can iterate on u, then iterate on each w,v such that w and... | Graph | Hard | null |
129 | hello coders today we are going to solve another lead for daily challenge and the question name is time and 5 so the numbers that comes out to base 495 right a girl is and we have to calculate the overall sum so the first number is 495 second number is 4 9 and well right this is the second part from root to sleep node ... | 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 |
795 | Hello Everyone Suggest This Solving Number Of But Maximum And Used As A Valid Which Change To Question And Give Positive Enters Into Positive Winters Left And Right The Number Of Class Ninth Subscribe Maximum Element In This Loot Mein Strike Enters Into All The Element Lose Weight Chandra Equal Her Ones 300 Flats Consi... | Number of Subarrays with Bounded Maximum | k-th-symbol-in-grammar | Given an integer array `nums` and two integers `left` and `right`, return _the number of contiguous non-empty **subarrays** such that the value of the maximum array element in that subarray is in the range_ `[left, right]`.
The test cases are generated so that the answer will fit in a **32-bit** integer.
**Example 1:... | Try to represent the current (N, K) in terms of some (N-1, prevK). What is prevK ? | Math,Bit Manipulation,Recursion | Medium | null |
60 | Hello hello guys welcome back to tech division in this video you will see politicians sequence problem specific from list to date 24th june challenge so let's not look at the problem statement in this problem where given interview k when is the number of units and want to No and will not give me the information subscri... | Permutation Sequence | permutation-sequence | The set `[1, 2, 3, ..., n]` contains a total of `n!` unique permutations.
By listing and labeling all of the permutations in order, we get the following sequence for `n = 3`:
1. `"123 "`
2. `"132 "`
3. `"213 "`
4. `"231 "`
5. `"312 "`
6. `"321 "`
Given `n` and `k`, return the `kth` permutation sequence.
**Exa... | null | Math,Recursion | Hard | 31,46 |
920 | Hello friends today let's solve number of music playlists um so we are given integer and it means we have a different sums and we want to listen to Go songs but they are not necessarily different we must make sure some can only be played again after chaos songs have been played if you look at this example you will wond... | Number of Music Playlists | uncommon-words-from-two-sentences | Your music player contains `n` different songs. You want to listen to `goal` songs (not necessarily different) during your trip. To avoid boredom, you will create a playlist so that:
* Every song is played **at least once**.
* A song can only be played again only if `k` other songs have been played.
Given `n`, `g... | null | Hash Table,String | Easy | 2190 |
1,605 | hello and welcome so today we'll be discussing one of the very important problem of uh lead code which is a problem number one six zero five and the problem is find valid matrix given row and column sum so what you have given row sum and column sum and you have to find the valid matrix so what this problem is all about... | Find Valid Matrix Given Row and Column Sums | minimum-number-of-days-to-make-m-bouquets | You are given two arrays `rowSum` and `colSum` of non-negative integers where `rowSum[i]` is the sum of the elements in the `ith` row and `colSum[j]` is the sum of the elements of the `jth` column of a 2D matrix. In other words, you do not know the elements of the matrix, but you do know the sums of each row and column... | If we can make m or more bouquets at day x, then we can still make m or more bouquets at any day y > x. We can check easily if we can make enough bouquets at day x if we can get group adjacent flowers at day x. | Array,Binary Search | Medium | 2134,2257 |
238 | hey guys welcome back today we're taking a look at product of array except self which is a pretty tricky array question that requires a bit of a creative twist on what we know so given an integer array nums return an array answer such that answer at index i is equal to the product of all elements of nums except nums of... | Product of Array Except Self | product-of-array-except-self | Given an integer array `nums`, return _an array_ `answer` _such that_ `answer[i]` _is equal to the product of all the elements of_ `nums` _except_ `nums[i]`.
The product of any prefix or suffix of `nums` is **guaranteed** to fit in a **32-bit** integer.
You must write an algorithm that runs in `O(n)` time and without... | null | Array,Prefix Sum | Medium | 42,152,265,2267 |
1,091 | hi everyone in today challenge we are going to solve this problem the problem name is path in a binary Matrix and the problem is one zero nine one all right guys so first of all we are going to clearly understand this problem statement after that we are going to move to the logic part we are going to see how we can sol... | 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 |
1,750 | Hello everyone welcome to my channel quote sir with me so today we are going to watch the video number of our t pointer technique playlist ok and the lead code is marked medium but actually it is a very easy question a lead code number is 1750 the name of the question is Minimum length of string after delete Similar en... | Minimum Length of String After Deleting Similar Ends | check-if-two-expression-trees-are-equivalent | Given a string `s` consisting only of characters `'a'`, `'b'`, and `'c'`. You are asked to apply the following algorithm on the string any number of times:
1. Pick a **non-empty** prefix from the string `s` where all the characters in the prefix are equal.
2. Pick a **non-empty** suffix from the string `s` where all... | Count for each variable how many times it appeared in the first tree. Do the same for the second tree and check if the count is the same for both tree. | Tree,Depth-First Search,Binary Tree | Medium | 1736 |
100 | Everyone welcome you my channel ok the name of the question is it has been asked many times ok Google Amazon Meta Adobe Bloomberg mentarax ok I came to college in mental graphics this company then they asked this question ok If there is input problem then understand what is the question? The question is very simple. It... | Same Tree | same-tree | Given the roots of two binary trees `p` and `q`, write a function to check if they are the same or not.
Two binary trees are considered the same if they are structurally identical, and the nodes have the same value.
**Example 1:**
**Input:** p = \[1,2,3\], q = \[1,2,3\]
**Output:** true
**Example 2:**
**Input:** p... | null | Tree,Depth-First Search,Breadth-First Search,Binary Tree | Easy | null |
1,094 | hey everybody this is larry this is day 21 of the leco daily challenge for september uh hit the like button hit the subscribe button join me on discord and let's go get started on today's problem carpooling um you're driving a vehicle that contains capacity of me the vehicle only drives these so going from left to righ... | Car Pooling | matrix-cells-in-distance-order | There is a car with `capacity` empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west).
You are given the integer `capacity` and an array `trips` where `trips[i] = [numPassengersi, fromi, toi]` indicates that the `ith` trip has `numPassengersi` passengers and the locations to pick them u... | null | Array,Math,Geometry,Sorting,Matrix | Easy | 2304 |
1,496 | hello guys and welcome back to lead Logics this is the path Crossing problem from lead code this is a lead code easy and the number for this is 1496 so in the given problem we are having a string path where path of i signifies uh a letter in from the following n s e w representing uh north south east and west and one u... | Path Crossing | lucky-numbers-in-a-matrix | Given a string `path`, where `path[i] = 'N'`, `'S'`, `'E'` or `'W'`, each representing moving one unit north, south, east, or west, respectively. You start at the origin `(0, 0)` on a 2D plane and walk on the path specified by `path`.
Return `true` _if the path crosses itself at any point, that is, if at any time you ... | Find out and save the minimum of each row and maximum of each column in two lists. Then scan through the whole matrix to identify the elements that satisfy the criteria. | Array,Matrix | Easy | null |
1,636 | hey everybody this is larry this is me going over q1 of the buy weekly contest 38 uh sort away by increasing frequency so this is actually a great example of using a key sorting by key instead of comparison so i mean i know that underneath it does comparison but literally um you want to sort by some value which is the ... | Sort Array by Increasing Frequency | number-of-substrings-with-only-1s | Given an array of integers `nums`, sort the array in **increasing** order based on the frequency of the values. If multiple values have the same frequency, sort them in **decreasing** order.
Return the _sorted array_.
**Example 1:**
**Input:** nums = \[1,1,2,2,2,3\]
**Output:** \[3,1,1,2,2,2\]
**Explanation:** '3' h... | Count number of 1s in each consecutive-1 group. For a group with n consecutive 1s, the total contribution of it to the final answer is (n + 1) * n // 2. | Math,String | Medium | 1885,2186 |
96 | hello everyone welcome to a Cohiba in this video student solve the problem binary search tree before we start the channel how many unique values and is equal to 1 only one unique tree that can be built that is with 1 if n is equal to 2 we can build one as a root and 2 or 2 as a root and 1 2 unique binary trees if n is ... | Unique Binary Search Trees | unique-binary-search-trees | Given an integer `n`, return _the number of structurally unique **BST'**s (binary search trees) which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`.
**Example 1:**
**Input:** n = 3
**Output:** 5
**Example 2:**
**Input:** n = 1
**Output:** 1
**Constraints:**
* `1 <= n <= 19` | null | Math,Dynamic Programming,Tree,Binary Search Tree,Binary Tree | Medium | 95 |
225 | hello and welcome to another video today we're going to be working on Implement stack using cues and this problem is I'd say not quite an easy problem and depends on your implementation as well um so I'd say it's closer to a medium problem but in this problem you're asked to implement a lasting first out stack so norma... | Implement Stack using Queues | implement-stack-using-queues | Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (`push`, `top`, `pop`, and `empty`).
Implement the `MyStack` class:
* `void push(int x)` Pushes element x to the top of the stack.
* `int pop()` Removes the element on the top... | null | Stack,Design,Queue | Easy | 232 |
949 | Hello hello everyone welcome to difficult challenge today's question is the largest time from giving details should give in any with after land for india to generate maximum time button video politician id am id for the time 4 minutes ago 220 this simple question is innovation award recruitment of All your activities t... | 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,424 | Everyone welcome to my channel code sari with mike so today we are going to do video number 70 of our playlist lead code number 1424 is a very easy question and already we have made another question which is exact same diagonal traverse one on that. You will also get the video on my playlist, you will get it in the sam... | Diagonal Traverse II | maximum-candies-you-can-get-from-boxes | Given a 2D integer array `nums`, return _all elements of_ `nums` _in diagonal order as shown in the below images_.
**Example 1:**
**Input:** nums = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\]
**Output:** \[1,4,2,7,5,3,8,6,9\]
**Example 2:**
**Input:** nums = \[\[1,2,3,4,5\],\[6,7\],\[8\],\[9,10,11\],\[12,13,14,15,16\]\]
**Ou... | Use Breadth First Search (BFS) to traverse all possible boxes you can open. Only push to the queue the boxes the you have with their keys. | Array,Breadth-First Search | Hard | null |
459 | hello everyone this is cpedit and in this video we'll be solving this problem repeated substring pattern so in this problem we have to tell whether we can create this original string using multiple copies of its substring so let's get started so for example the input is abab so the example is a b so if we choose this s... | Repeated Substring Pattern | repeated-substring-pattern | Given a string `s`, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.
**Example 1:**
**Input:** s = "abab "
**Output:** true
**Explanation:** It is the substring "ab " twice.
**Example 2:**
**Input:** s = "aba "
**Output:** false
**Example 3:**
... | null | String,String Matching | Easy | 28,686 |
392 | hey everyone so we are looking at leak code 392 is subsequence and this is going to be building off of that work that we've been talking about previously in this data structures and algorithms series so hopefully you've seen the last video where you have a solid understanding of some of the logic and how to approach th... | Is Subsequence | is-subsequence | Given two strings `s` and `t`, return `true` _if_ `s` _is a **subsequence** of_ `t`_, or_ `false` _otherwise_.
A **subsequence** of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i... | null | Two Pointers,String,Dynamic Programming | Easy | 808,1051 |
1,689 | hey everybody this is larry this is me going over weekly contest 219 q2 partitioning into minimum number of deci binary numbers uh hit the like button hit the subscribe button join me in this card let me know what you think about this problem so for this problem to be honest i was a little bit thrown up by it because i... | 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 |
1,808 | hey everybody this is larry this is day what q4 delete code uh weekly contest 224 maximize number of nice divisors um hit the like button to subscribe and join me on discord let me know what you think about today's prom so this one it's um you look at this answer and it's weird uh it's actually a very ad hoc one-off pr... | Maximize Number of Nice Divisors | stone-game-vii | You are given a positive integer `primeFactors`. You are asked to construct a positive integer `n` that satisfies the following conditions:
* The number of prime factors of `n` (not necessarily distinct) is **at most** `primeFactors`.
* The number of nice divisors of `n` is maximized. Note that a divisor of `n` is... | The constraints are small enough for an N^2 solution. Try using dynamic programming. | Array,Math,Dynamic Programming,Game Theory | Medium | 909,1240,1522,1617,1685,1788,1896,2002,2156 |
1,658 | Which Hybrid Today's Problems Minimum Operations to Reduce First Year Considering The Right Vyati St Anselms 512 Must Subscribe Now To The Numbers - To The Numbers - To The Numbers - Gabbar Samay Students - 110 Questions Of Make Sure Let's See What This Gabbar Samay Students - 110 Questions Of Make Sure Let's See What ... | Minimum Operations to Reduce X to Zero | minimum-swaps-to-arrange-a-binary-grid | You are given an integer array `nums` and an integer `x`. In one operation, you can either remove the leftmost or the rightmost element from the array `nums` and subtract its value from `x`. Note that this **modifies** the array for future operations.
Return _the **minimum number** of operations to reduce_ `x` _to **e... | For each row of the grid calculate the most right 1 in the grid in the array maxRight. To check if there exist answer, sort maxRight and check if maxRight[i] ≤ i for all possible i's. If there exist an answer, simulate the swaps. | Array,Greedy,Matrix | Medium | null |
368 | Hello Guys Welcome Back To Back Door And This Video Will See The Largest Divisible Most Problem Wishes From List To Date 18th June Challenge So Let's Follow Problem Statement Problem Years And Give Winners Of Distinct Possibilities For The Largest Subscribe My Of Elements In This Subscribe Mode on more solution fog sub... | Largest Divisible Subset | largest-divisible-subset | Given a set of **distinct** positive integers `nums`, return the largest subset `answer` such that every pair `(answer[i], answer[j])` of elements in this subset satisfies:
* `answer[i] % answer[j] == 0`, or
* `answer[j] % answer[i] == 0`
If there are multiple solutions, return any of them.
**Example 1:**
**Inp... | null | Array,Math,Dynamic Programming,Sorting | Medium | null |
906 | Hello everyone welcome to our channel question and you want to talk about one of the heart problems soft code no problem you support super first entrance end 1.06 ok so support super first entrance end 1.06 ok so support super first entrance end 1.06 ok so iss rule se reduce problem shubh related sampan roaming type ok... | Super Palindromes | walking-robot-simulation | Let's say a positive integer is a **super-palindrome** if it is a palindrome, and it is also the square of a palindrome.
Given two positive integers `left` and `right` represented as strings, return _the number of **super-palindromes** integers in the inclusive range_ `[left, right]`.
**Example 1:**
**Input:** left ... | null | Array,Simulation | Medium | 2178 |
787 | hello everyone today's question cheapest flights within K stops so there are in cities connected by implied each flight starts from CTU and arrives at B with a price W so now given all the cities and flights together with starting city s RC and destination DST so your task is to find the cheapest price from is her sour... | Cheapest Flights Within K Stops | sliding-puzzle | There are `n` cities connected by some number of flights. You are given an array `flights` where `flights[i] = [fromi, toi, pricei]` indicates that there is a flight from city `fromi` to city `toi` with cost `pricei`.
You are also given three integers `src`, `dst`, and `k`, return _**the cheapest price** from_ `src` _... | Perform a breadth-first-search, where the nodes are the puzzle boards and edges are if two puzzle boards can be transformed into one another with one move. | Array,Breadth-First Search,Matrix | Hard | null |
139 | in this video we're going to take a look at a legal problem called word break so given a non-empty string s and a so given a non-empty string s and a so given a non-empty string s and a dictionary um containing a list of non-empty words um containing a list of non-empty words um containing a list of non-empty words det... | Word Break | word-break | Given a string `s` and a dictionary of strings `wordDict`, return `true` if `s` can be segmented into a space-separated sequence of one or more dictionary words.
**Note** that the same word in the dictionary may be reused multiple times in the segmentation.
**Example 1:**
**Input:** s = "leetcode ", wordDict = \[ "... | null | Hash Table,String,Dynamic Programming,Trie,Memoization | Medium | 140 |
289 | hey everyone uh in this video i'm going to explain the solution for a lead code question called game of life which is by some big tech companies and also at the same time i'm going to go through the steps we should follow in the real code interview so let's get started so in the real coding interview the first step is ... | Game of Life | game-of-life | According to [Wikipedia's article](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life): "The **Game of Life**, also known simply as **Life**, is a cellular automaton devised by the British mathematician John Horton Conway in 1970. "
The board is made up of an `m x n` grid of cells, where each cell has an initial st... | null | Array,Matrix,Simulation | Medium | 73 |
236 | Hello hello everyone welcome to our channel audition in this video will be discussing the lowest comment and sister for * I am very famous comment and sister for * I am very famous comment and sister for * I am very famous problem that is present and internet code where it's nx is 236 setting categorized medium problem... | Lowest Common Ancestor of a Binary Tree | lowest-common-ancestor-of-a-binary-tree | Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
According to the [definition of LCA on Wikipedia](https://en.wikipedia.org/wiki/Lowest_common_ancestor): "The lowest common ancestor is defined between two nodes `p` and `q` as the lowest node in `T` that has both `p` and `q` as... | null | Tree,Depth-First Search,Binary Tree | Medium | 235,1190,1354,1780,1790,1816,2217 |
983 | hi everyone it's Cen today we have a problem when we are planning a travel one year in advance and for example let's take this scenario we are traveling let's say that on the 1st 4th 6 7 8 and the 20th day of the year and we need to calculate the how the minimum number of dollars so minimum amount that we can pay for o... | 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 |
451 | what's up guys episode is here with another lead code question and today we're solving leak code 451 sort characters by frequency once again if you want to solve this problem please take the time to solve it and come back to this video once you've solved the problem awesome so for this problem we're given a string and ... | 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,760 | hello uh today i'm gonna solve the problem a minimum limit of volts in the back this problem is quite hard for me for the first time but once you got the way of thinking it will be pretty simple and arrogant so let's get started so first of all we are given noms array and also max operations integers and we need to div... | Minimum Limit of Balls in a Bag | check-array-formation-through-concatenation | You are given an integer array `nums` where the `ith` bag contains `nums[i]` balls. You are also given an integer `maxOperations`.
You can perform the following operation at most `maxOperations` times:
* Take any bag of balls and divide it into two new bags with a **positive** number of balls.
* For example, ... | Note that the distinct part means that every position in the array belongs to only one piece Note that you can get the piece every position belongs to naively | Array,Hash Table | Easy | null |
152 | what is up everybody welcome back to my channel this is tony aka one lead code one day if you're new here this channel does one lead code per day following the pattern of topics or series that is i'm going to be solving with you together on a lead code problem i have never attempted before you heard that right there is... | Maximum Product Subarray | maximum-product-subarray | Given an integer array `nums`, find a subarray that has the largest product, and return _the product_.
The test cases are generated so that the answer will fit in a **32-bit** integer.
**Example 1:**
**Input:** nums = \[2,3,-2,4\]
**Output:** 6
**Explanation:** \[2,3\] has the largest product 6.
**Example 2:**
**I... | null | Array,Dynamic Programming | Medium | 53,198,238,628,713 |
1,925 | let's solve 1925 count Square some triplets so the question says that you need to find all Pythagoras triplets until the number n so say for example of the N is 10 okay n is equal to 10 so I need to find all Pythagoras triplets under 10 so the first one would be 3 4 and five where three square of 3 + square of five whe... | Count Square Sum Triples | count-nice-pairs-in-an-array | A **square triple** `(a,b,c)` is a triple where `a`, `b`, and `c` are **integers** and `a2 + b2 = c2`.
Given an integer `n`, return _the number of **square triples** such that_ `1 <= a, b, c <= n`.
**Example 1:**
**Input:** n = 5
**Output:** 2
**Explanation**: The square triples are (3,4,5) and (4,3,5).
**Example 2... | The condition can be rearranged to (nums[i] - rev(nums[i])) == (nums[j] - rev(nums[j])). Transform each nums[i] into (nums[i] - rev(nums[i])). Then, count the number of (i, j) pairs that have equal values. Keep a map storing the frequencies of values that you have seen so far. For each i, check if nums[i] is in the map... | Array,Hash Table,Math,Counting | Medium | 2129 |
138 | lead code practice time so two goals the first one is to see how to solve this problem and then we are going to put some code here and the second one is to see how they behave during every interview suppose this is some problem happening in the real interview so let's get started so the first one is the first step in t... | Copy List with Random Pointer | copy-list-with-random-pointer | A linked list of length `n` is given such that each node contains an additional random pointer, which could point to any node in the list, or `null`.
Construct a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) of the list. The deep copy should consist of exactly `n` **brand new** nodes, where e... | Just iterate the linked list and create copies of the nodes on the go. Since a node can be referenced from multiple nodes due to the random pointers, make sure you are not making multiple copies of the same node. You may want to use extra space to keep old node ---> new node mapping to prevent creating multiples copies... | Hash Table,Linked List | Medium | 133,1624,1634 |
1,332 | hey everybody this is larry this is day eight of the march lead code daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's prom remove panoramic subsequence okay given only a's and b's could remove one parameter subsequence from s we turn the minimum st... | Remove Palindromic Subsequences | count-vowels-permutation | You are given a string `s` consisting **only** of letters `'a'` and `'b'`. In a single step you can remove one **palindromic subsequence** from `s`.
Return _the **minimum** number of steps to make the given string empty_.
A string is a **subsequence** of a given string if it is generated by deleting some characters o... | Use dynamic programming. Let dp[i][j] be the number of strings of length i that ends with the j-th vowel. Deduce the recurrence from the given relations between vowels. | Dynamic Programming | Hard | null |
146 | okay so uh lead code practice time um this uh this is the last question for today uh there are two goals for this uh video the first one is to see uh how do you solve this problem and then we are going to put some code in and the second one is to see how to behave in a real interview given the question so let's get sta... | 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 |
684 | welcome to midnight coding everyone today we'll solve lead code question 684 redundant connection this is a graph problem and we'll be using union find algorithm to solve this problem but before we continue please like this video and subscribe to the channel as it will provide you with all the luck you need on your upc... | 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 |
1,248 | hello fans today I'm gonna talk about new decoded trail for a two car number oh nice Subway's the problem that came an array of integers none and you need your K a subway he's caught on ice if they are K or the numbers on it between a number of last several ways no Kevin Jews Emperor why is that there are five numbers ... | Count Number of Nice Subarrays | binary-tree-coloring-game | Given an array of integers `nums` and an integer `k`. A continuous subarray is called **nice** if there are `k` odd numbers on it.
Return _the number of **nice** sub-arrays_.
**Example 1:**
**Input:** nums = \[1,1,2,1,1\], k = 3
**Output:** 2
**Explanation:** The only sub-arrays with 3 odd numbers are \[1,1,2,1\] an... | The best move y must be immediately adjacent to x, since it locks out that subtree. Can you count each of (up to) 3 different subtrees neighboring x? | Tree,Depth-First Search,Binary Tree | Medium | null |
201 | hello everyone this is sham saari and I welcome you again in the new video of our YouTube channel so this is a lead code problem which was asked on 21st of February and the problem is medium so pit wise and of numbers range so they have given two integers left and right that represent range left right left to right and... | 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,696 | hello everyone so in this video we are going to solve a question complete code it is jump game 6 this is 1696 question read code and this comes under medium category all right so let's start with the problem statement you are given and zero indexed integer l in nums and in integer k you are initially standing at index ... | Jump Game VI | strange-printer-ii | You are given a **0-indexed** integer array `nums` and an integer `k`.
You are initially standing at index `0`. In one move, you can jump at most `k` steps forward without going outside the boundaries of the array. That is, you can jump from index `i` to any index in the range `[i + 1, min(n - 1, i + k)]` **inclusive*... | Try thinking in reverse. Given the grid, how can you tell if a colour was painted last? | Array,Graph,Topological Sort,Matrix | Hard | 664 |
54 | hi everyone welcome back to this channel I hope you guys are doing well today we are going to solve one of the famous lead chord problems spiral Matrix in this problem we have one mn2 and Matrix and we need to retrieve all the elements in spiral order for example for this Matrix we need to travel like this from this ce... | 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 |
44 | so in this video we are going to solve wired card matching problem so suppose if you have been given one string and you also have the pattern so you have to say according to this pattern this string is matching or not so if you see here suppose a string is SS and pattern is a so it will not match right so if you see he... | Wildcard Matching | wildcard-matching | Given an input string (`s`) and a pattern (`p`), implement wildcard pattern matching with support for `'?'` and `'*'` where:
* `'?'` Matches any single character.
* `'*'` Matches any sequence of characters (including the empty sequence).
The matching should cover the **entire** input string (not partial).
**Exam... | null | String,Dynamic Programming,Greedy,Recursion | Hard | 10 |
841 | hi guys welcome to algorithms made easy in this video we'll go through the question keys and rooms there are n rooms and you start in room 0. each room has a distinct number 0 to n minus 1 and each room may have some keys to access the next room formally each room i has a list of keys letters given in an array form roo... | Keys and Rooms | shortest-distance-to-a-character | There are `n` rooms labeled from `0` to `n - 1` and all the rooms are locked except for room `0`. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key.
When you visit a room, you may find a set of **distinct keys** in it. Each key has a number on it, denoting which room i... | null | Array,Two Pointers,String | Easy | null |
1,725 | now let's go over the code question number 1725 number of rectangles that can form the largest square now the question says you're given an array rectangle is at index i represents the i rectangle at length and width so this is length and this is good you can cut the eighth rectangle to form a square with a size length... | Number Of Rectangles That Can Form The Largest Square | number-of-sets-of-k-non-overlapping-line-segments | You are given an array `rectangles` where `rectangles[i] = [li, wi]` represents the `ith` rectangle of length `li` and width `wi`.
You can cut the `ith` rectangle to form a square with a side length of `k` if both `k <= li` and `k <= wi`. For example, if you have a rectangle `[4,6]`, you can cut it to get a square wit... | Try to use dynamic programming where the current index and remaining number of line segments to form can describe any intermediate state. To make the computation of each state in constant time, we could add another flag to the state that indicates whether or not we are in the middle of placing a line (placed start poin... | Math,Dynamic Programming | Medium | null |
394 | hello everyone welcome back after a very long time welcome back to my channel i am amitesh and today we will be discussing a very good question which i found while i was solving it for uh this uh six companies 30 days challenged by our square and the problem name is the code string it has been asked by goldman sachs an... | Decode String | decode-string | Given an encoded string, return its decoded string.
The encoding rule is: `k[encoded_string]`, where the `encoded_string` inside the square brackets is being repeated exactly `k` times. Note that `k` is guaranteed to be a positive integer.
You may assume that the input string is always valid; there are no extra white... | null | String,Stack,Recursion | Medium | 471,726,1076 |
1,247 | Hello gas welcome you new video, so this problem is a very interesting problem and one of my favorite question is from Giridih. Okay, so in the question it is said that we are given two strings S1 and S2 of equal length. It is already mentioned that out of the lengths of S, Van and Tu, X and A from two letters will eit... | Minimum Swaps to Make Strings Equal | decrease-elements-to-make-array-zigzag | You are given two strings `s1` and `s2` of equal length consisting of letters `"x "` and `"y "` **only**. Your task is to make these two strings equal to each other. You can swap any two characters that belong to **different** strings, which means: swap `s1[i]` and `s2[j]`.
Return the minimum number of swaps required ... | Do each case (even indexed is greater, odd indexed is greater) separately. In say the even case, you should decrease each even-indexed element until it is lower than its immediate neighbors. | Array,Greedy | Medium | null |
277 | hey how's it going everyone welcome to another video today we're going to be doing another leak code problem and this is a problem that is really fun in my opinion and it's called find the celebrity and it's a leak cook medium and this is actually a problem that a buddy of mine saw in a phone interview at Amazon so obv... | Find the Celebrity | find-the-celebrity | Suppose you are at a party with `n` people labeled from `0` to `n - 1` and among them, there may exist one celebrity. The definition of a celebrity is that all the other `n - 1` people know the celebrity, but the celebrity does not know any of them.
Now you want to find out who the celebrity is or verify that there is... | The best hint for this problem can be provided by the following figure: Well, if you understood the gist of the above idea, you can extend it to find a candidate that can possibly be a celebrity. Why do we say a "candidate"? That is for you to think. This is clearly a greedy approach to find the answer. However, there ... | Two Pointers,Greedy,Graph,Interactive | Medium | 1039 |
1,725 | hello everybody today we will focus on solving lead code problem one seven two five number of direct tanks that can form the largest square if you read the question we are giving off the in uh this arrival list and here in this array list we are given the items that represent them represent the length and width of the ... | Number Of Rectangles That Can Form The Largest Square | number-of-sets-of-k-non-overlapping-line-segments | You are given an array `rectangles` where `rectangles[i] = [li, wi]` represents the `ith` rectangle of length `li` and width `wi`.
You can cut the `ith` rectangle to form a square with a side length of `k` if both `k <= li` and `k <= wi`. For example, if you have a rectangle `[4,6]`, you can cut it to get a square wit... | Try to use dynamic programming where the current index and remaining number of line segments to form can describe any intermediate state. To make the computation of each state in constant time, we could add another flag to the state that indicates whether or not we are in the middle of placing a line (placed start poin... | Math,Dynamic Programming | Medium | null |
43 | Loot Exams will see the program of multiplication of two strings. It is from the list. The program of multiplication of two strings is simple in pattern. To understand this, there are some things in which we have to understand that when we do this multiplication, we will not use these teacher functions. This is not for... | Multiply Strings | multiply-strings | Given two non-negative integers `num1` and `num2` represented as strings, return the product of `num1` and `num2`, also represented as a string.
**Note:** You must not use any built-in BigInteger library or convert the inputs to integer directly.
**Example 1:**
**Input:** num1 = "2", num2 = "3"
**Output:** "6"
**Ex... | null | Math,String,Simulation | Medium | 2,66,67,415 |
1,027 | today we will be solving lead code 1027 that is longest arithmetic subsequence so in this question we are given with an array Norms of integers and we have to return the length of longest arithmetic subsequence in nums or given array and we all know that arithmetic subsequence is nothing but a series of integer where t... | 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 |
449 | Hello Hi Everyone Welcome To My Channel It's All The Problems Realized And Civilized GST Socializing Converted Alphabets Object Into A Sequence Of Which Sadhak Can Be Stored In File Or Memory And Transmitted Across Network Connection Link To Be Constructed In The Same And Other Computer Environment Designer Loot Civili... | Serialize and Deserialize BST | serialize-and-deserialize-bst | Serialization is converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment.
Design an algorithm to serialize and deserialize a **binary search t... | null | String,Tree,Depth-First Search,Breadth-First Search,Design,Binary Search Tree,Binary Tree | Medium | 297,652,765 |
35 | Hello hello viewers welcome back to tech news hindi video bhi seedha 100 china short position problem wishes from list to date end of june challenge so let's not look at the problem statement the problem remaining life middle aged person ten writers others the video then subscribe to the Video then subscribe to the Sub... | Search Insert Position | search-insert-position | Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
You must write an algorithm with `O(log n)` runtime complexity.
**Example 1:**
**Input:** nums = \[1,3,5,6\], target = 5
**Output:** 2
**Exa... | null | Array,Binary Search | Easy | 278 |
472 | um hello so today we are going to do this problem which is part of lead code January daily challenge so we get an array of strings words that don't have duplicates this is important and we want to return all the concatenated words in the list of words now what do they mean by concatenated words they mean that um if it'... | 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 |
598 | hey everyone welcome back and today we will be doing another lead code 598 range Edition 2 an easy one you are given an MX and Matrix M initialized with all 0 and array of operation oops where oops at I is equal to you can say a limit or a range we are provided so means M at X and Y should be incremented according to t... | Range Addition II | range-addition-ii | You are given an `m x n` matrix `M` initialized with all `0`'s and an array of operations `ops`, where `ops[i] = [ai, bi]` means `M[x][y]` should be incremented by one for all `0 <= x < ai` and `0 <= y < bi`.
Count and return _the number of maximum integers in the matrix after performing all the operations_.
**Exampl... | null | Array,Math | Easy | 370 |
1,255 | hello friends so today we're gonna discuss another problem from lead code which is a hard problem on bit manipulation the problem name is maximum score words form by letters it states that you are given a word list and some letters add the score of each letter so in simple terms you are given some letters or actually w... | Maximum Score Words Formed by Letters | reverse-subarray-to-maximize-array-value | Given a list of `words`, list of single `letters` (might be repeating) and `score` of every character.
Return the maximum score of **any** valid set of words formed by using the given letters (`words[i]` cannot be used two or more times).
It is not necessary to use all characters in `letters` and each letter can only... | What's the score after reversing a sub-array [L, R] ? It's the score without reversing it + abs(a[R] - a[L-1]) + abs(a[L] - a[R+1]) - abs(a[L] - a[L-1]) - abs(a[R] - a[R+1]) How to maximize that formula given that abs(x - y) = max(x - y, y - x) ? This can be written as max(max(a[R] - a[L - 1], a[L - 1] - a[R]) + max(a[... | Array,Math,Greedy | Hard | null |
59 | hello everyone welcome to date headings of april youtube challenge and i hope all of you are having a great time my name is sanchez i'm working a software developer for at adobe and today i present day 656 of daily lead code challenge the question that we have in today's spiral matrix here in this question we are given... | Spiral Matrix II | spiral-matrix-ii | Given a positive integer `n`, generate an `n x n` `matrix` filled with elements from `1` to `n2` in spiral order.
**Example 1:**
**Input:** n = 3
**Output:** \[\[1,2,3\],\[8,9,4\],\[7,6,5\]\]
**Example 2:**
**Input:** n = 1
**Output:** \[\[1\]\]
**Constraints:**
* `1 <= n <= 20` | null | Array,Matrix,Simulation | Medium | 54,921 |
1,066 | hello and welcome to another video in this video we're going to be working on campus spikes 2 and in the problem you have a campus that's a 2d grid and there are n workers and m bikes with n less than or equal to M each worker and a bike is a 2d coordinate on a grid like this we assign one unique bike to each worker su... | Campus Bikes II | fixed-point | On a campus represented as a 2D grid, there are `n` workers and `m` bikes, with `n <= m`. Each worker and bike is a 2D coordinate on this grid.
We assign one unique bike to each worker so that the sum of the **Manhattan distances** between each worker and their assigned bike is minimized.
Return `the minimum possible... | Loop over the array and check the first index i such A[i] == i | Array,Binary Search | Easy | null |
1,680 | hi everyone welcome to my YouTube channel and in this video we will look at problem 1680 from the code so the subject the title of this problem is concatenational consecutive binary numbers and the person you see on the left hand side is live needs I don't know his first name he was the German mathematicians and maybe ... | Concatenation of Consecutive Binary Numbers | count-all-possible-routes | Given an integer `n`, return _the **decimal value** of the binary string formed by concatenating the binary representations of_ `1` _to_ `n` _in order, **modulo**_ `109 + 7`.
**Example 1:**
**Input:** n = 1
**Output:** 1
**Explanation: ** "1 " in binary corresponds to the decimal value 1.
**Example 2:**
**Input:**... | Use dynamic programming to solve this problem with each state defined by the city index and fuel left. Since the array contains distinct integers fuel will always be spent in each move and so there can be no cycles. | Array,Dynamic Programming,Memoization | Hard | null |
1,743 | hi everyone it's albert today let's solve the contest median question restore the array from adjacent pairs and before we start don't forget to subscribe to my channel i'll be constantly solving good and classic clinical questions with clear explanation animation and visualization now let's look at a question for this ... | 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 |
212 | welcome back to algojs today's question is leak code 212 word search two so given an n by m board of characters in a list of string words return all words on the board so each word must be constructed from letters of sequentially adjacent cells where adjacent cells are horizontally and vertically neighboring the same l... | 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 |
3 | So today we will see Longest substring without repeating characters is a good problem and they have two output D. If there is longest substring without repeating characters then it has ABC. Longest ABC is right. If ABCA is not there because there is repeating character then the answer is it has all one. So there is one... | 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 |
153 | we are going to solve find minimum and rotated sorted array today this is the medium kind of problem let's look for our problem statement we are given an array of length n which was initially sorted in ascending order then it's got rotated now we have this rotated array with us so what the rotation means if initially w... | Find Minimum in Rotated Sorted Array | find-minimum-in-rotated-sorted-array | Suppose an array of length `n` sorted in ascending order is **rotated** between `1` and `n` times. For example, the array `nums = [0,1,2,4,5,6,7]` might become:
* `[4,5,6,7,0,1,2]` if it was rotated `4` times.
* `[0,1,2,4,5,6,7]` if it was rotated `7` times.
Notice that **rotating** an array `[a[0], a[1], a[2], .... | Array was originally in ascending order. Now that the array is rotated, there would be a point in the array where there is a small deflection from the increasing sequence. eg. The array would be something like [4, 5, 6, 7, 0, 1, 2]. You can divide the search space into two and see which direction to go.
Can you think ... | Array,Binary Search | Medium | 33,154 |
648 | hey how'd our today I'm looking at the questions 648 to replace words so the question is as follows in English we have a concept I call the root which can be followed by some other words so the root is a word the root word can be followed by some other words to form another longer word that's called this word successor... | Replace Words | replace-words | In English, we have a concept called **root**, which can be followed by some other word to form another longer word - let's call this word **successor**. For example, when the **root** `"an "` is followed by the **successor** word `"other "`, we can form a new word `"another "`.
Given a `dictionary` consisting of many... | null | Array,Hash Table,String,Trie | Medium | 208 |
376 | hey guys welcome or welcome back to my channel so today we are going to discuss another problem is wiggle subsequence so a wiggle sequence is a sequence where the difference between successive numbers strictly alternate between positive and negative okay meaning the difference between uh alternate numbers should be alt... | Wiggle Subsequence | wiggle-subsequence | A **wiggle sequence** is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with one element and a sequence with two non-equal elements are trivially wiggle sequences.
* For ... | null | Array,Dynamic Programming,Greedy | Medium | 2271 |
305 | hey guys what's up today the question we're gonna say is 305 the number of islands two right it's basically the question derivative from the question two hundred likes uh the number of islands one if you guys haven't finished that can just try that first and they said that it gives us you know the two degrees uh both y... | Number of Islands II | number-of-islands-ii | You are given an empty 2D binary grid `grid` of size `m x n`. The grid represents a map where `0`'s represent water and `1`'s represent land. Initially, all the cells of `grid` are water cells (i.e., all the cells are `0`'s).
We may perform an add land operation which turns the water at position into a land. You are g... | null | Array,Union Find | Hard | 200,2198 |
926 | Hello hello everyone welcome dandruff exactly edison electronic in this question on thursday a due to increase in subscribe oil olive oil ko hai to electronics and example possible se 0110 neurotic last 2 and will update were 2002 c the tarzan the car ki stock board heart Alert Cases Can Sleep With Long Due To Make It ... | Flip String to Monotone Increasing | find-and-replace-pattern | A binary string is monotone increasing if it consists of some number of `0`'s (possibly none), followed by some number of `1`'s (also possibly none).
You are given a binary string `s`. You can flip `s[i]` changing it from `0` to `1` or from `1` to `0`.
Return _the minimum number of flips to make_ `s` _monotone increa... | null | Array,Hash Table,String | Medium | null |
1,171 | so guys let's proceed to the question number 1171 remove zero some consecutive notes from link list so basically in this we have to remove the uh zero sums that is for example in this array 1 + 2 = 3 and minus 3 this array 1 + 2 = 3 and minus 3 this array 1 + 2 = 3 and minus 3 is also zero so we will remove Min -3 is a... | Remove Zero Sum Consecutive Nodes from Linked List | shortest-path-in-binary-matrix | Given the `head` of a linked list, we repeatedly delete consecutive sequences of nodes that sum to `0` until there are no such sequences.
After doing so, return the head of the final linked list. You may return any such answer.
(Note that in the examples below, all sequences are serializations of `ListNode` objects.)... | Do a breadth first search to find the shortest path. | Array,Breadth-First Search,Matrix | Medium | null |
71 | hello and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem number 71 simplify path let's read the problem description given a string path which is an absolute path starting with a slash to a file directory in a unix-style file to a file directory in a unix-style file t... | 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,876 | hello today we will be doing the problem number 1876 that is substring of size three with distinct characters so like to dislike youtube so we'll be doing it today the problem statement here is a string is good if there are no repeated characters given a string s return the number of good substrings of length 3 in s no... | Substrings of Size Three with Distinct Characters | map-of-highest-peak | A string is **good** if there are no repeated characters.
Given a string `s`, return _the number of **good substrings** of length **three** in_ `s`.
Note that if there are multiple occurrences of the same substring, every occurrence should be counted.
A **substring** is a contiguous sequence of characters... | Set each water cell to be 0. The height of each cell is limited by its closest water cell. Perform a multi-source BFS with all the water cells as sources. | Array,Breadth-First Search,Matrix | Medium | null |
93 | Hello friends today I'm going to solve with problem number 93 restore IP addresses so in this problem we need to construct a valid IP address from a given string s so what's a valid IP address uh it consists of four integers which are separated by single dots and each integer can be between 0 to 255 inclusive and canno... | 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 |
130 | hello friends today let's of the surrounding regions probably given a 2d bode contain the X and O the letter or capture all regions surrounded by X a region is captured by sleeping on earth into X in that surrounded region less is this example we sleep these Rios but we do not sleep this or why because the surrounding ... | Surrounded Regions | surrounded-regions | Given an `m x n` matrix `board` containing `'X'` and `'O'`, _capture all regions that are 4-directionally surrounded by_ `'X'`.
A region is **captured** by flipping all `'O'`s into `'X'`s in that surrounded region.
**Example 1:**
**Input:** board = \[\[ "X ", "X ", "X ", "X "\],\[ "X ", "O ", "O ", "X "\],\[ "X ", "... | null | Array,Depth-First Search,Breadth-First Search,Union Find,Matrix | Medium | 200,286 |
322 | hi everyone I'm Dr surjit Singh today we'll talk about the lead code problem coin change let us begin we are given a list of coin denominations and a Target amount we are to find the fewest number of coins that will make up the amount bottom up solution of the problem is iterative we are given a list of coin denominati... | Coin Change | coin-change | You are given an integer array `coins` representing coins of different denominations and an integer `amount` representing a total amount of money.
Return _the fewest number of coins that you need to make up that amount_. If that amount of money cannot be made up by any combination of the coins, return `-1`.
You may a... | null | Array,Dynamic Programming,Breadth-First Search | Medium | 1025,1393,2345 |
371 | hi there so today I'm looking at a little bit manipulation question which is 371 sum of two integers we need to calculate the sum of two integers a and B but we are not allowed to use the addition and the subtraction operator so we have to look into the binary representations for those integers and see what's actually ... | Sum of Two Integers | sum-of-two-integers | Given two integers `a` and `b`, return _the sum of the two integers without using the operators_ `+` _and_ `-`.
**Example 1:**
**Input:** a = 1, b = 2
**Output:** 3
**Example 2:**
**Input:** a = 2, b = 3
**Output:** 5
**Constraints:**
* `-1000 <= a, b <= 1000` | null | Math,Bit Manipulation | Medium | 2 |
344 | hey everyone welcome back to my channel before we get started don't forget to click the Subscribe button if you want more videos about coding interviews so in this video we'll be solving the problem lead called reverse string so let's get started the problem is that they give us a string as an array of characters and t... | Reverse String | reverse-string | Write a function that reverses a string. The input string is given as an array of characters `s`.
You must do this by modifying the input array [in-place](https://en.wikipedia.org/wiki/In-place_algorithm) with `O(1)` extra memory.
**Example 1:**
**Input:** s = \["h","e","l","l","o"\]
**Output:** \["o","l","l","e","h... | The entire logic for reversing a string is based on using the opposite directional two-pointer approach! | Two Pointers,String,Recursion | Easy | 345,541 |
1,952 | all right so this question is three divisors so you are given the integer n so return true if n has exactly three positive divisor and I'll just write return false so a divisor is actually like you I mean you can assume an equal to K times n and K is integer and it's also integer and then m is actually the floating num... | Three Divisors | minimum-sideway-jumps | Given an integer `n`, return `true` _if_ `n` _has **exactly three positive divisors**. Otherwise, return_ `false`.
An integer `m` is a **divisor** of `n` if there exists an integer `k` such that `n = k * m`.
**Example 1:**
**Input:** n = 2
**Output:** false
**Explantion:** 2 has only two divisors: 1 and 2.
**Exampl... | At a given point, there are only 3 possible states for where the frog can be. Check all the ways to move from one point to the next and update the minimum side jumps for each lane. | Array,Dynamic Programming,Greedy | Medium | 403 |
459 | Ko Hi I am Aayushi Rawal and welcome to my channel today will gather September light to turn on this death problem repeated sub skin problem give this can be constructed by taking subscribe and multiple co subscribe till take English letters in chief output bullion true that your will see Multiple approach to this prob... | Repeated Substring Pattern | repeated-substring-pattern | Given a string `s`, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.
**Example 1:**
**Input:** s = "abab "
**Output:** true
**Explanation:** It is the substring "ab " twice.
**Example 2:**
**Input:** s = "aba "
**Output:** false
**Example 3:**
... | null | String,String Matching | Easy | 28,686 |
928 | okay let's do this question this questions give me a hard time so you're given a network of nodes represented by this adjacency matrix so one if the nodes are connected and a zero if the nodes are not connected and those are corresponding to the index within this matrix and you're also given this vector of initial node... | Minimize Malware Spread II | surface-area-of-3d-shapes | You are given a network of `n` nodes represented as an `n x n` adjacency matrix `graph`, where the `ith` node is directly connected to the `jth` node if `graph[i][j] == 1`.
Some nodes `initial` are initially infected by malware. Whenever two nodes are directly connected, and at least one of those two nodes is infected... | null | Array,Math,Geometry,Matrix | Easy | null |
1,732 | guys uh so welcome to my legal serving section the easy part so 1 7 32 find the highest attitude uh sorry finding the audit sorry not 82 sorry so uh there is a bike going a road trip and the pro uh triple count has m plus one points at different uh altitude uh the bike the biker is starting his stop on po zero the rd i... | Find the Highest Altitude | minimum-one-bit-operations-to-make-integers-zero | There is a biker going on a road trip. The road trip consists of `n + 1` points at different altitudes. The biker starts his trip on point `0` with altitude equal `0`.
You are given an integer array `gain` of length `n` where `gain[i]` is the **net gain in altitude** between points `i` and `i + 1` for all (`0 <=... | The fastest way to convert n to zero is to remove all set bits starting from the leftmost one. Try some simple examples to learn the rule of how many steps are needed to remove one set bit. consider n=2^k case first, then solve for all n. | Dynamic Programming,Bit Manipulation,Memoization | Hard | 2119 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.