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
4
hello everybody it's uh Ryan power share your favorite programmer and we're gonna do today a leak code number for median of two short arrays pardon my speech at the moment I went to the dentist today got some work done but we're gonna power through we're gonna put this video out anyway so the problem we're doing today ...
Median of Two Sorted Arrays
median-of-two-sorted-arrays
Given two sorted arrays `nums1` and `nums2` of size `m` and `n` respectively, return **the median** of the two sorted arrays. The overall run time complexity should be `O(log (m+n))`. **Example 1:** **Input:** nums1 = \[1,3\], nums2 = \[2\] **Output:** 2.00000 **Explanation:** merged array = \[1,2,3\] and median is ...
null
Array,Binary Search,Divide and Conquer
Hard
null
525
hello and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem 525 contiguous array given a binary array nums return the maximum length of a continuous subarray with an equal number of zeros and ones so for example if we're given this nums here zero and one what are the tw...
Contiguous Array
contiguous-array
Given a binary array `nums`, return _the maximum length of a contiguous subarray with an equal number of_ `0` _and_ `1`. **Example 1:** **Input:** nums = \[0,1\] **Output:** 2 **Explanation:** \[0, 1\] is the longest contiguous subarray with an equal number of 0 and 1. **Example 2:** **Input:** nums = \[0,1,0\] **O...
null
Array,Hash Table,Prefix Sum
Medium
325
400
hey everybody this is Larry this is me trying to do an extra uh haven't extra prom that haven't done before an hour ago so let's get to it RNG let's go uh and today's PR today's lar extra prom is 4 digit given an integer n return M digit of the infinity sequence what is this one two huh oh I see it I was okay so basica...
Nth Digit
nth-digit
Given an integer `n`, return the `nth` digit of the infinite integer sequence `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...]`. **Example 1:** **Input:** n = 3 **Output:** 3 **Example 2:** **Input:** n = 11 **Output:** 0 **Explanation:** The 11th digit of the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... is a 0, which ...
null
Math,Binary Search
Medium
null
899
hello everyone and welcome back to another video so today we're going to be solving the lead code question orderly q all right so in this question we're going to be given a string s and an integer k so we can choose one of the first k letters of s and append it to the end of the string now the goal here is to return th...
Orderly Queue
binary-gap
You are given a string `s` and an integer `k`. You can choose one of the first `k` letters of `s` and append it at the end of the string.. Return _the lexicographically smallest string you could have after applying the mentioned step any number of moves_. **Example 1:** **Input:** s = "cba ", k = 1 **Output:** "ac...
null
Math,Bit Manipulation
Easy
null
1,706
How are you all, today we are going to talk about question number 1706, where will D ball fall, so in this, you have been given a great gift of Ambrose and size and now you will understand better what to do in this. What you have to do is see in this, you are given N balls here and you will drop them from here. Now wha...
Where Will the Ball Fall
min-cost-to-connect-all-points
You have a 2-D `grid` of size `m x n` representing a box, and you have `n` balls. The box is open on the top and bottom sides. Each cell in the box has a diagonal board spanning two corners of the cell that can redirect a ball to the right or to the left. * A board that redirects the ball to the right spans the top...
Connect each pair of points with a weighted edge, the weight being the manhattan distance between those points. The problem is now the cost of minimum spanning tree in graph with above edges.
Array,Union Find,Minimum Spanning Tree
Medium
2287
83
hey guys in this video i'll be showing you how to solve lead code question 83 remove duplicates from sorted list um so for this question we're given a sorted linked list and it's going to be singly linked and we're just asked to delete any duplicate elements um and so since this list is sorted um kind of the approach w...
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
347
347 top k frequent elements given an integer array nums and an integer k return the k most frequent elements you may return the answer in any order example one we have an array one two three and case two so we need to get the two most frequent elements we see that one appeared three times to appear two times so one and...
Top K Frequent Elements
top-k-frequent-elements
Given an integer array `nums` and an integer `k`, return _the_ `k` _most frequent elements_. You may return the answer in **any order**. **Example 1:** **Input:** nums = \[1,1,1,2,2,3\], k = 2 **Output:** \[1,2\] **Example 2:** **Input:** nums = \[1\], k = 1 **Output:** \[1\] **Constraints:** * `1 <= nums.lengt...
null
Array,Hash Table,Divide and Conquer,Sorting,Heap (Priority Queue),Bucket Sort,Counting,Quickselect
Medium
192,215,451,659,692,1014,1919
6
hello and welcome to the sixth video in this leak code in c-sharp series in this leak code in c-sharp series in this leak code in c-sharp series in this video we are going to be doing the challenge called zigzag conversion so let's go over to lead code and let's start this challenge so if we load in and let's see what ...
Zigzag Conversion
zigzag-conversion
The string `"PAYPALISHIRING "` is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: `"PAHNAPLSIIGYIR "` Write the code that will take a string and make this co...
null
String
Medium
null
374
hey everyone it's me abdullah welcome back i do lead code and stuff you can check out other my liquid lead code problems and videos and you if you have any kind of questions you can ask them in the comments or just on my instagram of gulation956 so anyways we'll be doing another lead code today three seven four cash nu...
Guess Number Higher or Lower
guess-number-higher-or-lower
We are playing the Guess Game. The game is as follows: I pick a number from `1` to `n`. You have to guess which number I picked. Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess. You call a pre-defined API `int guess(int num)`, which returns three possible re...
null
Binary Search,Interactive
Easy
278,375,658
795
all right guys welcome to our channel code with sunny and in this video i will be again talking about lead code problem the medium type problem number of sub arrays with bounded maximum you can see okay and its index is 795 and it is categorized at the medium type problem of the lead code right so before moving further...
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
168
hello everyone so today we are going to solve problem number 168 Excel sheet column title or lead code so what this problem States is quite simple given an integral column number return its corresponding column title as it appears in an Excel sheet so we need to first see that how the column numbers are mapped in an Ex...
Excel Sheet Column Title
excel-sheet-column-title
Given an integer `columnNumber`, return _its corresponding column title as it appears in an Excel sheet_. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... **Example 1:** **Input:** columnNumber = 1 **Output:** "A " **Example 2:** **Input:** columnNumber = 28 **Output:** "AB " **Example 3:**...
null
Math,String
Easy
171,2304
1,480
hello friends in this video we are going to see how to find the running sum of an array so it's a one-dimensional of an array so it's a one-dimensional of an array so it's a one-dimensional array so it should be very simple so let's say we have an array one two three four 5 so how do we find the running sum so running ...
Running Sum of 1d Array
movie-rating
Given an array `nums`. We define a running sum of an array as `runningSum[i] = sum(nums[0]...nums[i])`. Return the running sum of `nums`. **Example 1:** **Input:** nums = \[1,2,3,4\] **Output:** \[1,3,6,10\] **Explanation:** Running sum is obtained as follows: \[1, 1+2, 1+2+3, 1+2+3+4\]. **Example 2:** **Input:** ...
null
Database
Medium
null
148
hey what's up guys how's it going this video i'm going to go through this later 148 short list this problem was asked by amazon microsoft bloomberg apple and facebook in past six months as you can see this is not the most popular question of nico but i think it's pretty educational let's take a look at it uh we are giv...
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
347
what is going on everybody it's your boy average leader here with another video today we're tackling top k frequent elements number 347 on leak code this question is commonly asked by facebook capital one amazon bloomberg oracle apple and a few other companies here um i actually got this question from my bloomberg phon...
Top K Frequent Elements
top-k-frequent-elements
Given an integer array `nums` and an integer `k`, return _the_ `k` _most frequent elements_. You may return the answer in **any order**. **Example 1:** **Input:** nums = \[1,1,1,2,2,3\], k = 2 **Output:** \[1,2\] **Example 2:** **Input:** nums = \[1\], k = 1 **Output:** \[1\] **Constraints:** * `1 <= nums.lengt...
null
Array,Hash Table,Divide and Conquer,Sorting,Heap (Priority Queue),Bucket Sort,Counting,Quickselect
Medium
192,215,451,659,692,1014,1919
1,782
hey everybody this is larry this is me going over by weekly contest 47 q4 count pairs of notes so this one is a weird hard problem uh that a handful of people got at least you know an hour in and it is a way optimization problem i don't know and you know to be honest i'm not confident that my solution is the intended s...
Count Pairs Of Nodes
smallest-string-with-a-given-numeric-value
You are given an undirected graph defined by an integer `n`, the number of nodes, and a 2D integer array `edges`, the edges in the graph, where `edges[i] = [ui, vi]` indicates that there is an **undirected** edge between `ui` and `vi`. You are also given an integer array `queries`. Let `incident(a, b)` be defined as t...
Think greedily. If you build the string from the end to the beginning, it will always be optimal to put the highest possible character at the current index.
String,Greedy
Medium
null
1,716
hello and welcome back today we have 1716 calculate money in leod bank in this problem we have a user hery who wants to save money for his first car he puts money in the leod bank every day the first Monday he puts in $1 and every the first Monday he puts in $1 and every the first Monday he puts in $1 and every day onw...
Calculate Money in Leetcode Bank
maximum-non-negative-product-in-a-matrix
Hercy wants to save money for his first car. He puts money in the Leetcode bank **every day**. He starts by putting in `$1` on Monday, the first day. Every day from Tuesday to Sunday, he will put in `$1` more than the day before. On every subsequent Monday, he will put in `$1` more than the **previous Monday**. Given...
Use Dynamic programming. Keep the highest value and lowest value you can achieve up to a point.
Array,Dynamic Programming,Matrix
Medium
null
1,002
yeahyeah Hi Hi Hi everyone, I'm a programmer. Today I'm going to introduce to you a problem titled finding common characters. The detailed problem is as follows, give us an answer. table A is a piece of broom hit by this cursing net has only unknown characters Hoa Return list a list of all characters that appear in all...
Find Common Characters
maximum-width-ramp
Given a string array `words`, return _an array of all characters that show up in all strings within the_ `words` _(including duplicates)_. You may return the answer in **any order**. **Example 1:** **Input:** words = \["bella","label","roller"\] **Output:** \["e","l","l"\] **Example 2:** **Input:** words = \["cool"...
null
Array,Stack,Monotonic Stack
Medium
null
948
Jhaal Hello Hi Guys Welcome To Cash Today's Question Is Back Options In This Question Behavior Lifestyle Power Of P N Initial 480 And Certificates Were Taken A Representative And Job Is To Come Forward To Maximize The Total Score Back Water Ship Will Take This Token In Any Update On 20th the river front is that is on c...
Bag of Tokens
sort-an-array
You have an initial **power** of `power`, an initial **score** of `0`, and a bag of `tokens` where `tokens[i]` is the value of the `ith` token (0-indexed). Your goal is to maximize your total **score** by potentially playing each token in one of two ways: * If your current **power** is at least `tokens[i]`, you may...
null
Array,Divide and Conquer,Sorting,Heap (Priority Queue),Merge Sort,Bucket Sort,Radix Sort,Counting Sort
Medium
null
221
Loot Hello Bhaiya Yeh Bolo Phir Hum A Great Time Friends Welcome To Cases Channel Subscribe to the Page if you liked The Video then subscribe to subscribe our Ki Remedy Stick Pan Shark Slide Show Aur Sudhir Very Famous Interview Problem That Request You Kindly Go Through The Good Deeds Not To Withdraw Maximum Kar Do Pl...
Maximal Square
maximal-square
Given an `m x n` binary `matrix` filled with `0`'s and `1`'s, _find the largest square containing only_ `1`'s _and return its area_. **Example 1:** **Input:** matrix = \[\[ "1 ", "0 ", "1 ", "0 ", "0 "\],\[ "1 ", "0 ", "1 ", "1 ", "1 "\],\[ "1 ", "1 ", "1 ", "1 ", "1 "\],\[ "1 ", "0 ", "0 ", "1 ", "0 "\]\] **Output:*...
null
Array,Dynamic Programming,Matrix
Medium
85,769,1312,2200
134
lead codee problem number 134 gas station so this problem gives us a end gas stations along a circular route where the amount of gas at each station is inside of the gas up so over here for example in this index there will be one gas two gas three gas and so on so we have a car with an unlimited gas tank this means tha...
Gas Station
gas-station
There are `n` gas stations along a circular route, where the amount of gas at the `ith` station is `gas[i]`. You have a car with an unlimited gas tank and it costs `cost[i]` of gas to travel from the `ith` station to its next `(i + 1)th` station. You begin the journey with an empty tank at one of the gas stations. Gi...
null
Array,Greedy
Medium
1346
1,261
hey everyone today i'll be talking about leeco 1261 fine elements in a contaminated binary tree so we're given some tree it has all negative ones so it's been contaminated apparently and to recover it to make it not contaminated anymore we have this rule set so the root's value is zero and then for any given nodes valu...
Find Elements in a Contaminated Binary Tree
swap-for-longest-repeated-character-substring
Given a binary tree with the following rules: 1. `root.val == 0` 2. If `treeNode.val == x` and `treeNode.left != null`, then `treeNode.left.val == 2 * x + 1` 3. If `treeNode.val == x` and `treeNode.right != null`, then `treeNode.right.val == 2 * x + 2` Now the binary tree is contaminated, which means all `treeNode...
There are two cases: a block of characters, or two blocks of characters between one different character. By keeping a run-length encoded version of the string, we can easily check these cases.
String,Sliding Window
Medium
null
1,689
the code challenge one six eight nine let's go here's the site problems page and we are looking for one six eight nine i can just scroll down to it you can see it's medium difficulty five eight nine lights four three eight people struggling select your language i'm going to go with javascript and let's have a look at t...
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
764
alright guys welcome to our channel code with sunny and in this video i will be talking about the problem you can see largest plus sign its index is 764 and it is the medium type problem the leak code okay so to be honest i really like this problem and the reason behind this is if you look over the constraints i was tr...
Largest Plus Sign
n-ary-tree-level-order-traversal
You are given an integer `n`. You have an `n x n` binary grid `grid` with all values initially `1`'s except for some indices given in the array `mines`. The `ith` element of the array `mines` is defined as `mines[i] = [xi, yi]` where `grid[xi][yi] == 0`. Return _the order of the largest **axis-aligned** plus sign of_ ...
null
Tree,Breadth-First Search
Medium
102,775,776,2151
43
hey what's up guys think white here I do tech encoding stuff on twitch and YouTube check the description for all my information I do all the leak out solutions got a playlist do the premium ons on my patreon and yeah I have a discord as well if you want to join that but this is a problem called buddy strings it is defi...
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
158
hey guys they want you try to solve the redone characters give away the four to call multiple times actually I have explained this problem and the related trouble with the white bowl but I think you maybe I should call the life maybe data will help you understand this problem well okay let's see the problem give it a 5...
Read N Characters Given read4 II - Call Multiple Times
read-n-characters-given-read4-ii-call-multiple-times
Given a `file` and assume that you can only read the file using a given method `read4`, implement a method `read` to read `n` characters. Your method `read` may be **called multiple times**. **Method read4:** The API `read4` reads **four consecutive characters** from `file`, then writes those characters into the buff...
null
String,Simulation,Interactive
Hard
157
1,967
hey everyone welcome back to the channel so in today's video we will be solving it for 1967 which is number of strings that appear as a substring inward so in this problem we are given a array of strings patterns and the string what uh we need to return the number of strings in patterns that exist as the substring inwa...
Number of Strings That Appear as Substrings in Word
longest-substring-of-all-vowels-in-order
Given an array of strings `patterns` and a string `word`, return _the **number** of strings in_ `patterns` _that exist as a **substring** in_ `word`. A **substring** is a contiguous sequence of characters within a string. **Example 1:** **Input:** patterns = \[ "a ", "abc ", "bc ", "d "\], word = "abc " **Output:**...
Start from each 'a' and find the longest beautiful substring starting at that index. Based on the current character decide if you should include the next character in the beautiful substring.
String,Sliding Window
Medium
2186
1,047
Hello hello viewers welcome to my channel it's all the record problem remove all odds and click ads in spring so basically in this problem given in this strange facts and need to remove the duplicate latest correspondingly cases were getting this letter in alwar district former they are not Able To Delete Favorite More...
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,601
hey what's up guys this is john here so today uh let's take a look at uh this week's weekly contest uh problem 1601 maximum number of achievable transfer requests this is the last problem of this week's uh weekly contest i mean the other three problems i are not that good i know especially for the third one you know th...
Maximum Number of Achievable Transfer Requests
maximum-number-of-achievable-transfer-requests
We have `n` buildings numbered from `0` to `n - 1`. Each building has a number of employees. It's transfer season, and some employees want to change the building they reside in. You are given an array `requests` where `requests[i] = [fromi, toi]` represents an employee's request to transfer from building `fromi` to bu...
null
null
Hard
null
139
hello everyone welcome again to my channel and rickerson with dp memo video so here we will solve another problem that is 139 word break and it is quite a famous problem and it has another problem called word break too so here for this word break problem we will use recursion with dp memorized technique which we solved...
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
445
hello and welcome to another Elite code video today we're going to be doing the problem of the day for July 17th add two numbers too it's a good link list problem helps you know use linked lists also you have to know how adding actually works like in normal Edition which is kind of important okay so you're given two no...
Add Two Numbers II
add-two-numbers-ii
You are given two **non-empty** linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itsel...
null
Linked List,Math,Stack
Medium
2,1774
218
Hello and welcome. I'm James Murphy. In this video,&nbsp;we're tackling a hard interview question: The Infamous Skyline Problem. I'll explain my C++&nbsp;solution which beat 98.24% of other submissions in speed and 100% in memory. In case you've never&nbsp;looked at a beautiful city view and thought: I wonder what math...
The Skyline Problem
the-skyline-problem
A city's **skyline** is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and heights of all the buildings, return _the **skyline** formed by these buildings collectively_. The geometric information of each building is given in the array `buil...
null
Array,Divide and Conquer,Binary Indexed Tree,Segment Tree,Line Sweep,Heap (Priority Queue),Ordered Set
Hard
699
706
That they got a big ODI series according to Dibbs Half Birthday Bhi Challenge Photo Only Boys School Design Hai Swakshetri Designer Shuaib Stabilizers Deceased Person Just Different Functions Day The Just Want To Give A New Meaning To The Lord To Remove Subscribe Now To Receive New Updates Reviews &amp; News Angry Bird...
Design HashMap
design-hashmap
Design a HashMap without using any built-in hash table libraries. Implement the `MyHashMap` class: * `MyHashMap()` initializes the object with an empty map. * `void put(int key, int value)` inserts a `(key, value)` pair into the HashMap. If the `key` already exists in the map, update the corresponding `value`. * ...
null
null
Easy
null
68
today we're gonna be working on lead code question number 68 text justification so we have been given an array of strings words and a width max width format the text such that each line has exactly max with character and is fully justified left and right you should back your words in a greedy approach that is pack as m...
Text Justification
text-justification
Given an array of strings `words` and a width `maxWidth`, format the text such that each line has exactly `maxWidth` characters and is fully (left and right) justified. You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces `' '` when necessary so that ea...
null
Array,String,Simulation
Hard
1714,2260
287
hello everyone in this video we will solve the question uh 287 in the lead code that is find the duplicate number so in this it is a medium level question so here we are given an array numbers containing n plus one integers where each integer is between 1 to n inclusive that means we are given spaces of 1 to n plus 1 a...
Find the Duplicate Number
find-the-duplicate-number
Given an array of integers `nums` containing `n + 1` integers where each integer is in the range `[1, n]` inclusive. There is only **one repeated number** in `nums`, return _this repeated number_. You must solve the problem **without** modifying the array `nums` and uses only constant extra space. **Example 1:** **...
null
Array,Two Pointers,Binary Search,Bit Manipulation
Medium
41,136,142,268,645
474
hello everyone welcome to my channel code with sunny and today i am going to discuss the problem once and 0's index number is 474 and the problem is of medium type of lead code okay so let's discuss the problem now we have been given an array of binary strings and the two integers m and n and we have to return the size...
Ones and Zeroes
ones-and-zeroes
You are given an array of binary strings `strs` and two integers `m` and `n`. Return _the size of the largest subset of `strs` such that there are **at most**_ `m` `0`_'s and_ `n` `1`_'s in the subset_. A set `x` is a **subset** of a set `y` if all elements of `x` are also elements of `y`. **Example 1:** **Input:**...
null
Array,String,Dynamic Programming
Medium
510,600,2261
6
hello all welcome to another video solution by code runner in this video we will be looking at the zigzag conversion problem on lead code and this video will provide you with the c plus solution of this problem i have also made a video for the python solution of this problem and if you are more comfortable with python ...
Zigzag Conversion
zigzag-conversion
The string `"PAYPALISHIRING "` is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: `"PAHNAPLSIIGYIR "` Write the code that will take a string and make this co...
null
String
Medium
null
54
another day another problem so let's Solve IT hello guys I hope you are all doing well in this video we're gonna solve the spiral Matrix problem before we get started hit that subscribe button if you haven't already and without further adoles so let's get started imagine that you have a matrix a grid of numbers and the...
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
139
welcome to this video in this video we will solve this coding interview problem word break in this problem you are given word of dictionary and a string you have to check whether you can construct the string from the word of dictionary we can use one word multiple times to construct the string in this string we see we ...
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
232
Hello everyone welcome to my channel Okay let's see first let's see further asked the company why to implement Microsoft Amazon Google okay why to implement using stack okay let's see as if I take it if pushed then I take it Why is the behavior like this, if you push the van, then the van comes here, then if you push, ...
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
48
hi everyone today we are going to sort of three to go to the question rotate image so you are given a m by m2d matrix and representing image rotate the image by 90 degrees clockwise so you have to rotate the image in place which means you have to modify the input 2D Matrix directly do not allocate another 2D Matrix and...
Rotate Image
rotate-image
You are given an `n x n` 2D `matrix` representing an image, rotate the image by **90** degrees (clockwise). You have to rotate the image [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm), which means you have to modify the input 2D matrix directly. **DO NOT** allocate another 2D matrix and do the rotati...
null
Array,Math,Matrix
Medium
2015
856
hello everyone welcome or welcome back to my channel so today we are going to discuss another problem but before going forward if you have not liked the video please like it subscribe to my channel and hit the bell icon so that you get notified whenever i post a new video so without any further ado let's get started pr...
Score of Parentheses
consecutive-numbers-sum
Given a balanced parentheses string `s`, return _the **score** of the string_. The **score** of a balanced parentheses string is based on the following rule: * `"() "` has score `1`. * `AB` has score `A + B`, where `A` and `B` are balanced parentheses strings. * `(A)` has score `2 * A`, where `A` is a balanced ...
null
Math,Enumeration
Hard
null
1,845
hey there welcome to pomodora Joe for Monday November 6th 2023 today we're looking at lead code problem 1845 seat reservation manager this is a medium problem design a system that manages the reservation state of N seats that are numbered from 1 to n implement the seat manager class and it has three different functions...
Seat Reservation Manager
largest-submatrix-with-rearrangements
Design a system that manages the reservation state of `n` seats that are numbered from `1` to `n`. Implement the `SeatManager` class: * `SeatManager(int n)` Initializes a `SeatManager` object that will manage `n` seats numbered from `1` to `n`. All seats are initially available. * `int reserve()` Fetches the **sm...
For each column, find the number of consecutive ones ending at each position. For each row, sort the cumulative ones in non-increasing order and "fit" the largest submatrix.
Array,Greedy,Sorting,Matrix
Medium
695
232
okay leeco 232 implement a queue using stacks so in this problem all we're going to be doing is we're going to be using two stacks in order to implement a first and first out data structure that's known as a q right so basically how a cue looks if you're not familiar with it is you have some data so let's say we have l...
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
342
um lead God question uh question lead code 342 power of four we just did the power of three so it's pretty much the same thing um literally so let's get into it uh given an integer n return true if it is a power of four otherwise return false an integer N is a power of 4 if they are X if there exists an integer X such ...
Power of Four
power-of-four
Given an integer `n`, return _`true` if it is a power of four. Otherwise, return `false`_. An integer `n` is a power of four, if there exists an integer `x` such that `n == 4x`. **Example 1:** **Input:** n = 16 **Output:** true **Example 2:** **Input:** n = 5 **Output:** false **Example 3:** **Input:** n = 1 **O...
null
Math,Bit Manipulation,Recursion
Easy
231,326
269
happened to Ajay that yesterday in the cricket channel today's video, it's so let's signal on the printer of the one who looted the gender dictionary, Ghaghra has a string of some words, first a string of if string, are you not trading for some alien language when that language According to this Software Development Wi...
Alien Dictionary
alien-dictionary
There is a new alien language that uses the English alphabet. However, the order among the letters is unknown to you. You are given a list of strings `words` from the alien language's dictionary, where the strings in `words` are **sorted lexicographically** by the rules of this new language. Return _a string of the u...
null
Array,String,Depth-First Search,Breadth-First Search,Graph,Topological Sort
Hard
210
1,663
all right welcome to january's lead code challenge today's problem is smallest string with a given numeric value a numeric value of a lowercase character is defined as its position in the alphabet so a is one b is two so on and so forth a numeric value of a string consists of lowercase characters defined as the sum of ...
Smallest String With A Given Numeric Value
detect-cycles-in-2d-grid
The **numeric value** of a **lowercase character** is defined as its position `(1-indexed)` in the alphabet, so the numeric value of `a` is `1`, the numeric value of `b` is `2`, the numeric value of `c` is `3`, and so on. The **numeric value** of a **string** consisting of lowercase characters is defined as the sum of...
Keep track of the parent (previous position) to avoid considering an invalid path. Use DFS or BFS and keep track of visited cells to see if there is a cycle.
Array,Depth-First Search,Breadth-First Search,Union Find,Matrix
Medium
null
229
majority so given an integer array of size n find all the inputs that I pay more than n by three times so the given an array of size m I am here to return all the elements that are that is appearing more than n by three times so n is the size of the array in this case the size of the array is 7. so 7 by 3 will be so th...
Majority Element II
majority-element-ii
Given an integer array of size `n`, find all elements that appear more than `⌊ n/3 ⌋` times. **Example 1:** **Input:** nums = \[3,2,3\] **Output:** \[3\] **Example 2:** **Input:** nums = \[1\] **Output:** \[1\] **Example 3:** **Input:** nums = \[1,2\] **Output:** \[1,2\] **Constraints:** * `1 <= nums.length <...
How many majority elements could it possibly have? Do you have a better hint? Suggest it!
Array,Hash Table,Sorting,Counting
Medium
169,1102
1,260
welcome to tim's leco challenge this question is called shift 2d grid given a 2d grid of size m times n and an integer k you need to shift the grid k times now what does that mean shift means we're going to take the element at grid i j and move it to grid i j plus 1. now if the element is at the very edge or at the ver...
Shift 2D Grid
day-of-the-year
Given a 2D `grid` of size `m x n` and an integer `k`. You need to shift the `grid` `k` times. In one shift operation: * Element at `grid[i][j]` moves to `grid[i][j + 1]`. * Element at `grid[i][n - 1]` moves to `grid[i + 1][0]`. * Element at `grid[m - 1][n - 1]` moves to `grid[0][0]`. Return the _2D grid_ after...
Have a integer array of how many days there are per month. February gets one extra day if its a leap year. Then, we can manually count the ordinal as day + (number of days in months before this one).
Math,String
Easy
null
406
hey guys welcome to the core mat uh if you are new to the channel please do subscribe we solve a lot of competitive problems today's problem is q reconstruction by height what problem says is suppose you have a random list of people standing in a queue each person is described by a pair of integer h and k where h is th...
Queue Reconstruction by Height
queue-reconstruction-by-height
You are given an array of people, `people`, which are the attributes of some people in a queue (not necessarily in order). Each `people[i] = [hi, ki]` represents the `ith` person of height `hi` with **exactly** `ki` other people in front who have a height greater than or equal to `hi`. Reconstruct and return _the queu...
What can you say about the position of the shortest person? If the position of the shortest person is i, how many people would be in front of the shortest person? Once you fix the position of the shortest person, what can you say about the position of the second shortest person?
Array,Greedy,Binary Indexed Tree,Segment Tree,Sorting
Medium
315
319
hey guys it's iran and today we're going to solve a question that i came across and couldn't solve to save my life it's called bobswitcher i have mixed feelings about this question on one hand i think it's a terrible interview question i mean just awful look at how many dislikes it has it's not for nothing but on the o...
Bulb Switcher
bulb-switcher
There are `n` bulbs that are initially off. You first turn on all the bulbs, then you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turning off if it's on). For the `ith` round, you toggle every `i` bulb. For the `nth` round, you only toggle the last bulb. Retu...
null
Math,Brainteaser
Medium
672,1037,1491
827
in this video we're going to take a look at a legal problem called uh making a large island so we're basically given a n times n binary matrix squared you're given a you're allowed to change at most one zero right to be one return the size of the largest island in the grid after applying this operation so we are only a...
Making A Large Island
expressive-words
You are given an `n x n` binary matrix `grid`. You are allowed to change **at most one** `0` to be `1`. Return _the size of the largest **island** in_ `grid` _after applying this operation_. An **island** is a 4-directionally connected group of `1`s. **Example 1:** **Input:** grid = \[\[1,0\],\[0,1\]\] **Output:** ...
null
Array,Two Pointers,String
Medium
null
109
hello guys welcome back to my channel my name is I hope you all are doing fine let's solve today's problem for lead code the problem name is convert sorted list to a binary search tree okay it's a medium problem just give a like the problem is saying given the head of a singular linked list where element are sorted in ...
Convert Sorted List to Binary Search Tree
convert-sorted-list-to-binary-search-tree
Given the `head` of a singly linked list where elements are sorted in **ascending order**, convert _it to a_ **_height-balanced_** _binary search tree_. **Example 1:** **Input:** head = \[-10,-3,0,5,9\] **Output:** \[0,-3,9,-10,null,5\] **Explanation:** One possible answer is \[0,-3,9,-10,null,5\], which represents t...
null
Linked List,Divide and Conquer,Tree,Binary Search Tree,Binary Tree
Medium
108,2306
36
hello everyone in this video we will be solving the problem valid sudoku the number of the problem is 36 on lead code if you have played sudoku before then the rules must be pretty familiar to you but for everyone else who haven't played sudoku i'll just go through the rules we have to determine if the 9x9 sudoku board...
Valid Sudoku
valid-sudoku
Determine if a `9 x 9` Sudoku board is valid. Only the filled cells need to be validated **according to the following rules**: 1. Each row must contain the digits `1-9` without repetition. 2. Each column must contain the digits `1-9` without repetition. 3. Each of the nine `3 x 3` sub-boxes of the grid must contain...
null
Array,Hash Table,Matrix
Medium
37,2254
797
Hello everyone and welcome back to my channel Algorithm H Why Today I am going to write the code and also explain to you all the algorithm to solve this all paths from source to target problem which is there in lead code it is a medium level problem and Belong to the graph section, so let's start it by naming it She Cr...
All Paths From Source to Target
rabbits-in-forest
Given a directed acyclic graph (**DAG**) of `n` nodes labeled from `0` to `n - 1`, find all possible paths from node `0` to node `n - 1` and return them in **any order**. The graph is given as follows: `graph[i]` is a list of all nodes you can visit from node `i` (i.e., there is a directed edge from node `i` to node `...
null
Array,Hash Table,Math,Greedy
Medium
null
513
hey guys welcome to a new video in today's video we're going to look at a lead code problem and the problem's name is find bottom left tree value so in this question we given the root of a binary tree and we have to return the leftmost value in the last row of the tree so this is a straightforward description you have ...
Find Bottom Left Tree Value
find-bottom-left-tree-value
Given the `root` of a binary tree, return the leftmost value in the last row of the tree. **Example 1:** **Input:** root = \[2,1,3\] **Output:** 1 **Example 2:** **Input:** root = \[1,2,3,4,null,5,6,null,null,7\] **Output:** 7 **Constraints:** * The number of nodes in the tree is in the range `[1, 104]`. * `-...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
null
201
hello and welcome to my channel so today let's look at the uh today's lead code challenge question 201 bit wise and of a numbers range the question is given two integers left and right that represents the range left to right return the bitwise end of all numbers in this range inclusively so when we saw this question th...
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
495
the problem is demo attacking so the question is our hero Teemo is taking an enemy Ash with poison attacks when Timo attacks Ash gets poisoned for exactly duration seconds more formally an attack at second T will mean Ash is poison during the inclusion time interval t 2 t plus duration minus 1. if Timo attacks again be...
Teemo Attacking
teemo-attacking
Our hero Teemo is attacking an enemy Ashe with poison attacks! When Teemo attacks Ashe, Ashe gets poisoned for a exactly `duration` seconds. More formally, an attack at second `t` will mean Ashe is poisoned during the **inclusive** time interval `[t, t + duration - 1]`. If Teemo attacks again **before** the poison effe...
null
Array,Simulation
Easy
56,605,649
430
Hello everyone welcome to my channel today's date 19th July recording will play any problem his flat in a multi level doubly linked this problem you are giver ne Delhi link leaves bhi thing in addition to the next and previous pointers it should have a channel pointer In the middle and the main knot does not point to t...
Flatten a Multilevel Doubly Linked List
flatten-a-multilevel-doubly-linked-list
You are given a doubly linked list, which contains nodes that have a next pointer, a previous pointer, and an additional **child pointer**. This child pointer may or may not point to a separate doubly linked list, also containing these special nodes. These child lists may have one or more children of their own, and so ...
null
null
Medium
null
1,345
hi guys welcome to algorithms made easy today we will be seeing the question jump game part 4. given an array of integers arr you are initially positioned at the first index and in one step you can jump from the index i to either i plus 1 or i minus 1 or an index j where the value at the index i and j are equal but the...
Jump Game IV
perform-string-shifts
Given an array of integers `arr`, you are initially positioned at the first index of the array. In one step you can jump from index `i` to index: * `i + 1` where: `i + 1 < arr.length`. * `i - 1` where: `i - 1 >= 0`. * `j` where: `arr[i] == arr[j]` and `i != j`. Return _the minimum number of steps_ to reach the...
Intuitively performing all shift operations is acceptable due to the constraints. You may notice that left shift cancels the right shift, so count the total left shift times (may be negative if the final result is right shift), and perform it once.
Array,Math,String
Easy
null
305
hey hello there so today I'm talking about questions 305 number islands - about questions 305 number islands - about questions 305 number islands - which can be vulnerable to the question 200 number of islands since this is I guess the precursor question to that one gonna really quickly summarize what this question is ...
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
35
we are going to look at a lead called problem called search insert position in this question we are given a nums array and an integer variable target we have to return the index if the target is found else we have to return the index where it would have been present if it was inserted inside the array so in this case t...
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
144
all right so welcome back and this is called binary pre-order traversal and called binary pre-order traversal and called binary pre-order traversal and it's question 144 it's an easy uh tree traversal question and we're going to do exactly what it says we're going to traverse the tree in pre-order in pre-order in pre-o...
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
1,933
hey YouTube Welcome Back and today we have these problems called check if string is uh decompatible into value equal to substring Value equals substring and it's a new problem just has maybe 80 84 solution for it so it's really a new problem um and the good thing about new problems that you could find these types of pr...
Check if String Is Decomposable Into Value-Equal Substrings
number-of-different-integers-in-a-string
A **value-equal** string is a string where **all** characters are the same. * For example, `"1111 "` and `"33 "` are value-equal strings. * In contrast, `"123 "` is not a value-equal string. Given a digit string `s`, decompose the string into some number of **consecutive value-equal** substrings where **exactly o...
Try to split the string so that each integer is in a different string. Try to remove each integer's leading zeroes and compare the strings to find how many of them are unique.
Hash Table,String
Easy
null
20
using a stack is essential for coding interviews so let's get some practice we're given a string s containing just the round brackets curly braces and square brackets I want to determine if the input string is valid we are going to use a stack it's going to start at empty and when we see an Open Bracket we're just goin...
Valid Parentheses
valid-parentheses
Given a string `s` containing just the characters `'('`, `')'`, `'{'`, `'}'`, `'['` and `']'`, determine if the input string is valid. An input string is valid if: 1. Open brackets must be closed by the same type of brackets. 2. Open brackets must be closed in the correct order. 3. Every close bracket has a corres...
An interesting property about a valid parenthesis expression is that a sub-expression of a valid expression should also be a valid expression. (Not every sub-expression) e.g. { { } [ ] [ [ [ ] ] ] } is VALID expression [ [ [ ] ] ] is VALID sub-expression { } [ ] is VALID sub-express...
String,Stack
Easy
22,32,301,1045,2221
1,624
hello guys and welcome back to lead Logics this is the largest substring between two equal characters problem from lead code this is a lead code easy and the number for this is 1624 so in the given problem uh we are having a string s and we have to return the length of the longest substring between two equal characters...
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
97
hello everyone welcome to coderscam we are second day of june lead code challenge and the problem we are going to cover in this video is interleaving string input given here is three string variables s1 s2 and s3 and we have to return true or false if we can form string three by interleaving string one and string two s...
Interleaving String
interleaving-string
Given strings `s1`, `s2`, and `s3`, find whether `s3` is formed by an **interleaving** of `s1` and `s2`. An **interleaving** of two strings `s` and `t` is a configuration where `s` and `t` are divided into `n` and `m` substrings respectively, such that: * `s = s1 + s2 + ... + sn` * `t = t1 + t2 + ... + tm` * `|...
null
String,Dynamic Programming
Medium
null
1,814
Hello friends uh welcome to my channel let's have a look at problem 1814 can't Nest parents inner array so this problem actually is essentially the same as lead code 2426 23 40 64 493 Etc so here we still present two methods the first method is a dictionary and a check and the second method is direct cons so first I'll...
Count Nice Pairs in an Array
jump-game-vi
You are given an array `nums` that consists of non-negative integers. Let us define `rev(x)` as the reverse of the non-negative integer `x`. For example, `rev(123) = 321`, and `rev(120) = 21`. A pair of indices `(i, j)` is **nice** if it satisfies all of the following conditions: * `0 <= i < j < nums.length` * `nu...
Let dp[i] be "the maximum score to reach the end starting at index i". The answer for dp[i] is nums[i] + max{dp[i+j]} for 1 <= j <= k. That gives an O(n*k) solution. Instead of checking every j for every i, keep track of the largest dp[i] values in a heap and calculate dp[i] from right to left. When the largest value i...
Array,Dynamic Programming,Queue,Sliding Window,Heap (Priority Queue),Monotonic Queue
Medium
239,2001
48
to a new problem today so yeah this one has uh attracted my interest um i've just spotted it and i thought i'd do a stream pretty much immediately because i think it's really cool problem so the idea is to rotate a grid uh by 90 degrees clockwise and there's a constraint on here where we are not allowed to allocate ano...
Rotate Image
rotate-image
You are given an `n x n` 2D `matrix` representing an image, rotate the image by **90** degrees (clockwise). You have to rotate the image [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm), which means you have to modify the input 2D matrix directly. **DO NOT** allocate another 2D matrix and do the rotati...
null
Array,Math,Matrix
Medium
2015
46
hey yo what's up my little coders let's solve today they literally question 46 permutations basically given a collection of distinct integers return all possible permutations i will not lie it's quite challenging but it's a very interesting problem and it's very useful to know how to solve it um let's let me show you h...
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
334
are you stuck on a coding challenge don't worry code Crusader have got your back let's dive in and solve the increasing triplet sequence problem together the problem is to find if there exists a triplet of increasing numbers in the input array nums the solution starts by initializing two variables first and second with...
Increasing Triplet Subsequence
increasing-triplet-subsequence
Given an integer array `nums`, return `true` _if there exists a triple of indices_ `(i, j, k)` _such that_ `i < j < k` _and_ `nums[i] < nums[j] < nums[k]`. If no such indices exists, return `false`. **Example 1:** **Input:** nums = \[1,2,3,4,5\] **Output:** true **Explanation:** Any triplet where i < j < k is valid. ...
null
Array,Greedy
Medium
300,2122,2280
143
to solve the problem 143 reorder lists this is a popular single unless problem so for the input there is a given a singly linked list and for the output we have to reorder it to this pattern so for example 1 there is a given 1 2 3 4 we have to reorder 2 1 4 2 3 and another example 2 given 1 2 3 4 5 we have to reorder 1...
Reorder List
reorder-list
You are given the head of a singly linked-list. The list can be represented as: L0 -> L1 -> ... -> Ln - 1 -> Ln _Reorder the list to be on the following form:_ L0 -> Ln -> L1 -> Ln - 1 -> L2 -> Ln - 2 -> ... You may not modify the values in the list's nodes. Only nodes themselves may be changed. **Example 1:** **...
null
Linked List,Two Pointers,Stack,Recursion
Medium
2216
901
hello everyone and welcome back today we have 901 online stock span it says here to design an algorithm that collects daily price quotes for some stock and return the span of that Stock's price for the current day and this span is defined below where the span of a Stock's price in one day is the maximum number of conse...
Online Stock Span
advantage-shuffle
Design an algorithm that collects daily price quotes for some stock and returns **the span** of that stock's price for the current day. The **span** of the stock's price in one day is the maximum number of consecutive days (starting from that day and going backward) for which the stock price was less than or equal to ...
null
Array,Greedy,Sorting
Medium
null
701
hi everyone welcome to my channel let's solve the problem insert into a binary search tree so binary search tree is a very famous data structure in the in terms of interviews problem as well as the very like standard applications so we should know that the basic operations in binary sashi like insert a node delete a no...
Insert into a Binary Search Tree
insert-into-a-binary-search-tree
You are given the `root` node of a binary search tree (BST) and a `value` to insert into the tree. Return _the root node of the BST after the insertion_. It is **guaranteed** that the new value does not exist in the original BST. **Notice** that there may exist multiple valid ways for the insertion, as long as the tre...
null
null
Medium
null
1,237
hi everyone so let's talk about finding positive integer solution for a given equation so uh basically you definitely need to know like you have to input and then the input is basically based on the z so if that is equal then you just have to put it into the list right so you are given a function id so which is custom ...
Find Positive Integer Solution for a Given Equation
reported-posts-ii
Given a callable function `f(x, y)` **with a hidden formula** and a value `z`, reverse engineer the formula and return _all positive integer pairs_ `x` _and_ `y` _where_ `f(x,y) == z`. You may return the pairs in any order. While the exact formula is hidden, the function is monotonically increasing, i.e.: * `f(x, y...
null
Database
Medium
null
1,984
welcome guys so that's solving is 194. uh sorry 194 uh medium motif respeding highest and lowest k scores okay so you're given zero index arrays where the numbers are represented score and the i students and your keys so also given integer k and the picker score and in k students from array so that the difference betwe...
Minimum Difference Between Highest and Lowest of K Scores
maximum-distance-between-a-pair-of-values
You are given a **0-indexed** integer array `nums`, where `nums[i]` represents the score of the `ith` student. You are also given an integer `k`. Pick the scores of any `k` students from the array so that the **difference** between the **highest** and the **lowest** of the `k` scores is **minimized**. Return _the **m...
Since both arrays are sorted in a non-increasing way this means that for each value in the first array. We can find the farthest value smaller than it using binary search. There is another solution using a two pointers approach since the first array is non-increasing the farthest j such that nums2[j] ≥ nums1[i] is at l...
Array,Two Pointers,Binary Search,Greedy
Medium
2199
168
Hello everybody welcome back to hike my name is pranal j today we are going to understand a question called Excel sheet column title first of all we going to understand the question then we are going to code this in so watch the entire video all right let's get started with the question given an integer column number r...
Excel Sheet Column Title
excel-sheet-column-title
Given an integer `columnNumber`, return _its corresponding column title as it appears in an Excel sheet_. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... **Example 1:** **Input:** columnNumber = 1 **Output:** "A " **Example 2:** **Input:** columnNumber = 28 **Output:** "AB " **Example 3:**...
null
Math,String
Easy
171,2304
54
hey so welcome back and there's another daily code problem so today it's called spiral Matrix and it's a medium level problem so it's a like a two-dimensional problem so it's a like a two-dimensional problem so it's a like a two-dimensional array traversal problem where you're given a matrix here and you want to naviga...
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
1,099
hello and welcome to another video in this video we're going to be working on two Sumas less than K and it's very similar to the original two sum except for instead of finding two numbers that add up to a Target now you're asking for give me the biggest sum that I can use making two numbers that's less than this K that...
Two Sum Less Than K
path-with-maximum-minimum-value
Given an array `nums` of integers and integer `k`, return the maximum `sum` such that there exists `i < j` with `nums[i] + nums[j] = sum` and `sum < k`. If no `i`, `j` exist satisfying this equation, return `-1`. **Example 1:** **Input:** nums = \[34,23,1,24,75,33,54,8\], k = 60 **Output:** 58 **Explanation:** We can...
What if we sort each cell of the matrix by the value? Don't include small values in your path if you can only include large values. Let's keep adding a possible cell to use in the path incrementally with decreasing values. If the start and end cells are connected then we don't need to add more cells. Use union-find dat...
Array,Depth-First Search,Breadth-First Search,Union Find,Heap (Priority Queue),Matrix
Medium
1753
653
today I am solving little problem number 653 to Psalm 4. the input is in a binary search tree it is almost like the twosome problem uh which is in the form of array so here uh in the two sum problem we actually create a set where we store the complements of the elements that we encounter in the array and here also we a...
Two Sum IV - Input is a BST
two-sum-iv-input-is-a-bst
Given the `root` of a binary search tree and an integer `k`, return `true` _if there exist two elements in the BST such that their sum is equal to_ `k`, _or_ `false` _otherwise_. **Example 1:** **Input:** root = \[5,3,6,2,4,null,7\], k = 9 **Output:** true **Example 2:** **Input:** root = \[5,3,6,2,4,null,7\], k = ...
null
Hash Table,Two Pointers,Tree,Depth-First Search,Breadth-First Search,Binary Search Tree,Binary Tree
Easy
1,167,170,1150
424
what's up guys it's leetcoder this is elitecode424 longest repeating character replacement so we're given a string such as a b and we can choose any character of the string and change to any other uppercase english character we can perform this operation at most k times and we have to return the longest substring conta...
Longest Repeating Character Replacement
longest-repeating-character-replacement
You are given a string `s` and an integer `k`. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most `k` times. Return _the length of the longest substring containing the same letter you can get after performing the above operations_. ...
null
Hash Table,String,Sliding Window
Medium
340,1046,2119,2134,2319
124
hello world Joshua here I want to be teaching you about how to solve this problem binary tree Mattson path some alright we're tackling finally a big boy hard or big girl to be gender-neutral hard or big girl to be gender-neutral hard or big girl to be gender-neutral Oh me actually you know what I would retract that sta...
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
849
Hello Hi Everyone Welcome To My Channel It's All The Problem Maximized Everyday Person Should Give An Are Representing Role Subscribe Skating Subscribe And Leave With Subscribe And Subscribe This Video Not Shyam One Of The Distance From 0001 Number To Distance From Subscribe Now To 9 Ki Is Flexi Song Seat Number Three ...
Maximize Distance to Closest Person
maximize-distance-to-closest-person
You are given an array representing a row of `seats` where `seats[i] = 1` represents a person sitting in the `ith` seat, and `seats[i] = 0` represents that the `ith` seat is empty **(0-indexed)**. There is at least one empty seat, and at least one person sitting. Alex wants to sit in the seat such that the distance b...
null
null
Medium
null
398
back to the cracking pain youtube channel today we're going to be solving lead code problem 398 random pick index before we get into the question prompt you guys know the drill please subscribe to the channel if you haven't already it really helps me grow and i want to reach 10 000 by the end of the year so please help...
Random Pick Index
random-pick-index
Given an integer array `nums` with possible **duplicates**, randomly output the index of a given `target` number. You can assume that the given target number must exist in the array. Implement the `Solution` class: * `Solution(int[] nums)` Initializes the object with the array `nums`. * `int pick(int target)` Pic...
null
Hash Table,Math,Reservoir Sampling,Randomized
Medium
382,894,912
493
so hello guys welcome to this new video and in this video we're basically going to uh discover the question that is a reverse pass so uh in this question from lead code that is of hard difficulty level we will basically be given an array and we'll have to return the uh the number of reverse pairs that are present in th...
Reverse Pairs
reverse-pairs
Given an integer array `nums`, return _the number of **reverse pairs** in the array_. A **reverse pair** is a pair `(i, j)` where: * `0 <= i < j < nums.length` and * `nums[i] > 2 * nums[j]`. **Example 1:** **Input:** nums = \[1,3,2,3,1\] **Output:** 2 **Explanation:** The reverse pairs are: (1, 4) --> nums\[1\]...
null
Array,Binary Search,Divide and Conquer,Binary Indexed Tree,Segment Tree,Merge Sort,Ordered Set
Hard
315,327
80
Hello Hi Guys Welcome to Your Deeds and Such Today Solving Questions Remove Duplicates Question Remove Duplicates Another Posted in 1231 Subscribe Number One to Three What You Want the Giver Has * Repeat a Number 100 is too deep to be repeated or * Repeat a Number 100 is too deep to be repeated or * Repeat a Number 100...
Remove Duplicates from Sorted Array II
remove-duplicates-from-sorted-array-ii
Given an integer array `nums` sorted in **non-decreasing order**, remove some duplicates [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm) such that each unique element appears **at most twice**. The **relative order** of the elements should be kept the **same**. Since it is impossible to change the len...
null
Array,Two Pointers
Medium
26
349
hey everybody it's me Abdullah welcome back and today I'll be doing another lead code three four nine intersection of two arrays an easy one given two integer arrays nums one and nums two return and array of their intersection each element in the result must be unique and you may return the result in any order so we do...
Intersection of Two Arrays
intersection-of-two-arrays
Given two integer arrays `nums1` and `nums2`, return _an array of their intersection_. Each element in the result must be **unique** and you may return the result in **any order**. **Example 1:** **Input:** nums1 = \[1,2,2,1\], nums2 = \[2,2\] **Output:** \[2\] **Example 2:** **Input:** nums1 = \[4,9,5\], nums2 = \...
null
Array,Hash Table,Two Pointers,Binary Search,Sorting
Easy
350,1149,1392,2190,2282
1,685
hey everybody this is Larry this is day 25 of the leco day challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's Farm uh I'm still in okanawa in naha um yeah I got to remember to do the intro so maybe tomorrow but yeah today's Farm is 1685 some of the absolut...
Sum of Absolute Differences in a Sorted Array
stone-game-v
You are given an integer array `nums` sorted in **non-decreasing** order. Build and return _an integer array_ `result` _with the same length as_ `nums` _such that_ `result[i]` _is equal to the **summation of absolute differences** between_ `nums[i]` _and all the other elements in the array._ In other words, `result[i...
We need to try all possible divisions for the current row to get the max score. As calculating all possible divisions will lead us to calculate some sub-problems more than once, we need to think of dynamic programming.
Array,Math,Dynamic Programming,Game Theory
Hard
909,1240,1522,1617,1788,1808,2002,2156
639
Hey Already Guys Welcome To Our Channel Tweet Sunny And You Will Be Talking About Telescope Problem And Its Name Is Back Roadways Se Contents And 163 Interest Categorized As Hata Problem Playlist Ko Tit Soe Singh Ka Meeting Special Video Like You Will After A Long Time E Think It Was Quite Busy Software Second Hour Wha...
Decode Ways II
decode-ways-ii
A message containing letters from `A-Z` can be **encoded** into numbers using the following mapping: 'A' -> "1 " 'B' -> "2 " ... 'Z' -> "26 " To **decode** an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For examp...
null
String,Dynamic Programming
Hard
91,2091,2251
67
hello and welcome to another one of my lead code videos and this one we'll do lead code 67 add binary this is basically creating a binary Adder so the question is very simple we're given two binary strings and we have to produce an output which is another binary string that adds the two binary strings and note that the...
Add Binary
add-binary
Given two binary strings `a` and `b`, return _their sum as a binary string_. **Example 1:** **Input:** a = "11", b = "1" **Output:** "100" **Example 2:** **Input:** a = "1010", b = "1011" **Output:** "10101" **Constraints:** * `1 <= a.length, b.length <= 104` * `a` and `b` consist only of `'0'` or `'1'` chara...
null
Math,String,Bit Manipulation,Simulation
Easy
2,43,66,1031
374
Hello, my name is Suren and this is a solution with analysis of the literary code for task number 374 Yes Number Higher or lower, in fact, this is just an implementation in code of the children's problem Guess the number. For example, I guessed one number from one to a hundred. Guess what number if you randomly search ...
Guess Number Higher or Lower
guess-number-higher-or-lower
We are playing the Guess Game. The game is as follows: I pick a number from `1` to `n`. You have to guess which number I picked. Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess. You call a pre-defined API `int guess(int num)`, which returns three possible re...
null
Binary Search,Interactive
Easy
278,375,658
1,197
hey everyone welcome to my channel in this video i'm going to cover the solution to this question called minimum night moves so before we start the real content i would really appreciate that if you can help the squad's channel so first of all let's resolve this question in infinite chassboard with coordinates from min...
Minimum Knight Moves
parsing-a-boolean-expression
In an **infinite** chess board with coordinates from `-infinity` to `+infinity`, you have a **knight** at square `[0, 0]`. A knight has 8 possible moves it can make, as illustrated below. Each move is two squares in a cardinal direction, then one square in an orthogonal direction. Return _the minimum number of steps ...
Write a function "parse" which calls helper functions "parse_or", "parse_and", "parse_not".
String,Stack,Recursion
Hard
null
1,631
hey everyone welcome back and let's write some more neat code today so today I'll solve the problem path with minimum effort we are on a two-dimensional grid effort we are on a two-dimensional grid effort we are on a two-dimensional grid like this we're starting at the top left position and our goal is to get to the bo...
Path With Minimum Effort
number-of-sub-arrays-with-odd-sum
You are a hiker preparing for an upcoming hike. You are given `heights`, a 2D array of size `rows x columns`, where `heights[row][col]` represents the height of cell `(row, col)`. You are situated in the top-left cell, `(0, 0)`, and you hope to travel to the bottom-right cell, `(rows-1, columns-1)` (i.e., **0-indexed**...
Can we use the accumulative sum to keep track of all the odd-sum sub-arrays ? if the current accu sum is odd, we care only about previous even accu sums and vice versa.
Array,Math,Dynamic Programming,Prefix Sum
Medium
2242
1,748
okay so welcome guys so welcome to the my decode solving section so please uh be sure to subscribe to my channel okay so this is uh one seven four eight sum of unique element so basically you have integer arrays and a unique element of a royal element appears exactly once so return the sum of all unique elements so if ...
Sum of Unique Elements
best-team-with-no-conflicts
You are given an integer array `nums`. The unique elements of an array are the elements that appear **exactly once** in the array. Return _the **sum** of all the unique elements of_ `nums`. **Example 1:** **Input:** nums = \[1,2,3,2\] **Output:** 4 **Explanation:** The unique elements are \[1,3\], and the sum is 4. ...
First, sort players by age and break ties by their score. You can now consider the players from left to right. If you choose to include a player, you must only choose players with at least that score later on.
Array,Dynamic Programming,Sorting
Medium
null
110
everyone welcome back to the channel i hope you guys are doing extremely well so today we will be solving the problem check for balanced binary tree from the free card tree series so what is a balanced binary tree so in any given binary tree there will be a lot of nodes okay so for every node the height of the left sub...
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
236
hello everyone today I'm going to solve lead code problem number 236 lowest common ancestor of a binary tree uh now let's read the question I'll give it a binary tree find the lowest common ancestor LCA of two given nodes in the tree so what is LCA between two nodes p and Q is the lowest node in the tree that has both ...
Lowest Common Ancestor of a Binary Tree
lowest-common-ancestor-of-a-binary-tree
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the [definition of LCA on Wikipedia](https://en.wikipedia.org/wiki/Lowest_common_ancestor): "The lowest common ancestor is defined between two nodes `p` and `q` as the lowest node in `T` that has both `p` and `q` as...
null
Tree,Depth-First Search,Binary Tree
Medium
235,1190,1354,1780,1790,1816,2217
1,567
hey guys what's up uh my name is steve today we're going to go through lead con problem 1567 maximum length of sub array with pro with positive product so let's take a look at the problem giving an array integers nums it's asking us to find the maximum length of the sample array where the product of all of its elements...
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
501
hello everyone welcome to my channel here I solve the L code problems today I will try to find the solution of the problem number 501 find mode in binary search tree given the root of binary search tree BST with duplicates return all the modes the mo the most frequently occurred element in it if the tree has more than ...
Find Mode in Binary Search Tree
find-mode-in-binary-search-tree
Given the `root` of a binary search tree (BST) with duplicates, return _all the [mode(s)](https://en.wikipedia.org/wiki/Mode_(statistics)) (i.e., the most frequently occurred element) in it_. If the tree has more than one mode, return them in **any order**. Assume a BST is defined as follows: * The left subtree of...
null
Tree,Depth-First Search,Binary Search Tree,Binary Tree
Easy
98
160
in this video we're going to take a look at a legal problem called intersection of two linked lists so write a program to find a node uh note at which the intersection of two link uh singularly linked lists begins so for example the following two link lists begins to intersect at no c1 so in this case c1 is right here ...
Intersection of Two Linked Lists
intersection-of-two-linked-lists
Given the heads of two singly linked-lists `headA` and `headB`, return _the node at which the two lists intersect_. If the two linked lists have no intersection at all, return `null`. For example, the following two linked lists begin to intersect at node `c1`: The test cases are generated such that there are no cycle...
null
Hash Table,Linked List,Two Pointers
Easy
599
42
so today we're looking at leak code 42 trapping rainwater it says given n non-negative integers representing an non-negative integers representing an non-negative integers representing an elevation map or the width of each bar is 1 compute how much water is able to trap after raining so this has the array 0 1 0 2 1 0 1...
Trapping Rain Water
trapping-rain-water
Given `n` non-negative integers representing an elevation map where the width of each bar is `1`, compute how much water it can trap after raining. **Example 1:** **Input:** height = \[0,1,0,2,1,0,1,3,2,1,2,1\] **Output:** 6 **Explanation:** The above elevation map (black section) is represented by array \[0,1,0,2,1,...
null
Array,Two Pointers,Dynamic Programming,Stack,Monotonic Stack
Hard
11,238,407,756
115
Hello Everyone Let's Start Discussing About Today Lead Code by Kakali Contest 11 So, first of all, I liked this contest a little less because the language of the problems was a little, I felt that after reading it once, I could not understand it. Like In the first question too and in the fourth problem, the constraints...
Distinct Subsequences
distinct-subsequences
Given two strings `s` and `t`, return _the number of distinct_ **_subsequences_** _of_ `s` _which equals_ `t`. The test cases are generated so that the answer fits on a 32-bit signed integer. **Example 1:** **Input:** s = "rabbbit ", t = "rabbit " **Output:** 3 **Explanation:** As shown below, there are 3 ways you...
null
String,Dynamic Programming
Hard
2115