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
20
this question asks you to determine if the input string is valid and basically all open brackets must be closed by the same type of brackets and closed in the same order in order for it to be a valid string so they're saying these are the types of strings that you will have so i'm just going to create a dictionary to s...
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
56
Hello everyone welcome back to my channel Swayam Now we are going to discuss the problem from the sheet is much interval okay so this is a very important problem interview certificate let's read the problem first even a leaf can travel when in trouble I mean In the internal exam in which the first test and interview we...
Merge Intervals
merge-intervals
Given an array of `intervals` where `intervals[i] = [starti, endi]`, merge all overlapping intervals, and return _an array of the non-overlapping intervals that cover all the intervals in the input_. **Example 1:** **Input:** intervals = \[\[1,3\],\[2,6\],\[8,10\],\[15,18\]\] **Output:** \[\[1,6\],\[8,10\],\[15,18\]\...
null
Array,Sorting
Medium
57,252,253,495,616,715,761,768,1028,2297,2319
171
hello everyone hope you all are doing well so i am back with another lit good day challenge and it is late code number 171 excel sheet column number it is an easy level question and i also feel the same so the question is given a string column title that represent the column title as appear in an excel sheet return its...
Excel Sheet Column Number
excel-sheet-column-number
Given a string `columnTitle` that represents the column title as appears in an Excel sheet, return _its corresponding column number_. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... **Example 1:** **Input:** columnTitle = "A " **Output:** 1 **Example 2:** **Input:** columnTitle = "AB " **Ou...
null
Math,String
Easy
168,2304
187
hey welcome to this video we're gonna do Lika prom 187 repeated DNA sequences right so the directions are kind of long let's skip over that so they give us an input string representing the guess the four letters that represent DNA ACGT it's been a while and then you got returned Mac the let's see ten letter long sequen...
Repeated DNA Sequences
repeated-dna-sequences
The **DNA sequence** is composed of a series of nucleotides abbreviated as `'A'`, `'C'`, `'G'`, and `'T'`. * For example, `"ACGAATTCCG "` is a **DNA sequence**. When studying **DNA**, it is useful to identify repeated sequences within the DNA. Given a string `s` that represents a **DNA sequence**, return all the *...
null
Hash Table,String,Bit Manipulation,Sliding Window,Rolling Hash,Hash Function
Medium
null
1,732
hello guys welcome back to my channel and today we are going to solve a new lead for question that is finding the highest altitude so we are going to solve this portion with the help of JavaScript and if a person says there's a biker going on a road trip the road trip consists of n plus 1 points at different altitudes ...
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
1,035
Hello friends today I'm going to solve liquid problem number 10 35 uncrust lines in this problem we are given two integer arrays nums 1 and nums 2 and um what we are going to do is rewrite all the integers of num Swan and the nums 2 into separate horizontal lines like given in this example um where 1 4 and 2 are the in...
Uncrossed Lines
cousins-in-binary-tree
You are given two integer arrays `nums1` and `nums2`. We write the integers of `nums1` and `nums2` (in the order they are given) on two separate horizontal lines. We may draw connecting lines: a straight line connecting two numbers `nums1[i]` and `nums2[j]` such that: * `nums1[i] == nums2[j]`, and * the line we d...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
102
897
Hello Hi Everyone Welcome To My Channel It's All The Problem Increasing Order Search Tree To Give Me The Root Of - Tree And Tours In Give Me The Root Of - Tree And Tours In Give Me The Root Of - Tree And Tours In The Tree In Order Sudhe Left Node In The Tree Is The Root Of The Tree And Everyone Has No Clue Festival Avo...
Increasing Order Search Tree
prime-palindrome
Given the `root` of a binary search tree, rearrange the tree in **in-order** so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only one right child. **Example 1:** **Input:** root = \[5,3,6,2,4,null,8,1,null,null,null,7,9\] **Output:** \[1,null,2,null,3,null,4,nul...
null
Math
Medium
2202
961
is today we are going to record the n repeated elements in size 2 and array in python so in an array a of size 2 and their m plus one unique elements and exactly one of these elements is repeated end times return the elements repeated ten end times so example one we have one two three uh we can see that there are um th...
N-Repeated Element in Size 2N Array
long-pressed-name
You are given an integer array `nums` with the following properties: * `nums.length == 2 * n`. * `nums` contains `n + 1` **unique** elements. * Exactly one element of `nums` is repeated `n` times. Return _the element that is repeated_ `n` _times_. **Example 1:** **Input:** nums = \[1,2,3,3\] **Output:** 3 **...
null
Two Pointers,String
Easy
null
801
hey what's up guys jung here again and so today let's take a look at this lethal problem here number 801 minimum swaps to make sequences increasing a very good dp problem we have two integer sequences a and b who have the same non-zero length and you are allowed non-zero length and you are allowed non-zero length and y...
Minimum Swaps To Make Sequences Increasing
is-graph-bipartite
You are given two integer arrays of the same length `nums1` and `nums2`. In one operation, you are allowed to swap `nums1[i]` with `nums2[i]`. * For example, if `nums1 = [1,2,3,8]`, and `nums2 = [5,6,7,4]`, you can swap the element at `i = 3` to obtain `nums1 = [1,2,3,4]` and `nums2 = [5,6,7,8]`. Return _the minimu...
null
Depth-First Search,Breadth-First Search,Union Find,Graph
Medium
null
847
Bluetooth Facebook Today Will Be Discussing The Problems Of Taste For Visiting On So Let's First Understand A Problem Statement Being Given Directly Connected Graph And Note Smith 021 Minus One Note Se Zara Fiber List Of All Notes Connected With Node I Boys Association President Meaning Of Address Representative All th...
Shortest Path Visiting All Nodes
shortest-path-visiting-all-nodes
You have an undirected, connected graph of `n` nodes labeled from `0` to `n - 1`. You are given an array `graph` where `graph[i]` is a list of all the nodes connected with node `i` by an edge. Return _the length of the shortest path that visits every node_. You may start and stop at any node, you may revisit nodes mul...
null
null
Hard
null
994
First time spray attack in jhal Voting orange wash problem number 9483 dog show in this question the giver graph and its significance of different types of pollution based idioms thistle and festival which gives instant notifications every minute in fresh and incident to and rotting hormone begum pure Water Should Only...
Rotting Oranges
prison-cells-after-n-days
You are given an `m x n` `grid` where each cell can have one of three values: * `0` representing an empty cell, * `1` representing a fresh orange, or * `2` representing a rotten orange. Every minute, any fresh orange that is **4-directionally adjacent** to a rotten orange becomes rotten. Return _the minimum nu...
null
Array,Hash Table,Math,Bit Manipulation
Medium
null
41
Hello everyone so today bill b discussing question number 41 of late code which is first missing positive ok so here we have a hard problem so we have to do it with some thinking it is a little difficult but it is very difficult. No and this is my play list of Cyclix shot, this is its part, see its questions, try it af...
First Missing Positive
first-missing-positive
Given an unsorted integer array `nums`, return the smallest missing positive integer. You must implement an algorithm that runs in `O(n)` time and uses constant extra space. **Example 1:** **Input:** nums = \[1,2,0\] **Output:** 3 **Explanation:** The numbers in the range \[1,2\] are all in the array. **Example 2:*...
Think about how you would solve the problem in non-constant space. Can you apply that logic to the existing space? We don't care about duplicates or non-positive integers Remember that O(2n) = O(n)
Array,Hash Table
Hard
268,287,448,770
942
yeahyeah Hi everyone, I'm a programmer. Today I'm going to introduce to you a problem with the following title: you a problem with the following title: you a problem with the following title: a suitable Dy string, then we'll go into the details of the problem. To better understand what this word means, the following de...
DI String Match
super-palindromes
A permutation `perm` of `n + 1` integers of all the integers in the range `[0, n]` can be represented as a string `s` of length `n` where: * `s[i] == 'I'` if `perm[i] < perm[i + 1]`, and * `s[i] == 'D'` if `perm[i] > perm[i + 1]`. Given a string `s`, reconstruct the permutation `perm` and return it. If there are ...
null
Math,Enumeration
Hard
null
832
hello everyone so today in this video we can discuss another problem from lead code the problem name is flipping an image the problem is telling you that you are given an n cross n binary image like binary matrix image binary means that it only consists of zeros and ones now you have to flip the image horizontally and ...
Flipping an Image
binary-tree-pruning
Given an `n x n` binary matrix `image`, flip the image **horizontally**, then invert it, and return _the resulting image_. To flip an image horizontally means that each row of the image is reversed. * For example, flipping `[1,1,0]` horizontally results in `[0,1,1]`. To invert an image means that each `0` is repla...
null
Tree,Depth-First Search,Binary Tree
Medium
null
837
hey what's up guys john here again so this time let's take a look at another lead called problem here number eight hundred and thirty seven new 21-game very it's a very good new 21-game very it's a very good new 21-game very it's a very good problem I like it so even though it's a medium problem but I think it's a litt...
New 21 Game
most-common-word
Alice plays the following game, loosely based on the card game **"21 "**. Alice starts with `0` points and draws numbers while she has less than `k` points. During each draw, she gains an integer number of points randomly from the range `[1, maxPts]`, where `maxPts` is an integer. Each draw is independent and the outc...
null
Hash Table,String,Counting
Easy
null
213
hello everyone welcome to clash encoder so in this video we will see the question house robot 2 which is in continuation of the question on which i made the video for the house robber one so it is 213 question and it is a medium level question and will be more difficult than the household one but it is easy if you know...
House Robber II
house-robber-ii
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are **arranged in a circle.** That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have a security system connected, and **it will automatical...
Since House[1] and House[n] are adjacent, they cannot be robbed together. Therefore, the problem becomes to rob either House[1]-House[n-1] or House[2]-House[n], depending on which choice offers more money. Now the problem has degenerated to the House Robber, which is already been solved.
Array,Dynamic Programming
Medium
198,256,276,337,600,656
81
Hello friends today I am going to solve liquid problem number 81 search in rotated sorted array 2. in this problem we are given an integer array numps sorted in non-decreasing order and it sorted in non-decreasing order and it sorted in non-decreasing order and it not necessarily with distinct values okay so it may con...
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
1,037
hey what's up guys so that's solving stupid problem this is one zero three seven that is uh boom boomerang a woman i don't know argument points uh array of points right it's um interesting is that there are only three points okay and uh if there are boomerang bearings a set of three points there are the things and they...
Valid Boomerang
minimum-number-of-k-consecutive-bit-flips
Given an array `points` where `points[i] = [xi, yi]` represents a point on the **X-Y** plane, return `true` _if these points are a **boomerang**_. A **boomerang** is a set of three points that are **all distinct** and **not in a straight line**. **Example 1:** **Input:** points = \[\[1,1\],\[2,3\],\[3,2\]\] **Output...
null
Array,Bit Manipulation,Sliding Window,Prefix Sum
Hard
319,2286
239
So hello everyone of de and today's question is 239 sliding window maximum so understand this question we have an error given which will move in this we have to return max slide window so max sliding Window, what is the max sliding window? Max sliding window is the window in which what we are going to do is to store th...
Sliding Window Maximum
sliding-window-maximum
You are given an array of integers `nums`, there is a sliding window of size `k` which is moving from the very left of the array to the very right. You can only see the `k` numbers in the window. Each time the sliding window moves right by one position. Return _the max sliding window_. **Example 1:** **Input:** nums...
How about using a data structure such as deque (double-ended queue)? The queue size need not be the same as the window’s size. Remove redundant elements and the queue should store only elements that need to be considered.
Array,Queue,Sliding Window,Heap (Priority Queue),Monotonic Queue
Hard
76,155,159,265,1814
629
hello everyone welcome to quartus camp we are at 19th day of june eco challenge and the problem we are going to cover in this video is k inverse fast array so the input given here is a two integer values n and k with where n represent the elements starting from 1 to n in the array and k is nothing but the number of inv...
K Inverse Pairs Array
k-inverse-pairs-array
For an integer array `nums`, an **inverse pair** is a pair of integers `[i, j]` where `0 <= i < j < nums.length` and `nums[i] > nums[j]`. Given two integers n and k, return the number of different arrays consist of numbers from `1` to `n` such that there are exactly `k` **inverse pairs**. Since the answer can be huge,...
null
Dynamic Programming
Hard
null
6
another day another problem so let's Solve IT hello guys I hope everything is going well for you all so today's this video we're gonna solve the problems exact conversion I think this problem it's not likable by people as we can see that they have like 10K dislike so we're gonna solve it uh so let's read the problem th...
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
1,921
Hi Everyone Welcome Back To A New Video In This Video We Are Going To Solve A Question Name Eliminate Maximum Number Of Monsters Which Is A Medium Level Question Now Lets See The Problem Description We Have Been Given Two Array Namely Distance Array And Speed ​​Array Distance Array And Speed ​​Array Distance Array And ...
Eliminate Maximum Number of Monsters
eliminate-maximum-number-of-monsters
You are playing a video game where you are defending your city from a group of `n` monsters. You are given a **0-indexed** integer array `dist` of size `n`, where `dist[i]` is the **initial distance** in kilometers of the `ith` monster from the city. The monsters walk toward the city at a **constant** speed. The speed...
null
null
Medium
null
1,762
hello everyone today we're going to do buildings with an ocean view which is lead code problem 762 this problem holds a place in my heart since I live in San Diego and I wish I had a building an apartment with an ocean view anyway it's a medium problem stating there are n buildings in a line you are given an integer ar...
Buildings With an Ocean View
furthest-building-you-can-reach
There are `n` buildings in a line. You are given an integer array `heights` of size `n` that represents the heights of the buildings in the line. The ocean is to the right of the buildings. A building has an ocean view if the building can see the ocean without obstructions. Formally, a building has an ocean view if al...
Assume the problem is to check whether you can reach the last building or not. You'll have to do a set of jumps, and choose for each one whether to do it using a ladder or bricks. It's always optimal to use ladders in the largest jumps. Iterate on the buildings, maintaining the largest r jumps and the sum of the remain...
Array,Greedy,Heap (Priority Queue)
Medium
null
7
good morning my name is Alan singana in today's video I'll be explaining you the solution to the lead code number seven with the title reverse integer it is a medium difficulty level question and says that given a 32bit signed integer X return x with its digits reversed if reversing X causing the value to go outside th...
Reverse Integer
reverse-integer
Given a signed 32-bit integer `x`, return `x` _with its digits reversed_. If reversing `x` causes the value to go outside the signed 32-bit integer range `[-231, 231 - 1]`, then return `0`. **Assume the environment does not allow you to store 64-bit integers (signed or unsigned).** **Example 1:** **Input:** x = 123 ...
null
Math
Medium
8,190,2238
225
It has happened that most of the time you guys will be good and having fun, you are healthy till now we are on this side because then we put a lot of questions in it to make sure that the person who understood the whole thing was the one who explained the most the basic concepts like why is the lift stopped and what ha...
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
129
Hello Welcome Reaction Record Broken In To-Do List Ko Baikuntha Problem In To-Do List Ko Baikuntha Problem In To-Do List Ko Baikuntha Problem Loot-Loot Rule No Ki Return Total Arm Hole Paluto Note 5a Ek Photo Pal Ji Deep Wound De Koi Man Prabhat Ki Vid Vasundhara id porn in loot voice straight thread on its side left s...
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
991
Hello hello everyone welcome back to my channel short today introduce bhaiya on naad problem 51535 so please like share subscribe my channel get bell icon to notify members whenever possible so without any further delay started problem is broken calculator a pro content creator rathore day Teacher Start Value 19 Displa...
Broken Calculator
array-of-doubled-pairs
There is a broken calculator that has the integer `startValue` on its display initially. In one operation, you can: * multiply the number on display by `2`, or * subtract `1` from the number on display. Given two integers `startValue` and `target`, return _the minimum number of operations needed to display_ `targ...
null
Array,Hash Table,Greedy,Sorting
Medium
2117
107
hey guys welcome back to my channel and i'm back again with another really interesting coding in today guys we are going to solve question number 107 binary tree level orders reversal part 2. before i start the video guys just want to request you that if you have not yet subscribed to my channel then please do subscrib...
Binary Tree Level Order Traversal II
binary-tree-level-order-traversal-ii
Given the `root` of a binary tree, return _the bottom-up level order traversal of its nodes' values_. (i.e., from left to right, level by level from leaf to root). **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[\[15,7\],\[9,20\],\[3\]\] **Example 2:** **Input:** root = \[1\] **Output:** \[...
null
Tree,Breadth-First Search,Binary Tree
Medium
102,637
21
given two sorted linked list hulk' merge given two sorted linked list hulk' merge given two sorted linked list hulk' merge them into one sync result a linked list and return the new hat that's today's video let's get into it why my name is Steve today we are going through a little problem 21 merged two sorted lists let...
Merge Two Sorted Lists
merge-two-sorted-lists
You are given the heads of two sorted linked lists `list1` and `list2`. Merge the two lists in a one **sorted** list. The list should be made by splicing together the nodes of the first two lists. Return _the head of the merged linked list_. **Example 1:** **Input:** list1 = \[1,2,4\], list2 = \[1,3,4\] **Output:**...
null
Linked List,Recursion
Easy
23,88,148,244,1774,2071
318
welcome to mazelico challenge today's problem is maximum product of word lengths given a string array words return the maximum value of length words i times length words j where two words do not share common letters if no such two words exist return zero so this is the key here we need to figure out how do we figure ou...
Maximum Product of Word Lengths
maximum-product-of-word-lengths
Given a string array `words`, return _the maximum value of_ `length(word[i]) * length(word[j])` _where the two words do not share common letters_. If no such two words exist, return `0`. **Example 1:** **Input:** words = \[ "abcw ", "baz ", "foo ", "bar ", "xtfn ", "abcdef "\] **Output:** 16 **Explanation:** The two ...
null
Array,String,Bit Manipulation
Medium
null
48
hello everybody so in this video we will be looking at the lead code problem 48 that is rotate image so the problem statement states that we will be given a matrix 2d matrix of size n cross n so we'll have n cross n matrix and what we have to do is that is representing an image and we have to rotate this matrix by 90 d...
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
199
hey guys and welcome back to the cracking fang youtube channel today we're going to be solving lead code problem 199 binary tree right side view let's read the prompt given the root of a binary tree imagine yourself standing on the right side of it return the values of the nodes you can see ordered from top to bottom s...
Binary Tree Right Side View
binary-tree-right-side-view
Given the `root` of a binary tree, imagine yourself standing on the **right side** of it, return _the values of the nodes you can see ordered from top to bottom_. **Example 1:** **Input:** root = \[1,2,3,null,5,null,4\] **Output:** \[1,3,4\] **Example 2:** **Input:** root = \[1,null,3\] **Output:** \[1,3\] **Examp...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Medium
116,545
1,942
so hello everyone welcome to this new video and in this video i will be solving the problem 1942 the number of the smallest unoccupied chair so this problem is not that difficult uh all you have to do is sorting so first we will just understand how to approach this problem and uh then we will quote it so one thing i ho...
The Number of the Smallest Unoccupied Chair
primary-department-for-each-employee
There is a party where `n` friends numbered from `0` to `n - 1` are attending. There is an **infinite** number of chairs in this party that are numbered from `0` to `infinity`. When a friend arrives at the party, they sit on the unoccupied chair with the **smallest number**. * For example, if chairs `0`, `1`, and `5...
null
Database
Easy
null
1,021
hello guys in this video I will solve remove outermost parenthesis problem from weed code so in this problem we are given a string of balanced parentheses and we need to remove outermost parenthesis from the string so what does that mean we need to remove brackets whose level is one whose depth is one so what I mean by...
Remove Outermost Parentheses
distribute-coins-in-binary-tree
A valid parentheses string is either empty `" "`, `"( " + A + ") "`, or `A + B`, where `A` and `B` are valid parentheses strings, and `+` represents string concatenation. * For example, `" "`, `"() "`, `"(())() "`, and `"(()(())) "` are all valid parentheses strings. A valid parentheses string `s` is primitive if i...
null
Tree,Depth-First Search,Binary Tree
Medium
863,1008
1,838
hi today we're going to be going over the Java solution for lead code 1838 frequency of the most frequent element the frequency of an element is the number of times it occurs in an array you are given an integer array norms and an integer K in one operation you can choose an index of nums and increment the element by a...
Frequency of the Most Frequent Element
number-of-distinct-substrings-in-a-string
The **frequency** of an element is the number of times it occurs in an array. You are given an integer array `nums` and an integer `k`. In one operation, you can choose an index of `nums` and increment the element at that index by `1`. Return _the **maximum possible frequency** of an element after performing **at mos...
Calculate the prefix hashing array for s. Use the prefix hashing array to calculate the hashing value of each substring. Compare the hashing values to determine the unique substrings. There could be collisions if you use hashing, what about double hashing.
String,Trie,Rolling Hash,Suffix Array,Hash Function
Medium
null
746
so lead code problem of the day and here's the runtime error brings a solution for you just in case if you're new to our Channel I highly recommend you to subscribe the channel to get the daily updates on lead code Solutions so let's start with today's question that is minimum cost climbing stairs I'm going to solve th...
Min Cost Climbing Stairs
prefix-and-suffix-search
You are given an integer array `cost` where `cost[i]` is the cost of `ith` step on a staircase. Once you pay the cost, you can either climb one or two steps. You can either start from the step with index `0`, or the step with index `1`. Return _the minimum cost to reach the top of the floor_. **Example 1:** **Input...
For a word like "test", consider "#test", "t#test", "st#test", "est#test", "test#test". Then if we have a query like prefix = "te", suffix = "t", we can find it by searching for something we've inserted starting with "t#te".
String,Design,Trie
Hard
211
1,870
hey guys in today's video we are going to solve one more lead quote question that is minimum speed to arrive on time so in this question we are given a array with distance values and a variable r with the given time so let's see what I meant by this so let's say if I am standing here this is point d and I have to go to...
Minimum Speed to Arrive on Time
minimum-speed-to-arrive-on-time
You are given a floating-point number `hour`, representing the amount of time you have to reach the office. To commute to the office, you must take `n` trains in sequential order. You are also given an integer array `dist` of length `n`, where `dist[i]` describes the distance (in kilometers) of the `ith` train ride. E...
null
null
Medium
null
100
foreign q and we have to 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 so in example one here we have the root of one so this is our p and this are q and for the left and right children we have basicall...
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
540
hey yo what's up my little coders let's solve the delete called question 540 single element in assorted array basically we just need to find a single element inside the input array and the conditions are every element appears exactly twice inside this array with exception for one element which is single and appears onl...
Single Element in a Sorted Array
single-element-in-a-sorted-array
You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Return _the single element that appears only once_. Your solution must run in `O(log n)` time and `O(1)` space. **Example 1:** **Input:** nums = \[1,1,2,3,3,4,4,8,8\...
null
Array,Binary Search
Medium
null
1,696
so hello everyone today we will solve today's daily challenge problem jump game six problem statement is you are given zero index to 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 ca...
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
35
hey everybody this is Larry this is day 20 of the leeco daily challenge I didn't I did a weekly ones right hit the like button hit the Subscribe button join me on Discord let me know oh let me know what you think about today's Farm but as you can see on my screen maybe on the upper left side is unbox surprise you click...
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
810
And Hear That Shahrukh Mode Game Surya Given Udayveer Business High Pay And Square Pieces Airplane And So Will Have To Race The State Of The Game Of Tennis Players At Seervi Recommended For The Element Switch To Editor Mode Loda Player Beans OK White Plane I'm Starting Cream And Its Values Already 0 Mein Roke The A Pai...
Chalkboard XOR Game
valid-tic-tac-toe-state
You are given an array of integers `nums` represents the numbers written on a chalkboard. Alice and Bob take turns erasing exactly one number from the chalkboard, with Alice starting first. If erasing a number causes the bitwise XOR of all the elements of the chalkboard to become `0`, then that player loses. The bitwi...
null
Array,String
Medium
348
923
Hello Hi Guys Welcome To Your Decisions Made Easy In This Video Will See The Question Sambalpur City Governor John Is The Number Of subscribe to the Page if you liked The Video then subscribe to the Page A Drama Entries and 10 Questions Lord Saturn in Numbers Dreams from 0210 and tagged between more than firing from co...
3Sum With Multiplicity
super-egg-drop
Given an integer array `arr`, and an integer `target`, return the number of tuples `i, j, k` such that `i < j < k` and `arr[i] + arr[j] + arr[k] == target`. As the answer can be very large, return it **modulo** `109 + 7`. **Example 1:** **Input:** arr = \[1,1,2,2,3,3,4,4,5,5\], target = 8 **Output:** 20 **Explanatio...
null
Math,Binary Search,Dynamic Programming
Hard
2031
1,425
hello everyone welcome back here is vamson with another live cing session uh so today we have an exciting challenge that will test our problem solving skill and python uh expertise so let's Dive Right In uh today challenge is called uh constraint a subsequence sum uh 1,425 from daily lead coach challenges 1,425 from da...
Constrained Subsequence Sum
weather-type-in-each-country
Given an integer array `nums` and an integer `k`, return the maximum sum of a **non-empty** subsequence of that array such that for every two **consecutive** integers in the subsequence, `nums[i]` and `nums[j]`, where `i < j`, the condition `j - i <= k` is satisfied. A _subsequence_ of an array is obtained by deleting...
null
Database
Easy
null
1,887
hey everybody this is larry this is me going with q2 of the weekly contest 244 reduction operators to make arrays element uh equal so the key thing to know about this is just observing that for each number and they don't have to be unique it goes to the next number and then now you effectively reduce this problem into ...
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
1,675
Peace be upon you, my dear friend. How are you doing? O Lord, you will be fine and in the best condition. God willing, today we will solve it together. If you have not solved the issue, you must first go and solve the issue before you come to watch the video. We will try it once, twice, and three times, and God willing...
Minimize Deviation in Array
magnetic-force-between-two-balls
You are given an array `nums` of `n` positive integers. You can perform two types of operations on any element of the array any number of times: * If the element is **even**, **divide** it by `2`. * For example, if the array is `[1,2,3,4]`, then you can do this operation on the last element, and the array wil...
If you can place balls such that the answer is x then you can do it for y where y < x. Similarly if you cannot place balls such that the answer is x then you can do it for y where y > x. Binary search on the answer and greedily see if it is possible.
Array,Binary Search,Sorting
Medium
2188
54
hey guys welcome to one more video in this video we'll talk about spiral matrix problem uh actually in last six months this problem is asked by microsoft multiple times along with amazon and facebook so this is a quite a popular problem uh and this is an interesting problem because it doesn't require any complex data s...
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
502
hi guys today we'll talk about our next two heap coding pattern related question this question i don't go and read out all the description what was being said but i will go to the input and i will explain what it was asking about so we have some number of projects and to start any project we require capital at index 0 ...
IPO
ipo
Suppose LeetCode will start its **IPO** soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the **IPO**. Since it has limited resources, it can only finish at most `k` distinct projects before the **IPO**. Help LeetCode design...
null
Array,Greedy,Sorting,Heap (Priority Queue)
Hard
null
843
alright I'll guess I'll start so this problem was suggested by somebody on the discord Channel so I figured I would take a stab at solving this so before I start I just want to let people know that there's no guarantee that I will be getting the perfect solution or the best solution I think the objective of doing these...
Guess the Word
binary-trees-with-factors
You are given an array of unique strings `words` where `words[i]` is six letters long. One word of `words` was chosen as a secret word. You are also given the helper object `Master`. You may call `Master.guess(word)` where `word` is a six-letter-long string, and it must be from `words`. `Master.guess(word)` returns: ...
null
Array,Hash Table,Dynamic Programming
Medium
null
1,046
lead code problem number 10,46 last stone weight so this problem 10,46 last stone weight so this problem 10,46 last stone weight so this problem gives us an array of integers Stones where the stones ey is the weight of the stone all right okay so on each Turn You will choose the heaviest two stones smash them together ...
Last Stone Weight
max-consecutive-ones-iii
You are given an array of integers `stones` where `stones[i]` is the weight of the `ith` stone. We are playing a game with the stones. On each turn, we choose the **heaviest two stones** and smash them together. Suppose the heaviest two stones have weights `x` and `y` with `x <= y`. The result of this smash is: * I...
One thing's for sure, we will only flip a zero if it extends an existing window of 1s. Otherwise, there's no point in doing it, right? Think Sliding Window! Since we know this problem can be solved using the sliding window construct, we might as well focus in that direction for hints. Basically, in a given window, we c...
Array,Binary Search,Sliding Window,Prefix Sum
Medium
340,424,485,487,2134
645
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 set mismatch so the question says that we have a set of integers s which originally contains all the numbers starting from the range 1 through n so n is the length of the array and unfortunately due to ...
Set Mismatch
set-mismatch
You have a set of integers `s`, which originally contains all the numbers from `1` to `n`. Unfortunately, due to some error, one of the numbers in `s` got duplicated to another number in the set, which results in **repetition of one** number and **loss of another** number. You are given an integer array `nums` represe...
null
Array,Hash Table,Bit Manipulation,Sorting
Easy
287
146
hi this is kevin and you're watching google engineer explains uh today we're going to be talking about leak code 146 lru cache let's dive in all right first off before we talk about this problem too much let's talk about what a cache is okay and i thought of a good uh example that can help illustrate what is a cache so...
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
1,721
hello everyone welcome back so today we are going to solve the problem of lead code after a gap of one week i guess so the problem we are going to solve today is related to a linked list so the common name is wrapping nodes in a linked list let's go through the problem once you are given the head of a linked list and i...
Swapping Nodes in a Linked List
maximum-profit-of-operating-a-centennial-wheel
You are given the `head` of a linked list, and an integer `k`. Return _the head of the linked list after **swapping** the values of the_ `kth` _node from the beginning and the_ `kth` _node from the end (the list is **1-indexed**)._ **Example 1:** **Input:** head = \[1,2,3,4,5\], k = 2 **Output:** \[1,4,3,2,5\] **Ex...
Think simulation Note that the number of turns will never be more than 50 / 4 * n
Array,Simulation
Medium
null
708
okay so lead code practice time so in this video two things first one is uh to see how to solve this problem and then we are going to put some solid code in and then another thing is to see how to solve this problem during interview so let's get started so the first step is to understand the problem and try to ask some...
Insert into a Sorted Circular Linked List
insert-into-a-sorted-circular-linked-list
Given a Circular Linked List node, which is sorted in non-descending order, write a function to insert a value `insertVal` into the list such that it remains a sorted circular list. The given node can be a reference to any single node in the list and may not necessarily be the smallest value in the circular list. If t...
null
null
Medium
null
1,380
hello everyone it's really good to see you here so today we are going to solve a leaked good problem which is lucky number in a matrix so the problem statement goes like a lucky number is an element of the matrix such that it is a it is the minimum element in its row and maximum in its column so basically let's see it ...
Lucky Numbers in a Matrix
number-of-closed-islands
Given an `m x n` matrix of **distinct** numbers, return _all **lucky numbers** in the matrix in **any** order_. A **lucky number** is an element of the matrix such that it is the minimum element in its row and maximum in its column. **Example 1:** **Input:** matrix = \[\[3,7,8\],\[9,11,13\],\[15,16,17\]\] **Output:*...
Exclude connected group of 0s on the corners because they are not closed island. Return number of connected component of 0s on the grid.
Array,Depth-First Search,Breadth-First Search,Union Find,Matrix
Medium
null
1,970
hello guys welcome back to the channel today we are solving another leadport problem that is 1970 last day where you can still cross before jumping into the solution I would highly recommend you should read the problem statement on your own and give at least 15 to 30 minutes to this problem so let's get right into it w...
Last Day Where You Can Still Cross
sorting-the-sentence
There is a **1-based** binary matrix where `0` represents land and `1` represents water. You are given integers `row` and `col` representing the number of rows and columns in the matrix, respectively. Initially on day `0`, the **entire** matrix is **land**. However, each day a new cell becomes flooded with **water**. ...
Divide the string into the words as an array of strings Sort the words by removing the last character from each word and sorting according to it
String,Sorting
Easy
2168
952
Hello friends, today's discussion about liquid problem is 952, it is the largest computer science like commenting problem. First of all, you are given equity in which Vyas and Notes only made the application which also has mushrooms in the. The value of notification is fine, what is it? Know that you have the graph and...
Largest Component Size by Common Factor
word-subsets
You are given an integer array of unique positive integers `nums`. Consider the following graph: * There are `nums.length` nodes, labeled `nums[0]` to `nums[nums.length - 1]`, * There is an undirected edge between `nums[i]` and `nums[j]` if `nums[i]` and `nums[j]` share a common factor greater than `1`. Return _t...
null
Array,Hash Table,String
Medium
null
30
hello everyone welcome to coding decoded my name is anthony today i'm working as technical architect at adobe and first of all i would like to congratulate all the subscribers of coding decoded that we have reached a big milestone of 10 000 subscribers a special video is in process i'll be sharing a thank you note with...
Substring with Concatenation of All Words
substring-with-concatenation-of-all-words
You are given a string `s` and an array of strings `words`. All the strings of `words` are of **the same length**. A **concatenated substring** in `s` is a substring that contains all the strings of any permutation of `words` concatenated. * For example, if `words = [ "ab ", "cd ", "ef "]`, then `"abcdef "`, `"abef...
null
Hash Table,String,Sliding Window
Hard
76
264
hello everyone and welcome to my channel this channel is all about Cody here you will see detailed explanations on data structures and algorithms you will also learn how to solve coding interview questions by diving deep into the logic and intuition behind it and before moving further you might also want to click on th...
Ugly Number II
ugly-number-ii
An **ugly number** is a positive integer whose prime factors are limited to `2`, `3`, and `5`. Given an integer `n`, return _the_ `nth` _**ugly number**_. **Example 1:** **Input:** n = 10 **Output:** 12 **Explanation:** \[1, 2, 3, 4, 5, 6, 8, 9, 10, 12\] is the sequence of the first 10 ugly numbers. **Example 2:** ...
The naive approach is to call isUgly for every number until you reach the nth one. Most numbers are not ugly. Try to focus your effort on generating only the ugly ones. An ugly number must be multiplied by either 2, 3, or 5 from a smaller ugly number. The key is how to maintain the order of the ugly numbers. Try a simi...
Hash Table,Math,Dynamic Programming,Heap (Priority Queue)
Medium
23,204,263,279,313,1307
200
all right so let's take a look at this problem this one is called number of islands given an m by n 2d binary grid which represents a map of ones which are the land and zeros which are water return the number of islands an island is surrounded by water and is formed by connecting adjacent lands horizontally or vertical...
Number of Islands
number-of-islands
Given an `m x n` 2D binary grid `grid` which represents a map of `'1'`s (land) and `'0'`s (water), return _the number of islands_. An **island** is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. **Exampl...
null
Array,Depth-First Search,Breadth-First Search,Union Find,Matrix
Medium
130,286,305,323,694,695,2035,2103
92
hey everybody this is larry this is day 23 of the june eco daily challenge hit the like button hit the subscribe button join me on discord let me know what you think about today's one reverse linked list too so i usually solve this live so if it's a little bit slow on the explanation or whatever watch it on 2x whatever...
Reverse Linked List II
reverse-linked-list-ii
Given the `head` of a singly linked list and two integers `left` and `right` where `left <= right`, reverse the nodes of the list from position `left` to position `right`, and return _the reversed list_. **Example 1:** **Input:** head = \[1,2,3,4,5\], left = 2, right = 4 **Output:** \[1,4,3,2,5\] **Example 2:** **I...
null
Linked List
Medium
206
1,750
hey there everyone welcome back to lead coding so this is the contest bi-weekly coding so this is the contest bi-weekly coding so this is the contest bi-weekly contest 45 and this is the problem number three of the contest so let us see what the problem statement is saying we are given a string consisting of a b and c ...
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
153
hello everyone it's really good to see you here so today we are going to solve a liquid problem which is find minimum in rotated sorted array so what we have given here we have given an array which is actually rotated and is it in a sorted order form and what we have to do is we have to find the minimum element inside ...
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
70
hey what's up everyone in this video we are going to solve a very easy to understand problem that is available on lead code the simplicity of this problem makes it a very good candidate for anybody who wants to learn dynamic programming and is just getting started and because it is a beginner friendly problem i have ch...
Climbing Stairs
climbing-stairs
You are climbing a staircase. It takes `n` steps to reach the top. Each time you can either climb `1` or `2` steps. In how many distinct ways can you climb to the top? **Example 1:** **Input:** n = 2 **Output:** 2 **Explanation:** There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps **Example 2:** ...
To reach nth step, what could have been your previous steps? (Think about the step sizes)
Math,Dynamic Programming,Memoization
Easy
747,1013,1236
524
hello guys uh and welcome back to my channel so today we will be solving the lead code day 22 challenge uh which says the that is the longest word in the dictionary through deleting so we have been given a string and a string dictionary and we want to find the longest string in the dictionary that can be formed by dele...
Longest Word in Dictionary through Deleting
longest-word-in-dictionary-through-deleting
Given a string `s` and a string array `dictionary`, return _the longest string in the dictionary that can be formed by deleting some of the given string characters_. If there is more than one possible result, return the longest word with the smallest lexicographical order. If there is no possible result, return the emp...
null
Array,Two Pointers,String,Sorting
Medium
720
818
all right eight one eight race cars so we have a car that starts at position zero and it has a speed of one and it has we can give our car two instructions so the two instructions are accelerate if we give an accelerator instruction it will increase our position by our speed and then we'll double our speed here and if ...
Race Car
similar-rgb-color
Your car starts at position `0` and speed `+1` on an infinite number line. Your car can go into negative positions. Your car drives automatically according to a sequence of instructions `'A'` (accelerate) and `'R'` (reverse): * When you get an instruction `'A'`, your car does the following: * `position += spee...
null
Math,String,Enumeration
Easy
null
383
hey guys let's take a look of uh liquid question number 383 ransom notes first of all we need to understand the concept of ransom note what is that what is ransom notes um let's take in take a look at this picture ransom note actually it's just like they're trying to make a note and using words or letters cutting rando...
Ransom Note
ransom-note
Given two strings `ransomNote` and `magazine`, return `true` _if_ `ransomNote` _can be constructed by using the letters from_ `magazine` _and_ `false` _otherwise_. Each letter in `magazine` can only be used once in `ransomNote`. **Example 1:** **Input:** ransomNote = "a", magazine = "b" **Output:** false **Example ...
null
Hash Table,String,Counting
Easy
691
419
welcome back everyone we're gonna be solving Lee code 419 battleships and a board so this problem is pretty much the exact same as the number of islands problem except instead of ones and zeros we're dealing with x's and dots um so essentially same thing as number of islands if you've watched that video before if you h...
Battleships in a Board
battleships-in-a-board
Given an `m x n` matrix `board` where each cell is a battleship `'X'` or empty `'.'`, return _the number of the **battleships** on_ `board`. **Battleships** can only be placed horizontally or vertically on `board`. In other words, they can only be made of the shape `1 x k` (`1` row, `k` columns) or `k x 1` (`k` rows, ...
null
Array,Depth-First Search,Matrix
Medium
null
1,839
hi welcome I'd like to address leak code number 1839 longest substring of all vowels in order uh this problem essentially proposes a classification of substrings that it's calling beautiful and a substring is beautiful if uh basically two constraints are met the first is that all vowels are essentially contained in a s...
Longest Substring Of All Vowels in Order
decode-xored-array
A string is considered **beautiful** if it satisfies the following conditions: * Each of the 5 English vowels (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`) must appear **at least once** in it. * The letters must be sorted in **alphabetical order** (i.e. all `'a'`s before `'e'`s, all `'e'`s before `'i'`s, etc.). For example...
Since that encoded[i] = arr[i] XOR arr[i+1], then arr[i+1] = encoded[i] XOR arr[i]. Iterate on i from beginning to end, and set arr[i+1] = encoded[i] XOR arr[i].
Array,Bit Manipulation
Easy
null
1,929
in this video we will solve another simple problem from arrays and this is taken from our lead code and the problem number is 1929 and it's called concatenation of array so the problem says you are given an integer array and its name is in nums and its length is n and you want to create a resulting array let's say ans ...
Concatenation of Array
maximum-value-at-a-given-index-in-a-bounded-array
Given an integer array `nums` of length `n`, you want to create an array `ans` of length `2n` where `ans[i] == nums[i]` and `ans[i + n] == nums[i]` for `0 <= i < n` (**0-indexed**). Specifically, `ans` is the **concatenation** of two `nums` arrays. Return _the array_ `ans`. **Example 1:** **Input:** nums = \[1,2,1\...
What if the problem was instead determining if you could generate a valid array with nums[index] == target? To generate the array, set nums[index] to target, nums[index-i] to target-i, and nums[index+i] to target-i. Then, this will give the minimum possible sum, so check if the sum is less than or equal to maxSum. n is...
Binary Search,Greedy
Medium
null
443
So hey guys welcome back to our new video a this next video on strings to lead code 443 question is string compression and just we will read the question and just we will know how many approaches are there to solve this problem and just let's Read the question T is given an array of character compress it using followin...
String Compression
string-compression
Given an array of characters `chars`, compress it using the following algorithm: Begin with an empty string `s`. For each group of **consecutive repeating characters** in `chars`: * If the group's length is `1`, append the character to `s`. * Otherwise, append the character followed by the group's length. The co...
How do you know if you are at the end of a consecutive group of characters?
Two Pointers,String
Medium
38,271,604,1241
589
this is lead code question 589 and re3 free order traversal so we have a tree like this and we need to run a pre-order traversal on that street and a pre-order traversal on that street and a pre-order traversal on that street and return the values in a vector of integers so this is not a binary trade if you look at the...
N-ary Tree Preorder Traversal
n-ary-tree-preorder-traversal
Given the `root` of an n-ary tree, return _the preorder traversal of its nodes' values_. Nary-Tree input serialization is represented in their level order traversal. Each group of children is separated by the null value (See examples) **Example 1:** **Input:** root = \[1,null,3,2,4,null,5,6\] **Output:** \[1,3,5,6,2...
null
null
Easy
null
377
Hello everyone welcome to my channel court sorry with mike so today we are going to do video number 10 of our back tracking playlist ok lead code number 377 is medium market but is it not at all in medium it is quite easy with the family template of back tracking Will make this and will make it with two sends. Both are...
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
2,000
hello everyone welcome to my Channel today we have another problem to solve here um imagine we have a special word and a special letter our job is to flip the beginning of the word up to the first time we find our special letter let's look at some example to better understand the question so if our word is AB c d e f d...
Reverse Prefix of Word
minimum-speed-to-arrive-on-time
Given a **0-indexed** string `word` and a character `ch`, **reverse** the segment of `word` that starts at index `0` and ends at the index of the **first occurrence** of `ch` (**inclusive**). If the character `ch` does not exist in `word`, do nothing. * For example, if `word = "abcdefd "` and `ch = "d "`, then you s...
Given the speed the trains are traveling at, can you find the total time it takes for you to arrive? Is there a cutoff where any speeds larger will always allow you to arrive on time?
Array,Binary Search
Medium
1335,2013,2294
859
welcome to october's leeco challenge today's problem is buddy strings given two strings of lower case letters return true if you can swap two letters in a so that the result is equal to b otherwise return false now swapping letters is defined as taking two indices such that i does not equal j and swapping the character...
Buddy Strings
design-circular-deque
Given two strings `s` and `goal`, return `true` _if you can swap two letters in_ `s` _so the result is equal to_ `goal`_, otherwise, return_ `false`_._ Swapping letters is defined as taking two indices `i` and `j` (0-indexed) such that `i != j` and swapping the characters at `s[i]` and `s[j]`. * For example, swappi...
null
Array,Linked List,Design,Queue
Medium
860,1767
338
hello everyone welcome to the channel today's question is counting bits if you are new to the channel please consider subscribing we sold a lot of into question on this channel and that can definitely help you with your interview the question says given a non-negative the question says given a non-negative the question...
Counting Bits
counting-bits
Given an integer `n`, return _an array_ `ans` _of length_ `n + 1` _such that for each_ `i` (`0 <= i <= n`)_,_ `ans[i]` _is the **number of**_ `1`_**'s** in the binary representation of_ `i`. **Example 1:** **Input:** n = 2 **Output:** \[0,1,1\] **Explanation:** 0 --> 0 1 --> 1 2 --> 10 **Example 2:** **Input:** n =...
You should make use of what you have produced already. Divide the numbers in ranges like [2-3], [4-7], [8-15] and so on. And try to generate new range from previous. Or does the odd/even status of the number help you in calculating the number of 1s?
Dynamic Programming,Bit Manipulation
Easy
191
1,559
hey guys today we're going to solve lead code number 1559 detect cycles in 2d grid so we're given a grid of characters just like this and we need to find if there is a cycle where both these cells have the same value and the cycle length needs to be at least four so the way we're going to do this is recursively through...
Detect Cycles in 2D Grid
cherry-pickup-ii
Given a 2D array of characters `grid` of size `m x n`, you need to find if there exists any cycle consisting of the **same value** in `grid`. A cycle is a path of **length 4 or more** in the grid that starts and ends at the same cell. From a given cell, you can move to one of the cells adjacent to it - in one of the f...
Use dynammic programming, define DP[i][j][k]: The maximum cherries that both robots can take starting on the ith row, and column j and k of Robot 1 and 2 respectively.
Array,Dynamic Programming,Matrix
Hard
null
1,680
everyone welcome to the 27th of january's equal challenge and today's question is concatenation of consecutive binary numbers in this question you're given an integer n and you need to generate a new number uh by con that is formed by concatenating the binary representation of all the numbers starting from 1 up to n al...
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,603
hello everyone and welcome to another short video on solving uh a elite code problem with apl and i have to start by apologizing because the idea of these videos at least for me is to solve these problems for the first time in apl with you and hopefully that shows you a little bit of how thinking in apl might look like...
Design Parking System
running-sum-of-1d-array
Design a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for each size. Implement the `ParkingSystem` class: * `ParkingSystem(int big, int medium, int small)` Initializes object of the `ParkingSystem` class. The number of slot...
Think about how we can calculate the i-th number in the running sum from the (i-1)-th number.
Array,Prefix Sum
Easy
null
23
Hello guys welcome back to take use this video will see the match shot at least problem Vismrit ko number-23 so in this problem will be doing problem Vismrit ko number-23 so in this problem will be doing problem Vismrit ko number-23 so in this problem will be doing good fiber process in order to solve this problem so l...
Merge k Sorted Lists
merge-k-sorted-lists
You are given an array of `k` linked-lists `lists`, each linked-list is sorted in ascending order. _Merge all the linked-lists into one sorted linked-list and return it._ **Example 1:** **Input:** lists = \[\[1,4,5\],\[1,3,4\],\[2,6\]\] **Output:** \[1,1,2,3,4,4,5,6\] **Explanation:** The linked-lists are: \[ 1->4...
null
Linked List,Divide and Conquer,Heap (Priority Queue),Merge Sort
Hard
21,264
1,758
hello and welcome to another video in this video we're going to be working on minimum changes to make alternating binary string and in the problem you're given a string and you want to figure out how many operations you need to make it alternating meaning you don't have zeros next to zeros and ones next to ones so in t...
Minimum Changes To Make Alternating Binary String
distribute-repeating-integers
You are given a string `s` consisting only of the characters `'0'` and `'1'`. In one operation, you can change any `'0'` to `'1'` or vice versa. The string is called alternating if no two adjacent characters are equal. For example, the string `"010 "` is alternating, while the string `"0100 "` is not. Return _the **m...
Count the frequencies of each number. For example, if nums = [4,4,5,5,5], frequencies = [2,3]. Each customer wants all of their numbers to be the same. This means that each customer will be assigned to one number. Use dynamic programming. Iterate through the numbers' frequencies, and choose some subset of customers to ...
Array,Dynamic Programming,Backtracking,Bit Manipulation,Bitmask
Hard
null
77
hi guys today let's discuss the lead code question 77 combinations given two integers n and K written all possible combinations of K numbers chosen from the range 1 to n you may return the answer in any order yeah let's go to the example one the input n is equal 4 and K is equal 2 so when n is equal to 4 and K is equal...
Combinations
combinations
Given two integers `n` and `k`, return _all possible combinations of_ `k` _numbers chosen from the range_ `[1, n]`. You may return the answer in **any order**. **Example 1:** **Input:** n = 4, k = 2 **Output:** \[\[1,2\],\[1,3\],\[1,4\],\[2,3\],\[2,4\],\[3,4\]\] **Explanation:** There are 4 choose 2 = 6 total combin...
null
Backtracking
Medium
39,46
1,455
Hai Hydro Suryavanshi Question Check It's Lord Curzon Chiffon Is This Sentence Subscribe Must Subscribe Sentence In this sentence you have to tell that if you do it in the beginning, get married Jiya Raghbir and share and subscribe If you were sending a text message, then I am giving the answer There were tumors, this ...
Check If a Word Occurs As a Prefix of Any Word in a Sentence
filter-restaurants-by-vegan-friendly-price-and-distance
Given a `sentence` that consists of some words separated by a **single space**, and a `searchWord`, check if `searchWord` is a prefix of any word in `sentence`. Return _the index of the word in_ `sentence` _(**1-indexed**) where_ `searchWord` _is a prefix of this word_. If `searchWord` is a prefix of more than one wor...
Do the filtering and sort as said. Note that the id may not be the index in the array.
Array,Sorting
Medium
null
120
hey so welcome back and this is another daily good problem so today it's called triangle it's a medium level dynamic programming problem and so let's get started here so essentially you're just given a two-dimensional Matrix two-dimensional Matrix two-dimensional Matrix um but it's actually interesting where the uh bas...
Triangle
triangle
Given a `triangle` array, return _the minimum path sum from top to bottom_. For each step, you may move to an adjacent number of the row below. More formally, if you are on index `i` on the current row, you may move to either index `i` or index `i + 1` on the next row. **Example 1:** **Input:** triangle = \[\[2\],\[...
null
Array,Dynamic Programming
Medium
null
1,701
so lead code 1701 average waiting time so you're the chef of a restaurant and you're given an array of customers in order of their arrival at the restaurant and as soon as the customer arrives they give you their order and you're given the time of arrival and the time that it takes to prepare the order of the current c...
Average Waiting Time
remove-max-number-of-edges-to-keep-graph-fully-traversable
There is a restaurant with a single chef. You are given an array `customers`, where `customers[i] = [arrivali, timei]:` * `arrivali` is the arrival time of the `ith` customer. The arrival times are sorted in **non-decreasing** order. * `timei` is the time needed to prepare the order of the `ith` customer. When a ...
Build the network instead of removing extra edges. Suppose you have the final graph (after removing extra edges). Consider the subgraph with only the edges that Alice can traverse. What structure does this subgraph have? How many edges are there? Use disjoint set union data structure for both Alice and Bob. Always use ...
Union Find,Graph
Hard
null
225
um hello so today we are going to do this problem uh from heat code called implement stack using queues um so the problem says we need to implement elastin first out stack using only two queues um and it should support all the function of a normal stack so push tab pop and empty so these functions here um and some node...
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
1,877
everyone and good afternoon to all of you today we have problem which name is minimize maximum pair some in Array lead code b877 problem so before going forward in this video please make sure that you have likeed and subscribed to this Channel and also it's my advice to all of you that please read the problem carefully...
Minimize Maximum Pair Sum in Array
find-followers-count
The **pair sum** of a pair `(a,b)` is equal to `a + b`. The **maximum pair sum** is the largest **pair sum** in a list of pairs. * For example, if we have pairs `(1,5)`, `(2,3)`, and `(4,4)`, the **maximum pair sum** would be `max(1+5, 2+3, 4+4) = max(6, 5, 8) = 8`. Given an array `nums` of **even** length `n`, pai...
null
Database
Easy
null
1,611
hey everybody this is Larry this is day 30th of the Leo day challenge hit the like button hit the Subscribe button join me on Discord let me know what you think about today's far I'm here in naha in okanawa in Japan on my last day in Japan last full day anyway so uh yeah let me know what you think about the comment che...
Minimum One Bit Operations to Make Integers Zero
making-file-names-unique
Given an integer `n`, you must transform it into `0` using the following operations any number of times: * Change the rightmost (`0th`) bit in the binary representation of `n`. * Change the `ith` bit in the binary representation of `n` if the `(i-1)th` bit is set to `1` and the `(i-2)th` through `0th` bits are set...
Keep a map of each name and the smallest valid integer that can be appended as a suffix to it. If the name is not present in the map, you can use it without adding any suffixes. If the name is present in the map, append the smallest proper suffix, and add the new name to the map.
Array,Hash Table,String
Medium
null
1,751
hey what's up guys this is john here so today uh let's take a look at this elite called problem number 1751 maximum number of events that can be attended number two so you're giving like an array event right where we have start day end day and the value so basically the ice events start at start day and end at end stag...
Maximum Number of Events That Can Be Attended II
slowest-key
You are given an array of `events` where `events[i] = [startDayi, endDayi, valuei]`. The `ith` event starts at `startDayi` and ends at `endDayi`, and if you attend this event, you will receive a value of `valuei`. You are also given an integer `k` which represents the maximum number of events you can attend. You can o...
Get for each press its key and amount of time taken. Iterate on the presses, maintaining the answer so far. The current press will change the answer if and only if its amount of time taken is longer than that of the previous answer, or they are equal but the key is larger than that of the previous answer.
Array,String
Easy
null
56
Hello friends, welcome to the new video, question number 56 is a question of Amar Jain Travels medium level. This question has been given in basic clearance category. It has been asked on Facebook, Amazon, Google, Apple, Microsoft, Payl and big companies. Let's start with this. Basically, you have been given a number o...
Merge Intervals
merge-intervals
Given an array of `intervals` where `intervals[i] = [starti, endi]`, merge all overlapping intervals, and return _an array of the non-overlapping intervals that cover all the intervals in the input_. **Example 1:** **Input:** intervals = \[\[1,3\],\[2,6\],\[8,10\],\[15,18\]\] **Output:** \[\[1,6\],\[8,10\],\[15,18\]\...
null
Array,Sorting
Medium
57,252,253,495,616,715,761,768,1028,2297,2319
1,991
1991 find the middle index in array question so we are given a zero index integer array nums find the left most middle index that is the smallest amongst all the positive ones so a middle index uh it's also given about the definition of the middle index so what is this middle index mdl index is an index were numbers of...
Find the Middle Index in Array
league-statistics
Given a **0-indexed** integer array `nums`, find the **leftmost** `middleIndex` (i.e., the smallest amongst all the possible ones). A `middleIndex` is an index where `nums[0] + nums[1] + ... + nums[middleIndex-1] == nums[middleIndex+1] + nums[middleIndex+2] + ... + nums[nums.length-1]`. If `middleIndex == 0`, the lef...
null
Database
Medium
null
1,894
Scientist A Hello Hi Guys How Are You Commission Always Doing Good Welcome To Land Co Disney Today Will Drowned Medium Able To Send A Text Festival Replace The Channel And Dont's First D' Replace The Channel And Dont's First D' Replace The Channel And Dont's First D' Souza After Alarm Is Preserved Quickly Subscribe Bel...
Find the Student that Will Replace the Chalk
merge-strings-alternately
There are `n` students in a class numbered from `0` to `n - 1`. The teacher will give each student a problem starting with the student number `0`, then the student number `1`, and so on until the teacher reaches the student number `n - 1`. After that, the teacher will restart the process, starting with the student numb...
Use two pointers, one pointer for each string. Alternately choose the character from each pointer, and move the pointer upwards.
Two Pointers,String
Easy
281
136
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 code single number so let's get started the problem is that they give us a non-empty array of integers give us a non...
Single Number
single-number
Given a **non-empty** array of integers `nums`, every element appears _twice_ except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space. **Example 1:** **Input:** nums = \[2,2,1\] **Output:** 1 **Example 2:** **Input:** nums = \[4,1,2,1,2...
null
Array,Bit Manipulation
Easy
137,260,268,287,389
61
hello everybody today i'm going to solve this problem rotate list let's read the question first given the head of a linked list rotate the list to a write by k places okay so given a linked list which is a linked list which has a node every node has a value and then a pointer to the next node and there are some integer...
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
1,478
Hello Friends Today I Will Discuss The Problems To Meet With Heart Problem And Avoiding This Video In The Problem Set Of List To Dot Problems Samay Jab Play List For To Heart From Its Front Part Is Dros Question That You Can At Least Show The Problem Name Is Allocate mil boxes to solve the problem statement from zif ho...
Allocate Mailboxes
maximum-number-of-events-that-can-be-attended
Given the array `houses` where `houses[i]` is the location of the `ith` house along a street and an integer `k`, allocate `k` mailboxes in the street. Return _the **minimum** total distance between each house and its nearest mailbox_. The test cases are generated so that the answer fits in a 32-bit integer. **Exampl...
Sort the events by the start time and in case of tie by the end time in ascending order. Loop over the sorted events. Attend as much as you can and keep the last day occupied. When you try to attend new event keep in mind the first day you can attend a new event in.
Array,Greedy,Heap (Priority Queue)
Medium
1851,2118
328
hello everyone welcome to quartus camp we are second day of december let go challenge and the problem we are going to cover in this video is odd even linked list so the input given here is ahead of a linked list which consists of odd even nodes and we have to return the reordered list in such a way that all odd indices...
Odd Even Linked List
odd-even-linked-list
Given the `head` of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return _the reordered list_. The **first** node is considered **odd**, and the **second** node is **even**, and so on. Note that the relative order inside both the even and odd groups s...
null
Linked List
Medium
725
1,385
so hi everyone let's try to solve this problem which says find distance with value between two errors so uh problem statement is something like this given two integer errors i one and two and integer distance d return the distance value between the two areas so and what is that distance value that has been defined over...
Find the Distance Value Between Two Arrays
number-of-ways-to-build-house-of-cards
Given two integer arrays `arr1` and `arr2`, and the integer `d`, _return the distance value between the two arrays_. The distance value is defined as the number of elements `arr1[i]` such that there is not any element `arr2[j]` where `|arr1[i]-arr2[j]| <= d`. **Example 1:** **Input:** arr1 = \[4,5,8\], arr2 = \[10,9...
If a row has k triangles, how many cards does it take to build that row? It takes 3 * k - 1 cards. If you still have i cards left, and on the previous row there were k triangles, what are the possible ways to build the current row? You can start at 1 triangle and continue adding more until you run out of cards or reach...
Math,Dynamic Programming
Medium
815
1,004
Hello Everyone Welcome back to my channel Saurabh is going to ask which 2130 is the problem in Domchanch, so I have added it in it, there will be amazing meaning and need, you have learned something and please tell us maximum how many positive ones will there be, so I am Alarm set clip art most cases Okay like see here...
Max Consecutive Ones III
least-operators-to-express-number
Given a binary array `nums` and an integer `k`, return _the maximum number of consecutive_ `1`_'s in the array if you can flip at most_ `k` `0`'s. **Example 1:** **Input:** nums = \[1,1,1,0,0,0,1,1,1,1,0\], k = 2 **Output:** 6 **Explanation:** \[1,1,1,0,0,**1**,1,1,1,1,**1**\] Bolded numbers were flipped from 0 to 1....
null
Math,Dynamic Programming
Hard
null
68
Hello everyone, welcome to my channel, we are going to do video number 18 of this. Lead code number 68 is hard marked but it is quite easy because in this you have to do only what is written in the question, do not put any extra mind, okay further it is this. It has been said that you do that and your time will be redu...
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
1,051
hello everyone so now we're going to solve called something called height checker it says that the school is trying to take an annual photo of all the students are standing in a non-decreasing order non-decreasing order non-decreasing order okay you are given integer array Heights representing the current order of stud...
Height Checker
shortest-way-to-form-string
A school is trying to take an annual photo of all the students. The students are asked to stand in a single file line in **non-decreasing order** by height. Let this ordering be represented by the integer array `expected` where `expected[i]` is the expected height of the `ith` student in line. You are given an integer...
Which conditions have to been met in order to be impossible to form the target string? If there exists a character in the target string which doesn't exist in the source string then it will be impossible to form the target string. Assuming we are in the case which is possible to form the target string, how can we assur...
String,Dynamic Programming,Greedy
Medium
392,808