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
1,679
everyone and welcome to another tutorial today we will solve lead code 1 1679 problem max number of K on pairs let's read the description you are given an integer array nums and an integer key in one operation you can pick two numbers from the array whose sum is equals to K and remove them from the array return maximum...
Max Number of K-Sum Pairs
shortest-subarray-to-be-removed-to-make-array-sorted
You are given an integer array `nums` and an integer `k`. In one operation, you can pick two numbers from the array whose sum equals `k` and remove them from the array. Return _the maximum number of operations you can perform on the array_. **Example 1:** **Input:** nums = \[1,2,3,4\], k = 5 **Output:** 2 **Explana...
The key is to find the longest non-decreasing subarray starting with the first element or ending with the last element, respectively. After removing some subarray, the result is the concatenation of a sorted prefix and a sorted suffix, where the last element of the prefix is smaller than the first element of the suffix...
Array,Two Pointers,Binary Search,Stack,Monotonic Stack
Medium
null
86
Hello guys welcome to the video only coding and today vrishabha problem school partition list play list the value addition notes in the loop must subscribe gold channel subscribe red color subscribe and elements from the love you to To Two And Second Elementary Upgrade From This Point Rollins And Placid Before And Afte...
Partition List
partition-list
Given the `head` of a linked list and a value `x`, partition it such that all nodes **less than** `x` come before nodes **greater than or equal** to `x`. You should **preserve** the original relative order of the nodes in each of the two partitions. **Example 1:** **Input:** head = \[1,4,3,2,5,2\], x = 3 **Output:**...
null
Linked List,Two Pointers
Medium
2265
977
hi everyone welcome to coding with Jaz so today the coding problem that we'll be looking at is squares off a sorted array so for this question you are given a sorted array in a non decreasing order and your task is to square all of the elements and then return it in a non decreasing order as well so the hard part of th...
Squares of a Sorted Array
distinct-subsequences-ii
Given an integer array `nums` sorted in **non-decreasing** order, return _an array of **the squares of each number** sorted in non-decreasing order_. **Example 1:** **Input:** nums = \[-4,-1,0,3,10\] **Output:** \[0,1,9,16,100\] **Explanation:** After squaring, the array becomes \[16,1,0,9,100\]. After sorting, it be...
null
String,Dynamic Programming
Hard
2115
1,704
Hello everyone welcome to my channel Tweet Sunny Today I am going to discuss problem determined in history and half simple like OK of solid code index numbers 1704 and problems of similar type so let's jump to the problem statement that has been given string gas Of evento 16 inches to 10 places to intervene in the spli...
Determine if String Halves Are Alike
special-positions-in-a-binary-matrix
You are given a string `s` of even length. Split this string into two halves of equal lengths, and let `a` be the first half and `b` be the second half. Two strings are **alike** if they have the same number of vowels (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`, `'A'`, `'E'`, `'I'`, `'O'`, `'U'`). Notice that `s` contains uppe...
Keep track of 1s in each row and in each column. Then while iterating over matrix, if the current position is 1 and current row as well as current column contains exactly one occurrence of 1.
Array,Matrix
Easy
null
382
hello everyone welcome or welcome back to my channel so today we are going to solve another problem but before going forward if you've not liked the video please like it subscribe to my channel so that you get notified whenever i post a new video so before any further do let's get started so the problem is linked is ra...
Linked List Random Node
linked-list-random-node
Given a singly linked list, return a random node's value from the linked list. Each node must have the **same probability** of being chosen. Implement the `Solution` class: * `Solution(ListNode head)` Initializes the object with the head of the singly-linked list `head`. * `int getRandom()` Chooses a node randoml...
null
Linked List,Math,Reservoir Sampling,Randomized
Medium
398
1,669
hey what's going on guys it's ilya bailey here i recording stuff on youtube chat description for all my information i do all liquid problems make sure you subscribe to this channel give me a big thumbs up to support it and this is called merge in between length lists you are given two length lists uh list one and list ...
Merge In Between Linked Lists
minimum-cost-to-cut-a-stick
You are given two linked lists: `list1` and `list2` of sizes `n` and `m` respectively. Remove `list1`'s nodes from the `ath` node to the `bth` node, and put `list2` in their place. The blue edges and nodes in the following figure indicate the result: _Build the result list and return its head._ **Example 1:** **In...
Build a dp array where dp[i][j] is the minimum cost to achieve all the cuts between i and j. When you try to get the minimum cost between i and j, try all possible cuts k between them, dp[i][j] = min(dp[i][k] + dp[k][j]) + (j - i) for all possible cuts k between them.
Array,Dynamic Programming
Hard
2251
82
welcome to january's leeco challenge today's problem is remove duplicates from sorted list 2. given the head of a sorted linked list delete all nodes that have duplicate numbers leaving only distinct numbers from the original list so we can have a linked list here and we're going to remove all the duplicates we're not ...
Remove Duplicates from Sorted List II
remove-duplicates-from-sorted-list-ii
Given the `head` of a sorted linked list, _delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list_. Return _the linked list **sorted** as well_. **Example 1:** **Input:** head = \[1,2,3,3,4,4,5\] **Output:** \[1,2,5\] **Example 2:** **Input:** head = \[1,1,1,2,3\] **Outpu...
null
Linked List,Two Pointers
Medium
83,1982
98
so i'm going to teach you the easiest way to solve the validate a binary substring problem so that method is called the limits methods okay so what does the limit method say the limit method states that for each node check if the value of the node falls within certain limits and if not written false so it means for ins...
Validate Binary Search Tree
validate-binary-search-tree
Given the `root` of a binary tree, _determine if it is a valid binary search tree (BST)_. A **valid BST** is defined as follows: * The left subtree of a node contains only nodes with keys **less than** the node's key. * The right subtree of a node contains only nodes with keys **greater than** the node's key. * ...
null
Tree,Depth-First Search,Binary Search Tree,Binary Tree
Medium
94,501
105
hello friends we are still not employed by a fan company so let's not stop lead coding till we get there today we are going to construct a binary tree from pre-order and in order traversal lead pre-order and in order traversal lead pre-order and in order traversal lead code problem and if we see some of the companies w...
Construct Binary Tree from Preorder and Inorder Traversal
construct-binary-tree-from-preorder-and-inorder-traversal
Given two integer arrays `preorder` and `inorder` where `preorder` is the preorder traversal of a binary tree and `inorder` is the inorder traversal of the same tree, construct and return _the binary tree_. **Example 1:** **Input:** preorder = \[3,9,20,15,7\], inorder = \[9,3,15,20,7\] **Output:** \[3,9,20,null,null,...
null
Array,Hash Table,Divide and Conquer,Tree,Binary Tree
Medium
106
1,845
hey everybody this is Larry this is day six of the Leo da challenge of November and actually day six this time hopefully I'm getting it right uh hit the like button hit the Subscribe button join me on Discord let me know what you think about today's farm and today we are still in uh at least of this recording uh still ...
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
35
hello and welcome to my channel so let's look at the lead code 35 search insert position give 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 ...
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
819
hello everyone welcome to my youtube channel today we're going to look at the 890 question most common words in python um so given a paragraph and list of bandwidths return the most frequent word that is not in the list of bad words so uh let's see the example here the most frequently appeared word is actually um hit o...
Most Common Word
minimum-swaps-to-make-sequences-increasing
Given a string `paragraph` and a string array of the banned words `banned`, return _the most frequent word that is not banned_. It is **guaranteed** there is **at least one word** that is not banned, and that the answer is **unique**. The words in `paragraph` are **case-insensitive** and the answer should be returned ...
null
Array,Dynamic Programming
Hard
2234
1,624
hey there what's up this is steve today let's go through one little problem it's labeled as easy it's actually pretty straightforward but i thought it's meaningful to go through this problem quickly and it's legal problem 1624 largest substring between two equal characters let's take a look at the problem given the str...
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
368
hello guys welcome back to my YouTube channel today we are going to solve Day N problem on lead code if you guys haven't subscribed my YouTube channel yet then please go ahead and subscribe it now without any delay let's get started with today's problem okay so guys uh this is a problem of largest divisible subset so i...
Largest Divisible Subset
largest-divisible-subset
Given a set of **distinct** positive integers `nums`, return the largest subset `answer` such that every pair `(answer[i], answer[j])` of elements in this subset satisfies: * `answer[i] % answer[j] == 0`, or * `answer[j] % answer[i] == 0` If there are multiple solutions, return any of them. **Example 1:** **Inp...
null
Array,Math,Dynamic Programming,Sorting
Medium
null
77
the question is combinations okay statement is given two integers n and k return all possible combinations of k numbers out of the range 1 comma n you may return the answer in any order okay look at the first test case we have n is equal to 4 and k is equal to 2 what they mean is we have to make the arrangements or com...
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
102
hey everyone welcome back and let's write some more neat code today so today let's solve binary tree level order traversal it's basically just like it sounds so we're given a binary tree and we want to return the level order traversal of its nodes so basically going through every single level of the tree and going from...
Binary Tree Level Order Traversal
binary-tree-level-order-traversal
Given the `root` of a binary tree, return _the level order traversal of its nodes' values_. (i.e., from left to right, level by level). **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[\[3\],\[9,20\],\[15,7\]\] **Example 2:** **Input:** root = \[1\] **Output:** \[\[1\]\] **Example 3:** **I...
null
Tree,Breadth-First Search,Binary Tree
Medium
103,107,111,314,637,764,1035
424
hello everyone and welcome to my first liko tutorial it's lee code number 424 the longest repeating character replacement so basically with this problem we're given a string s and an integer k we can choose any character of the string and change it to any other uppercase english character and we can perform this operat...
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
3
hello everyone so today we are looking at lead code number three longest substring without repeating characters uh this is a very popular question that's asked at a lot of companies you can see here in the last six to eight months very frequent at bloomberg amazon microsoft facebook all around so i highly suggest that ...
Longest Substring Without Repeating Characters
longest-substring-without-repeating-characters
Given a string `s`, find the length of the **longest** **substring** without repeating characters. **Example 1:** **Input:** s = "abcabcbb " **Output:** 3 **Explanation:** The answer is "abc ", with the length of 3. **Example 2:** **Input:** s = "bbbbb " **Output:** 1 **Explanation:** The answer is "b ", with t...
null
Hash Table,String,Sliding Window
Medium
159,340,1034,1813,2209
605
hey yo what's up my little coders let me show you in this tutorial how to solve the lethal question 605 can place flowers we are given one integer array which represents the flowerbed and this integer array can consist of only zeros or ones where one represents the twice um this place is not empty and the flower is alr...
Can Place Flowers
can-place-flowers
You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in **adjacent** plots. Given an integer array `flowerbed` containing `0`'s and `1`'s, where `0` means empty and `1` means not empty, and an integer `n`, return `true` _if_ `n` _new flowers can be plan...
null
Array,Greedy
Easy
495,735
1,884
hey everybody this is larry this is me doing a bonus question so hit the like button hit the subscribe button hit join me on discord leave a comment whatever you like to do uh it's august 12 2022 here i am doing a random question hopefully is one that is not premium because i have to subscribe to unlock maybe one day i...
Egg Drop With 2 Eggs and N Floors
minimum-changes-to-make-alternating-binary-string
You are given **two identical** eggs and you have access to a building with `n` floors labeled from `1` to `n`. You know that there exists a floor `f` where `0 <= f <= n` such that any egg dropped at a floor **higher** than `f` will **break**, and any egg dropped **at or below** floor `f` will **not break**. In each ...
Think about how the final string will look like. It will either start with a '0' and be like '010101010..' or with a '1' and be like '10101010..' Try both ways, and check for each way, the number of changes needed to reach it from the given string. The answer is the minimum of both ways.
String
Easy
null
331
welcome to august seleco challenge today's problem is verify pre-order today's problem is verify pre-order today's problem is verify pre-order serialization of a binary tree one way to serialize a binary tree is to use pre-order traversal prior traversals use pre-order traversal prior traversals use pre-order traversal...
Verify Preorder Serialization of a Binary Tree
verify-preorder-serialization-of-a-binary-tree
One way to serialize a binary tree is to use **preorder traversal**. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as `'#'`. For example, the above binary tree can be serialized to the string `"9,3,4,#,#,1,#,#,2,#,6,#,# "`, where `'#'` repres...
null
String,Stack,Tree,Binary Tree
Medium
null
1,171
hi let's solve today's daily challenge that is remove Zero Sum consecutive notes from link list so first let's understand what the question is so in this question you given the head of a link list and you need to repeatedly delete consecutive sequences of nodes that sum to zero until there are no such sequences all rig...
Remove Zero Sum Consecutive Nodes from Linked List
shortest-path-in-binary-matrix
Given the `head` of a linked list, we repeatedly delete consecutive sequences of nodes that sum to `0` until there are no such sequences. After doing so, return the head of the final linked list. You may return any such answer. (Note that in the examples below, all sequences are serializations of `ListNode` objects.)...
Do a breadth first search to find the shortest path.
Array,Breadth-First Search,Matrix
Medium
null
231
hey guys welcome back to helper function in this video we will discuss a question power of two so the problem is pretty straightforward given an integer write a function to determine if it is a power of two or not so we just need to return true if the number is power of two otherwise false so for the numbers like 1 2 a...
Power of Two
power-of-two
Given an integer `n`, return _`true` if it is a power of two. Otherwise, return `false`_. An integer `n` is a power of two, if there exists an integer `x` such that `n == 2x`. **Example 1:** **Input:** n = 1 **Output:** true **Explanation:** 20 = 1 **Example 2:** **Input:** n = 16 **Output:** true **Explanation:**...
null
Math,Bit Manipulation,Recursion
Easy
191,326,342
1,200
Hey guys, don't increase them by 1 and in this video I'm going to explain to you how to solve the problem one thousand and two hundred of the cold the minimum program absolut flex what this problem will want you to provide it will want you to build a method in which this method will receive a vector of integers and you...
Minimum Absolute Difference
remove-interval
Given an array of **distinct** integers `arr`, find all pairs of elements with the minimum absolute difference of any two elements. Return a list of pairs in ascending order(with respect to pairs), each pair `[a, b]` follows * `a, b` are from `arr` * `a < b` * `b - a` equals to the minimum absolute difference o...
Solve the problem for every interval alone. Divide the problem into cases according to the position of the two intervals.
Array
Medium
null
127
hi guys over here to increase our today's question is word ladder given two words begin word and end word and a dictionary is word list find the length of shortest transformation sequence from begin word to n-word such that only one begin word to n-word such that only one begin word to n-word such that only one letter ...
Word Ladder
word-ladder
A **transformation sequence** from word `beginWord` to word `endWord` using a dictionary `wordList` is a sequence of words `beginWord -> s1 -> s2 -> ... -> sk` such that: * Every adjacent pair of words differs by a single letter. * Every `si` for `1 <= i <= k` is in `wordList`. Note that `beginWord` does not need ...
null
Hash Table,String,Breadth-First Search
Hard
126,433
1,460
and today we will be solving a new lead code question that is make two strings for image two arrays equal by reversing summaries so let's read out the question what the question I'm asking from us you are given two integers arrays of equal length Target and error in one step you can select any non empty summary of ARR ...
Make Two Arrays Equal by Reversing Subarrays
number-of-substrings-containing-all-three-characters
You are given two integer arrays of equal length `target` and `arr`. In one step, you can select any **non-empty subarray** of `arr` and reverse it. You are allowed to make any number of steps. Return `true` _if you can make_ `arr` _equal to_ `target` _or_ `false` _otherwise_. **Example 1:** **Input:** target = \[1,...
For each position we simply need to find the first occurrence of a/b/c on or after this position. So we can pre-compute three link-list of indices of each a, b, and c.
Hash Table,String,Sliding Window
Medium
2187
1,029
hey everyone welcome back and let's write some more neat code today so today let's solve the problem to city scheduling so a company is planning to interview two times n people and we're given an array costs which they don't really mention here but at the bottom of the description they say that the length of costs is t...
Two City Scheduling
vertical-order-traversal-of-a-binary-tree
A company is planning to interview `2n` people. Given the array `costs` where `costs[i] = [aCosti, bCosti]`, the cost of flying the `ith` person to city `a` is `aCosti`, and the cost of flying the `ith` person to city `b` is `bCosti`. Return _the minimum cost to fly every person to a city_ such that exactly `n` people...
null
Hash Table,Tree,Depth-First Search,Breadth-First Search,Binary Tree
Hard
null
956
cool 9:36 tallest billboard you're cool 9:36 tallest billboard you're cool 9:36 tallest billboard you're installing a build one wanted to have two large aside the people have to still support one on your side each still suffer my superior you go hi you have a collection of watts which can be rode together well together...
Tallest Billboard
number-of-music-playlists
You are installing a billboard and want it to have the largest height. The billboard will have two steel supports, one on each side. Each steel support must be an equal height. You are given a collection of `rods` that can be welded together. For example, if you have rods of lengths `1`, `2`, and `3`, you can weld the...
null
Math,Dynamic Programming,Combinatorics
Hard
null
1,312
hey everyone welcome back today we are going to solve problem number one three one two minimum insertion steps to make up string palindrome first we will see the explanation of the problem statement then the logic and the code now let's dive into the solution so here I've taken the second example from the late codep si...
Minimum Insertion Steps to Make a String Palindrome
count-artifacts-that-can-be-extracted
Given a string `s`. In one step you can insert any character at any index of the string. Return _the minimum number of steps_ to make `s` palindrome. A **Palindrome String** is one that reads the same backward as well as forward. **Example 1:** **Input:** s = "zzazz " **Output:** 0 **Explanation:** The string "zz...
Check if each coordinate of each artifact has been excavated. How can we do this quickly without iterating over the dig array every time? Consider marking all excavated cells in a 2D boolean array.
Array,Hash Table,Simulation
Medium
221
1,870
hello everyone welcome back curious when I'm saying today we have fascinating tasks to tackle together we will be exploring a unique problem called minimum speed uh to arrive on time so uh where we will be embarking on a journey taking multiple trains to reach the office and our goal is to determine the minimum speed t...
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
404
how's it going guys today we're gonna be going over another problem called sum of left leaves this is the problem that's asked by bloomberg and Facebook right now so the problem scription says find the sum of all F leaves in a given binary tree so pretty simple problems description an example here is this tree and it s...
Sum of Left Leaves
sum-of-left-leaves
Given the `root` of a binary tree, return _the sum of all left leaves._ A **leaf** is a node with no children. A **left leaf** is a leaf that is the left child of another node. **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** 24 **Explanation:** There are two left leaves in the binary tree, wit...
null
Tree,Depth-First Search,Breadth-First Search,Binary Tree
Easy
null
1,606
hey everybody this is larry this is me going over q4 of the recent bi-weekly contest 36. uh of the recent bi-weekly contest 36. uh of the recent bi-weekly contest 36. uh hit the like button to subscribe and join me on discord and let's go find servers that handle the most number of requests so this one i took a long ti...
Find Servers That Handled Most Number of Requests
find-servers-that-handled-most-number-of-requests
You have `k` servers numbered from `0` to `k-1` that are being used to handle multiple requests simultaneously. Each server has infinite computational capacity but **cannot handle more than one request at a time**. The requests are assigned to servers according to a specific algorithm: * The `ith` (0-indexed) reques...
null
null
Hard
null
724
hello welcome to problem solving and today's problem will be 724 find pivot index the problem statement is given an array of integer nums calculate the pivot index of this array and the pivot statements definition is the pivot string pivot index is the index where the sum of all the numbers strictly to the left and let...
Find Pivot Index
find-pivot-index
Given an array of integers `nums`, calculate the **pivot index** of this array. The **pivot index** is the index where the sum of all the numbers **strictly** to the left of the index is equal to the sum of all the numbers **strictly** to the index's right. If the index is on the left edge of the array, then the left...
We can precompute prefix sums P[i] = nums[0] + nums[1] + ... + nums[i-1]. Then for each index, the left sum is P[i], and the right sum is P[P.length - 1] - P[i] - nums[i].
Array,Prefix Sum
Easy
560,2102,2369
1,630
hey everybody this is larry this is me going over arithmetic subways q2 of the recently code contest uh hit the like button hit the subscribe button join me on discord uh and you're gonna you get to watch me solve this live afterwards but the short answer for this question to be honest is just brute force um basically ...
Arithmetic Subarrays
count-odd-numbers-in-an-interval-range
A sequence of numbers is called **arithmetic** if it consists of at least two elements, and the difference between every two consecutive elements is the same. More formally, a sequence `s` is arithmetic if and only if `s[i+1] - s[i] == s[1] - s[0]` for all valid `i`. For example, these are **arithmetic** sequences: 1...
If the range (high - low + 1) is even, the number of even and odd numbers in this range will be the same. If the range (high - low + 1) is odd, the solution will depend on the parity of high and low.
Math
Easy
null
138
hey what's up guys this is john here so today uh let's take a look at today's daily challenge problem number 138 copy list with random pointer so basically you just it just asks you to make like a deep copy of a linked list but the only difference is that you know for this linked list other than the value and next poin...
Copy List with Random Pointer
copy-list-with-random-pointer
A linked list of length `n` is given such that each node contains an additional random pointer, which could point to any node in the list, or `null`. Construct a [**deep copy**](https://en.wikipedia.org/wiki/Object_copying#Deep_copy) of the list. The deep copy should consist of exactly `n` **brand new** nodes, where e...
Just iterate the linked list and create copies of the nodes on the go. Since a node can be referenced from multiple nodes due to the random pointers, make sure you are not making multiple copies of the same node. You may want to use extra space to keep old node ---> new node mapping to prevent creating multiples copies...
Hash Table,Linked List
Medium
133,1624,1634
785
okay so lead code practice time in this video there are two goals the first one is to find the solution for this specific problem and also do some coding and the second one is to see how to solve this problem properly by following the interview process so let's get started so remember the first step is always to try to...
Is Graph Bipartite?
basic-calculator-iii
There is an **undirected** graph with `n` nodes, where each node is numbered between `0` and `n - 1`. You are given a 2D array `graph`, where `graph[u]` is an array of nodes that node `u` is adjacent to. More formally, for each `v` in `graph[u]`, there is an undirected edge between node `u` and node `v`. The graph has ...
null
Math,String,Stack,Recursion
Hard
224,227,781,1736
3
in the previous video we learned about sliding window a problem-solving sliding window a problem-solving sliding window a problem-solving technique that works by maintaining a window that represents a contiguous part of the data in this video we will use it to solve a popular coding problem longest substring without re...
Longest Substring Without Repeating Characters
longest-substring-without-repeating-characters
Given a string `s`, find the length of the **longest** **substring** without repeating characters. **Example 1:** **Input:** s = "abcabcbb " **Output:** 3 **Explanation:** The answer is "abc ", with the length of 3. **Example 2:** **Input:** s = "bbbbb " **Output:** 1 **Explanation:** The answer is "b ", with t...
null
Hash Table,String,Sliding Window
Medium
159,340,1034,1813,2209
228
now let's go over question number 228 summary ranges you are given sorted unique integer array numbers you're going to be given an array that is composed of numbers they're all going to be sorted they're going to be unique and they're going to be all integers so whole numbers return the smallest sorted list of ranges t...
Summary Ranges
summary-ranges
You are given a **sorted unique** integer array `nums`. A **range** `[a,b]` is the set of all integers from `a` to `b` (inclusive). Return _the **smallest sorted** list of ranges that **cover all the numbers in the array exactly**_. That is, each element of `nums` is covered by exactly one of the ranges, and there is...
null
Array
Easy
163,352
1,010
hey guys it's iran with another coding interview tutorial this one has been requested by subscribers so thanks for the suggestion i think it's a really good one so i hope you enjoy it now this question is called pairs of songs with total duration divisible by 60 and the description goes like this you are given a list o...
Pairs of Songs With Total Durations Divisible by 60
powerful-integers
You are given a list of songs where the `ith` song has a duration of `time[i]` seconds. Return _the number of pairs of songs for which their total duration in seconds is divisible by_ `60`. Formally, we want the number of indices `i`, `j` such that `i < j` with `(time[i] + time[j]) % 60 == 0`. **Example 1:** **Input...
null
Hash Table,Math
Medium
null
212
hello everyone welcome to day ninth of october liquor challenge and today's question is word search two in this question we are given a grid of size m cross n where each cell has some characters associated with it we need to identify the number of words that are also given to us that lie within this grid and in what al...
Word Search II
word-search-ii
Given an `m x n` `board` of characters and a list of strings `words`, return _all words on the board_. Each word must be constructed from letters of sequentially adjacent cells, where **adjacent cells** are horizontally or vertically neighboring. The same letter cell may not be used more than once in a word. **Exampl...
You would need to optimize your backtracking to pass the larger test. Could you stop backtracking earlier? If the current candidate does not exist in all words' prefix, you could stop backtracking immediately. What kind of data structure could answer such query efficiently? Does a hash table work? Why or why not? How a...
Array,String,Backtracking,Trie,Matrix
Hard
79,1022,1433
171
hello guys we are back with another lead code problem and today is day 22 of february let's see that today's problem and the problem is excellency column number it's a fall into the category of easy and it's a highly like ratio so let's directly dive into the question what actually question ask so you have a given and ...
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
51
Ki A Hello Everyone Welcome T20 Second Aap Nahin Daal Introduce Question And Begin From 10pm Problems Very Fierce Interview Fail Subscribe Problem in the Video then subscribe to Ki Ki Ki Ki Patient Se Start Aircraft Place In This Alone In The Chest Size 30 Channel Blurry Si Ki Also Chew Young Vansh Replace Mirchi Probl...
N-Queens
n-queens
The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other. Given an integer `n`, return _all distinct solutions to the **n-queens puzzle**_. You may return the answer in **any order**. Each solution contains a distinct board configuration of the n-...
null
Array,Backtracking
Hard
52,1043
53
hello guys welcome to study algorithms and today we would be looking at finding the maximum sum contiguous sub array first we would understand the problem statement and define a contiguous sub array then if you try to solve it in a naive way and see what problems could occur next we would optimize the solution and disc...
Maximum Subarray
maximum-subarray
Given an integer array `nums`, find the subarray with the largest sum, and return _its sum_. **Example 1:** **Input:** nums = \[-2,1,-3,4,-1,2,1,-5,4\] **Output:** 6 **Explanation:** The subarray \[4,-1,2,1\] has the largest sum 6. **Example 2:** **Input:** nums = \[1\] **Output:** 1 **Explanation:** The subarray \...
null
Array,Divide and Conquer,Dynamic Programming
Easy
121,152,697,1020,1849,1893
108
welcome to mazelico challenge today's problem is convert sorted list to binary search tree given the head of a singly linked list where the elements are sorted in ascending order convert it to a height balanced bst for this problem a height balanced binary tree is defined as a binary tree in which the depth of the two ...
Convert Sorted Array to Binary Search Tree
convert-sorted-array-to-binary-search-tree
Given an integer array `nums` where the elements are sorted in **ascending order**, convert _it to a_ **_height-balanced_** _binary search tree_. **Example 1:** **Input:** nums = \[-10,-3,0,5,9\] **Output:** \[0,-3,9,-10,null,5\] **Explanation:** \[0,-10,5,null,-3,null,9\] is also accepted: **Example 2:** **Input...
null
Array,Divide and Conquer,Tree,Binary Search Tree,Binary Tree
Easy
109
1,095
hey everyone welcome back and let's write some more neat code today so today let's solve the problem find in Mountain array once again we have a hard problem this one though is not super crazy I think at least conceptually you should be able to figure out how to solve this problem in a reasonable amount of time hopeful...
Find in Mountain Array
two-city-scheduling
_(This problem is an **interactive problem**.)_ You may recall that an array `arr` is a **mountain array** if and only if: * `arr.length >= 3` * There exists some `i` with `0 < i < arr.length - 1` such that: * `arr[0] < arr[1] < ... < arr[i - 1] < arr[i]` * `arr[i] > arr[i + 1] > ... > arr[arr.length ...
null
Array,Greedy,Sorting
Medium
null
1,269
hey everybody this is Larry this is me doing day 15 and I'll also do the premium problem later uh of the deco day challenge oh they going give us a hard one right before contest hit the like button hit the Subscribe button join me on Discord let me know what you think about today's SP 1269 number of ways to stay in the...
Number of Ways to Stay in the Same Place After Some Steps
market-analysis-ii
You have a pointer at index `0` in an array of size `arrLen`. At each step, you can move 1 position to the left, 1 position to the right in the array, or stay in the same place (The pointer should not be placed outside the array at any time). Given two integers `steps` and `arrLen`, return the number of ways such that...
null
Database
Hard
null
143
hey what's going on everyone I'm back in the leeco grind so let's get to it in this video I'll show you how to solve question 143 reorder a linked list using a two-pointer method but the way I solve a two-pointer method but the way I solve a two-pointer method but the way I solve it here is a little different than the ...
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
1,614
resting depth of the parenthesis so string is a married parenting string where they have denoted as VPS if it meets one of the following criterias so first one is it is an empty string or a single character not equal to either open or close okay other critical is it can be written as EB like a is concatenated with B wh...
Maximum Nesting Depth of the Parentheses
maximum-nesting-depth-of-the-parentheses
A string is a **valid parentheses string** (denoted **VPS**) if it meets one of the following: * It is an empty string `" "`, or a single character not equal to `"( "` or `") "`, * It can be written as `AB` (`A` concatenated with `B`), where `A` and `B` are **VPS**'s, or * It can be written as `(A)`, where `A` i...
null
null
Easy
null
1,705
hey everybody this is me going over q2 of the weekly contest 221 uh maximum number of g in apples so this one i had a lot of struggle with during the contest um if you skip i actually just kind of i tried like three or four different things uh and they were just wrong um i mean i had the right idea but uh i want to go ...
Maximum Number of Eaten Apples
count-unhappy-friends
There is a special kind of apple tree that grows apples every day for `n` days. On the `ith` day, the tree grows `apples[i]` apples that will rot after `days[i]` days, that is on day `i + days[i]` the apples will be rotten and cannot be eaten. On some days, the apple tree does not grow any apples, which are denoted by ...
Create a matrix “rank” where rank[i][j] holds how highly friend ‘i' views ‘j’. This allows for O(1) comparisons between people
Array,Simulation
Medium
null
412
hey guys welcome back to my series of videos of solving lead code problems right now looking at 412 Fizz Buzz so given an integer n return the string array answer which is from index one until the integer end inclusively and each of the indexes it shows the positions of the answer array and it will be first bus if I is...
Fizz Buzz
fizz-buzz
Given an integer `n`, return _a string array_ `answer` _(**1-indexed**) where_: * `answer[i] == "FizzBuzz "` if `i` is divisible by `3` and `5`. * `answer[i] == "Fizz "` if `i` is divisible by `3`. * `answer[i] == "Buzz "` if `i` is divisible by `5`. * `answer[i] == i` (as a string) if none of the above condit...
null
Math,String,Simulation
Easy
1316
496
hey everyone in this video let's take a look at question 496 next greater element 1 only code part of our blind 75 list of questions so let's begin in this question I'm actually going to go ahead and just copy the examples here I find that they're easier to understand yeah than the actual question phrasing is a little ...
Next Greater Element I
next-greater-element-i
The **next greater element** of some element `x` in an array is the **first greater** element that is **to the right** of `x` in the same array. You are given two **distinct 0-indexed** integer arrays `nums1` and `nums2`, where `nums1` is a subset of `nums2`. For each `0 <= i < nums1.length`, find the index `j` such ...
null
Array,Hash Table,Stack,Monotonic Stack
Easy
503,556,739,2227
1,957
hey what's up guys so i saw this 1957 dvd character to make fancy string also offensive string the string with no three consecutive characters are equal so given string ask delete the minimum possible number of characters to make it fancy uh you can prove that this is unique uh this is i mean you can try to prove okay ...
Delete Characters to Make Fancy String
closest-room
A **fancy string** is a string where no **three** **consecutive** characters are equal. Given a string `s`, delete the **minimum** possible number of characters from `s` to make it **fancy**. Return _the final string after the deletion_. It can be shown that the answer will always be **unique**. **Example 1:** **In...
Is there a way to sort the queries so it's easier to search the closest room larger than the size? Use binary search to speed up the search time.
Array,Binary Search,Sorting
Hard
2179
1,727
hey everyone today we are going to solve the Ral question largest sub Matrix with rearrangements okay so we should return the largest Square in The Matrix so simply formula is height multiply width so let's think about this um since we can rearrange the matrix by entire columns we can consider entire columns as a heigh...
Largest Submatrix With Rearrangements
cat-and-mouse-ii
You are given a binary matrix `matrix` of size `m x n`, and you are allowed to rearrange the **columns** of the `matrix` in any order. Return _the area of the largest submatrix within_ `matrix` _where **every** element of the submatrix is_ `1` _after reordering the columns optimally._ **Example 1:** **Input:** matri...
Try working backward: consider all trivial states you know to be winning or losing, and work backward to determine which other states can be labeled as winning or losing.
Math,Dynamic Programming,Breadth-First Search,Graph,Memoization,Game Theory
Hard
805,949
334
hello guys welcome to another interesting video in the series of coding it's called increasing triplet subsequence so let's get started with it given an integer array nums return true if there exists a triplet of indices i j k such that i is less than j is less than k and numbers of i is less than numbers of j and numb...
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
343
all right let's talk about integer break so you're given independent break it into the sum of k positive integers so for k greater than or equal to 2 and maximize the product of integer so return the maximum product so basically this is supposed to be easy but it's actually really difficult to code so imagine you have ...
Integer Break
integer-break
Given an integer `n`, break it into the sum of `k` **positive integers**, where `k >= 2`, and maximize the product of those integers. Return _the maximum product you can get_. **Example 1:** **Input:** n = 2 **Output:** 1 **Explanation:** 2 = 1 + 1, 1 \* 1 = 1. **Example 2:** **Input:** n = 10 **Output:** 36 **Exp...
There is a simple O(n) solution to this problem. You may check the breaking results of n ranging from 7 to 10 to discover the regularities.
Math,Dynamic Programming
Medium
1936
455
hello everyone in this video I'm going to explain you uh the sign cookies problem so the problem goes like this so let me take example and explain I think you have gone through the problem so you have understood what problem statement says so basically they'll be given us two arrays uh G so G implies the grid array and...
Assign Cookies
assign-cookies
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child `i` has a greed factor `g[i]`, which is the minimum size of a cookie that the child will be content with; and each cookie `j` has a size `s[j]`. If `s[j] >= g[i]`, we can assign ...
null
Array,Greedy,Sorting
Easy
null
863
hey yo what's up guys babybear4812 coming at you one more time uh as i record this video it's super claudio uh but as the old adage goes when uh when rain brings you sorrow lean code brings you joy and so here we are i don't think there's an average that goes like that i just made that up um anyways 863 all nodes dista...
All Nodes Distance K in Binary Tree
sum-of-distances-in-tree
Given the `root` of a binary tree, the value of a target node `target`, and an integer `k`, return _an array of the values of all nodes that have a distance_ `k` _from the target node._ You can return the answer in **any order**. **Example 1:** **Input:** root = \[3,5,1,6,2,0,8,null,null,7,4\], target = 5, k = 2 **O...
null
Dynamic Programming,Tree,Depth-First Search,Graph
Hard
1021,2175
820
Hello guys welcome to another interesting video open a desi shop ideal for today the problem it is the goddess challenge of today only its caller shopping cooling off but so let's get started to the problem given there goals for stated in question are of course So 2014 Russia And Finally Tears Return The Length Of The ...
Short Encoding of Words
find-eventual-safe-states
A **valid encoding** of an array of `words` is any reference string `s` and array of indices `indices` such that: * `words.length == indices.length` * The reference string `s` ends with the `'#'` character. * For each index `indices[i]`, the **substring** of `s` starting from `indices[i]` and up to (but not incl...
null
Depth-First Search,Breadth-First Search,Graph,Topological Sort
Medium
null
144
Everyone and welcome back again Tu Coding Ispat Delhi Challenge There can be only two maximum routes from one route or from one note There can be maximum two children Visit all of them He is the priority person As if I explain in this one, then can you do this route You will start from here, we will add it, after that ...
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,008
hey everybody this is larry oh this is day 13 for 14 yeah 13 day 13 of the lead co daily october challenge uh hit the like button subscribe and join me on this card let me know what you think about today's firm and all the good stuff uh yeah i took a nap so i just woke up even though it is like 9 00 p.m in new york tho...
Construct Binary Search Tree from Preorder Traversal
binary-tree-cameras
Given an array of integers preorder, which represents the **preorder traversal** of a BST (i.e., **binary search tree**), construct the tree and return _its root_. It is **guaranteed** that there is always possible to find a binary search tree with the given requirements for the given test cases. A **binary search tr...
null
Dynamic Programming,Tree,Depth-First Search,Binary Tree
Hard
1021
1,980
Hello Welcome Back Friends Today We Are Going to Be Discussed Problem 1995 Unique Binary Spring The Governor of None in Unix Banner Spring Switch Off Planning and Return Winery String of Land in That Was Not Appeared in Effigy of Multiple Answers You May Return of the Day 102 Ago Have Been Given Minor Strings of Length...
Find Unique Binary String
faulty-sensor
Given an array of strings `nums` containing `n` **unique** binary strings each of length `n`, return _a binary string of length_ `n` _that **does not appear** in_ `nums`_. If there are multiple answers, you may return **any** of them_. **Example 1:** **Input:** nums = \[ "01 ", "10 "\] **Output:** "11 " **Explanatio...
Check for a common prefix of the two arrays. After this common prefix, there should be one array similar to the other but shifted by one. If both arrays can be shifted, return -1.
Array,Two Pointers
Easy
null
232
hey everyone welcome back and let's write some more neat code today so today let's solve the problem Implement Q using Stacks if you don't remember what a q is it's a first in first out data structure so for example we have a few operations that we can perform we can push elements into the queue and this case they're g...
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
64
let's talk about today's li coding challenge question minimum path saw we have a M by n grid matrix filled with non-negative numbers we want to find a non-negative numbers we want to find a non-negative numbers we want to find a path from top left towards bottom right which minimize the sum of all the numbers although ...
Minimum Path Sum
minimum-path-sum
Given a `m x n` `grid` filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. **Note:** You can only move either down or right at any point in time. **Example 1:** **Input:** grid = \[\[1,3,1\],\[1,5,1\],\[4,2,1\]\] **Output:** 7 **Explanat...
null
Array,Dynamic Programming,Matrix
Medium
62,174,741,2067,2192
120
Hello Hi Guys Welcome And Welcome Back To My Channel Suggestion Or After Hours Phone Information On Problem Number Love You Please Like And Subscribe My Channel And Hit Like And Show That You Get Notified When Ever Portion Video 2018 Problem Hi Problem Or Governor Triangle Hey written minimum 5 sum from top to bottom p...
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,685
hello and welcome to another video in this video we're going to be working on some of absolute differences in a sorted array and in the problem you're given an inary num sort in ncreasing order and what you want to do is you want to build an integer ARR result where the result is the sum of taking every single number i...
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
1,093
I always Calvin here so today we will discuss about a problem called statistic from a large sample from weekly contest 142 so we are given array of size 2200 and 456 the represent frequency of number from 0 to 255 so first index representing number of 0 second X representing number of 1 second index presenting number o...
Statistics from a Large Sample
recover-a-tree-from-preorder-traversal
You are given a large sample of integers in the range `[0, 255]`. Since the sample is so large, it is represented by an array `count` where `count[k]` is the **number of times** that `k` appears in the sample. Calculate the following statistics: * `minimum`: The minimum element in the sample. * `maximum`: The max...
Do an iterative depth first search, parsing dashes from the string to inform you how to link the nodes together.
String,Tree,Depth-First Search,Binary Tree
Hard
null
670
hello and welcome back to the cracking Fang YouTube channel today we are solving one of my least favorite questions this problem is extremely annoying to code up and even though it's not that hard to solve conceptually it's just a horrible problem that requires way too much uh work to do okay it is 670 maximum swap you...
Maximum Swap
maximum-swap
You are given an integer `num`. You can swap two digits at most once to get the maximum valued number. Return _the maximum valued number you can get_. **Example 1:** **Input:** num = 2736 **Output:** 7236 **Explanation:** Swap the number 2 and the number 7. **Example 2:** **Input:** num = 9973 **Output:** 9973 **E...
null
Math,Greedy
Medium
321
1,646
hi there so today's problem is get maximum in generated array so we are given an input of an integer n and what we are going to do we are going to fill the array of size n and return the value which is maximum in the array here we go we basically gonna have an array of size n here our size is seven so indexed from zero...
Get Maximum in Generated Array
kth-missing-positive-number
You are given an integer `n`. A **0-indexed** integer array `nums` of length `n + 1` is generated in the following way: * `nums[0] = 0` * `nums[1] = 1` * `nums[2 * i] = nums[i]` when `2 <= 2 * i <= n` * `nums[2 * i + 1] = nums[i] + nums[i + 1]` when `2 <= 2 * i + 1 <= n` Return _the **maximum** integer in the...
Keep track of how many positive numbers are missing as you scan the array.
Array,Binary Search
Easy
2305
744
hello and welcome to another Elite code problem today we're going to be doing the promo of the day for June 9th and it's fine smallest letter greater than Target it's pretty straightforward it says you're given an array letters sorted in non-decreasing order in a character non-decreasing order in a character non-decrea...
Find Smallest Letter Greater Than Target
network-delay-time
You are given an array of characters `letters` that is sorted in **non-decreasing order**, and a character `target`. There are **at least two different** characters in `letters`. Return _the smallest character in_ `letters` _that is lexicographically greater than_ `target`. If such a character does not exist, return t...
We visit each node at some time, and if that time is better than the fastest time we've reached this node, we travel along outgoing edges in sorted order. Alternatively, we could use Dijkstra's algorithm.
Depth-First Search,Breadth-First Search,Graph,Heap (Priority Queue),Shortest Path
Medium
2151,2171
1,675
thank you hello everyone so today we have this hard problem it's minimized deviation in Array um let's read the description you are given an array nums of n positive integers like given here and you can perform two types of operation on any element of the array any number of times okay if the element is even divided by...
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
246
welcome back everyone we're going to be solving Lee code 246 strabogrammatic number so we're given a string called num which represents an integer and we want to return true if that number is a stravogrammatic number and they Define a strip of grammatic number as a number that looks the same when we're rotated 180 degr...
Strobogrammatic Number
strobogrammatic-number
Given a string `num` which represents an integer, return `true` _if_ `num` _is a **strobogrammatic number**_. A **strobogrammatic number** is a number that looks the same when rotated `180` degrees (looked at upside down). **Example 1:** **Input:** num = "69 " **Output:** true **Example 2:** **Input:** num = "88...
null
Hash Table,Two Pointers,String
Easy
247,248,1069
1,835
hi everyone in this video we are going to discuss the finds or sum of all things bitwise and so uh let us understand what the question demands so you are given two array let us say these are two arrays and then you will have to create a new array each element taking and with the other element of the array in this way a...
Find XOR Sum of All Pairs Bitwise AND
decode-xored-permutation
The **XOR sum** of a list is the bitwise `XOR` of all its elements. If the list only contains one element, then its **XOR sum** will be equal to this element. * For example, the **XOR sum** of `[1,2,3,4]` is equal to `1 XOR 2 XOR 3 XOR 4 = 4`, and the **XOR sum** of `[3]` is equal to `3`. You are given two **0-inde...
Compute the XOR of the numbers between 1 and n, and think about how it can be used. Let it be x. Think why n is odd. perm[0] = x XOR encoded[1] XOR encoded[3] XOR encoded[5] ... perm[i] = perm[i-1] XOR encoded[i-1]
Array,Bit Manipulation
Medium
null
1,822
welcome back everyone today we're going to be solving Lee code 1822 sign of the product of an array so we are given a function sine function which takes in one parameter X which returns 1 if x is positive negative one if x is negative and 0 if x is equal to zero so we're given an array an integer array and we need to l...
Sign of the Product of an Array
longest-palindromic-subsequence-ii
There is a function `signFunc(x)` that returns: * `1` if `x` is positive. * `-1` if `x` is negative. * `0` if `x` is equal to `0`. You are given an integer array `nums`. Let `product` be the product of all values in the array `nums`. Return `signFunc(product)`. **Example 1:** **Input:** nums = \[-1,-2,-3,-4,...
As with any good dp problem that uses palindromes, try building the palindrome from the edges The prime point is to check that no two adjacent characters are equal, so save the past character while building the palindrome.
String,Dynamic Programming
Medium
516
218
The problem is 218 10 and what is its height. Regarding its starting, I basically have to tell a skyline, which is basically how I am saying that if I draw its outline laterally, then my result will be something like this. Okay, this value also. So I can take that means why am I not taking this value or this value is g...
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
1,168
hello everyone welcome um to another video this is optimize water distribution in a village it's a legal problem um which is premium right a premium liquid problem I'm asked by Google Facebook and Microsoft so I hope you guys you know get a lot of utility from this video um uh there are basically we have um it's not li...
Optimize Water Distribution in a Village
duplicate-zeros
There are `n` houses in a village. We want to supply water for all the houses by building wells and laying pipes. For each house `i`, we can either build a well inside it directly with cost `wells[i - 1]` (note the `-1` due to **0-indexing**), or pipe in water from another well to it. The costs to lay pipes between ho...
This is a great introductory problem for understanding and working with the concept of in-place operations. The problem statement clearly states that we are to modify the array in-place. That does not mean we cannot use another array. We just don't have to return anything. A better way to solve this would be without us...
Array,Two Pointers
Easy
null
810
cool okay 810 chalkboard XOR game we're giving non-negative integers num sub I giving non-negative integers num sub I giving non-negative integers num sub I which I've been on a chalkboard Alice and Bob which open common names in game theory so I feel like it's gonna be a game for you one Alice and Bob take turns you r...
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
1,288
hello so continuing on this beauty contest 15 second problem remove covered intervals says that given a list of intervals remove all intervals that are covered by another interval Andalus which means basically a B is considered covered by a by the interval C D if a is if C is smaller yeah that wording is a little bit h...
Remove Covered Intervals
maximum-subarray-sum-with-one-deletion
Given an array `intervals` where `intervals[i] = [li, ri]` represent the interval `[li, ri)`, remove all intervals that are covered by another interval in the list. The interval `[a, b)` is covered by the interval `[c, d)` if and only if `c <= a` and `b <= d`. Return _the number of remaining intervals_. **Example 1:...
How to solve this problem if no deletions are allowed ? Try deleting each element and find the maximum subarray sum to both sides of that element. To do that efficiently, use the idea of Kadane's algorithm.
Array,Dynamic Programming
Medium
null
451
hello everyone this is sham Saar and I welcome you again in the next video of our YouTube channel uh this is the 7th of February problem and the name of the problem is sort characters by frequency it is a medium problem uh here they have given string s and we need to sort it in decreasing order based on the frequency o...
Sort Characters By Frequency
sort-characters-by-frequency
Given a string `s`, sort it in **decreasing order** based on the **frequency** of the characters. The **frequency** of a character is the number of times it appears in the string. Return _the sorted string_. If there are multiple answers, return _any of them_. **Example 1:** **Input:** s = "tree " **Output:** "eer...
null
Hash Table,String,Sorting,Heap (Priority Queue),Bucket Sort,Counting
Medium
347,387,1741
279
hello everyone this is sham saari and I welcome you again in the next video of our YouTube channel so this problem came in 8th of February and we are discussing this medium level problem perfect squares here they have given an integer n and we need to return the least number of perfect squares square numbers that sum t...
Perfect Squares
perfect-squares
Given an integer `n`, return _the least number of perfect square numbers that sum to_ `n`. A **perfect square** is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, `1`, `4`, `9`, and `16` are perfect squares while `3` and `11` are not. **Example ...
null
Math,Dynamic Programming,Breadth-First Search
Medium
204,264
1,395
hey folks welcome back to another video today we'll be looking at question 1395 count number of teams um the way we'll be approaching the solution is by uh inspecting each and every element and looking at how many elements that are to the left of the current element which are less than and greater than the current elem...
Count Number of Teams
minimum-time-visiting-all-points
There are `n` soldiers standing in a line. Each soldier is assigned a **unique** `rating` value. You have to form a team of 3 soldiers amongst them under the following rules: * Choose 3 soldiers with index (`i`, `j`, `k`) with rating (`rating[i]`, `rating[j]`, `rating[k]`). * A team is valid if: (`rating[i] < rat...
To walk from point A to point B there will be an optimal strategy to walk ? Advance in diagonal as possible then after that go in straight line. Repeat the process until visiting all the points.
Array,Math,Geometry
Easy
null
35
hey everybody this is larry this is me doing the co daily challenge number um day 26 happy thanksgiving sorry i'm like a little bit off uh happy thanksgiving doing day 26 of the november league day challenge hit the like button hit the subscriber and join me on discord let me know what you think about today's problem u...
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
191
hey everyone today we are going to solve the question number one bits okay so this question is very simple so let me explain with my solution code if you understand this you can solve this question so we have a constraint saying the input must be a binary string of ring 32 so we Loop 32 times at most and in the loop um...
Number of 1 Bits
number-of-1-bits
Write a function that takes the binary representation of an unsigned integer and returns the number of '1' bits it has (also known as the [Hamming weight](http://en.wikipedia.org/wiki/Hamming_weight)). **Note:** * Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input ...
null
Bit Manipulation
Easy
190,231,338,401,461,693,767
1,184
hi what's up everybody and this is fisher cover here today we're going through a little problem 1184 it's called distance between bus stops and labeled as easy but I thought it's very interesting question okay before we dive into you the question please do me a favor and hit the like button that's going to help a lot w...
Distance Between Bus Stops
car-pooling
A bus has `n` stops numbered from `0` to `n - 1` that form a circle. We know the distance between all pairs of neighboring stops where `distance[i]` is the distance between the stops number `i` and `(i + 1) % n`. The bus goes along both directions i.e. clockwise and counterclockwise. Return the shortest distance betw...
Sort the pickup and dropoff events by location, then process them in order.
Array,Sorting,Heap (Priority Queue),Simulation,Prefix Sum
Medium
253
128
hi everyone today solid quick question called longest consecutive sequence so given sort of intuition nouns want to change the length or longest consecutive element sequence and we must show the problem in one time which means it should be one pass okay now let's look example here so example one we're starting the one ...
Longest Consecutive Sequence
longest-consecutive-sequence
Given an unsorted array of integers `nums`, return _the length of the longest consecutive elements sequence._ You must write an algorithm that runs in `O(n)` time. **Example 1:** **Input:** nums = \[100,4,200,1,3,2\] **Output:** 4 **Explanation:** The longest consecutive elements sequence is `[1, 2, 3, 4]`. Therefor...
null
Array,Hash Table,Union Find
Medium
298,2278
228
Hello everyone welcome back to my channel once again so here we are going to talk about today's daily problems of late code NDA question from hair code easy problem whose name is Summary Rangers so easy problem is okay so the question what did you say that you have Sorted Unique Wait Right Pay attention here, some thin...
Summary Ranges
summary-ranges
You are given a **sorted unique** integer array `nums`. A **range** `[a,b]` is the set of all integers from `a` to `b` (inclusive). Return _the **smallest sorted** list of ranges that **cover all the numbers in the array exactly**_. That is, each element of `nums` is covered by exactly one of the ranges, and there is...
null
Array
Easy
163,352
1,239
Maximum length of concated string's unique characters, so first Happy Diwali to all of you, vector is given string, okay, so what we have to do is, we have to make concated disting, okay, which candidate string has to be created by taking these strings which are inside this factor, so that the string I have included in...
Maximum Length of a Concatenated String with Unique Characters
largest-1-bordered-square
You are given an array of strings `arr`. A string `s` is formed by the **concatenation** of a **subsequence** of `arr` that has **unique characters**. Return _the **maximum** possible length_ of `s`. A **subsequence** is an array that can be derived from another array by deleting some or no elements without changing ...
For each square, know how many ones are up, left, down, and right of this square. You can find it in O(N^2) using dynamic programming. Now for each square ( O(N^3) ), we can evaluate whether that square is 1-bordered in O(1).
Array,Dynamic Programming,Matrix
Medium
null
424
Hello friends today I'm going to solve liquid problem number 424 longest repeating character replacement so here we are given a string s which consists of uppercase English characters and an integer K and we are allowed to change any character of the string to another character and the maximum number of times we could ...
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
1,562
hi everyone it's albert here today let's solve the contest question find latest group of size m okay the question statement so given an array and its items are the permutation of numbers from 1 to n and n is the size of the array and we also have a binary string of size n that they are initially set of bits to zero so ...
Find Latest Group of Size M
people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list
Given an array `arr` that represents a permutation of numbers from `1` to `n`. You have a binary string of size `n` that initially has all its bits set to zero. At each step `i` (assuming both the binary string and `arr` are 1-indexed) from `1` to `n`, the bit at position `arr[i]` is set to `1`. You are also given an...
Use hashing to convert company names in numbers and then for each list check if this is a subset of any other list. In order to check if a list is a subset of another list, use two pointers technique to get a linear solution for this task. The total complexity will be O(n^2 * m) where n is the number of lists and m is ...
Array,Hash Table,String
Medium
null
1,352
welcome to my channel so in this video i'm going to go through this um uh specific question called product of the last k numbers and at the end of the video i'm going to go through the general steps we should follow in a real interview so let's get started before we start the real content for today i would really appre...
Product of the Last K Numbers
maximum-profit-in-job-scheduling
Design an algorithm that accepts a stream of integers and retrieves the product of the last `k` integers of the stream. Implement the `ProductOfNumbers` class: * `ProductOfNumbers()` Initializes the object with an empty stream. * `void add(int num)` Appends the integer `num` to the stream. * `int getProduct(int...
Think on DP. Sort the elements by starting time, then define the dp[i] as the maximum profit taking elements from the suffix starting at i. Use binarySearch (lower_bound/upper_bound on C++) to get the next index for the DP transition.
Array,Binary Search,Dynamic Programming,Sorting
Hard
2118,2164
973
Jhaal Hello Everyone Welcome and Welcome Back to my Channel Today Were Going to Solve Na the Problem Is Cake This Point to Reject So in this Problem Will Be Given a Good Points Where Points of It Ads Index and Point Se Loan Rate Will Be For Paririt sweetness together sexual representatives point n K Point Quality Point...
K Closest Points to Origin
stamping-the-sequence
Given an array of `points` where `points[i] = [xi, yi]` represents a point on the **X-Y** plane and an integer `k`, return the `k` closest points to the origin `(0, 0)`. The distance between two points on the **X-Y** plane is the Euclidean distance (i.e., `√(x1 - x2)2 + (y1 - y2)2`). You may return the answer in **an...
null
String,Stack,Greedy,Queue
Hard
null
791
welcome to july's leeco challenge today's problem is custom sort string order and str are strings composed of lowercase letters in order no letter occurs more than once so everything's distinct now order was sorted in some custom order previously we want to permute the characters of str so that they match the order tha...
Custom Sort String
split-bst
You are given two strings order and s. All the characters of `order` are **unique** and were sorted in some custom order previously. Permute the characters of `s` so that they match the order that `order` was sorted. More specifically, if a character `x` occurs before a character `y` in `order`, then `x` should occur ...
Use recursion. If root.val <= V, you split root.right into two halves, then join it's left half back on root.right.
Tree,Binary Search Tree,Recursion,Binary Tree
Medium
450
1,222
lead code 122 I took the solution from this um Nick white code look at it in here and this is the no this is the problems so if you are given a king in here what are the queens that can attack you which means like this one got blocked not even blocked it doesn't happen she doesn't even have any path and this one gets b...
Queens That Can Attack the King
remove-covered-intervals
On a **0-indexed** `8 x 8` chessboard, there can be multiple black queens ad one white king. You are given a 2D integer array `queens` where `queens[i] = [xQueeni, yQueeni]` represents the position of the `ith` black queen on the chessboard. You are also given an integer array `king` of length `2` where `king = [xKing...
How to check if an interval is covered by another? Compare each interval to all others and check if it is covered by any interval.
Array,Sorting
Medium
null
1,780
hello everyone welcome to coderscam and today we are going to cover check if number is a sum of powers of three so given here is an integer value and we have to return true if it is possible to represent the given number as a sum of distinct powers of 3 otherwise written false so consider the first example that is n is...
Check if Number is a Sum of Powers of Three
lowest-common-ancestor-of-a-binary-tree-ii
Given an integer `n`, return `true` _if it is possible to represent_ `n` _as the sum of distinct powers of three._ Otherwise, return `false`. An integer `y` is a power of three if there exists an integer `x` such that `y == 3x`. **Example 1:** **Input:** n = 12 **Output:** true **Explanation:** 12 = 31 + 32 **Examp...
Traverse the graph visiting root, left, root, right, root to make an Euler Path Return the node (LCA) that is at the lowest depth between p and q in the Euler Path
Tree,Depth-First Search,Binary Tree
Medium
235,236,1790,1816
5
hello this is kevin i'm a software engineer at google and a graduate of the es program at uc berkeley go bears and today i want to talk about lee code problem number five longest palindromic substring this is a medium difficulty problem and cool so basically the problem says like you are given a string and you want to ...
Longest Palindromic Substring
longest-palindromic-substring
Given a string `s`, return _the longest_ _palindromic_ _substring_ in `s`. **Example 1:** **Input:** s = "babad " **Output:** "bab " **Explanation:** "aba " is also a valid answer. **Example 2:** **Input:** s = "cbbd " **Output:** "bb " **Constraints:** * `1 <= s.length <= 1000` * `s` consist of only dig...
How can we reuse a previously computed palindrome to compute a larger palindrome? If “aba” is a palindrome, is “xabax” a palindrome? Similarly is “xabay” a palindrome? Complexity based hint: If we use brute-force and check whether for every start and end position a substring is a palindrome we have O(n^2) start - end ...
String,Dynamic Programming
Medium
214,266,336,516,647
1,626
hey everyone welcome back and let's write some more neat code today so today let's solve the problem best team with no conflicts before we start I will say that this is very similar to the problem longest increasing subsequence which we've solved on this channel this problem is actually even harder than that problem so...
Best Team With No Conflicts
can-make-arithmetic-progression-from-sequence
You are the manager of a basketball team. For the upcoming tournament, you want to choose the team with the highest overall score. The score of the team is the **sum** of scores of all the players in the team. However, the basketball team is not allowed to have **conflicts**. A **conflict** exists if a younger player ...
Consider that any valid arithmetic progression will be in sorted order. Sort the array, then check if the differences of all consecutive elements are equal.
Array,Sorting
Easy
1752
561
hey everyone welcome back and today we'll be doing another lead chord array partition an easy one given integer array nums of an integers group these integers to and Pairs and such that the sum of Min a b and so all the maximize return the maximize some so we are given an array in which there are you can say our pairs ...
Array Partition
array-partition-i
Given an integer array `nums` of `2n` integers, group these integers into `n` pairs `(a1, b1), (a2, b2), ..., (an, bn)` such that the sum of `min(ai, bi)` for all `i` is **maximized**. Return _the maximized sum_. **Example 1:** **Input:** nums = \[1,4,3,2\] **Output:** 4 **Explanation:** All possible pairings (ignori...
Obviously, brute force won't help here. Think of something else, take some example like 1,2,3,4. How will you make pairs to get the result? There must be some pattern. Did you observe that- Minimum element gets add into the result in sacrifice of maximum element. Still won't able to find pairs? Sort the array and try t...
Array,Greedy,Sorting,Counting Sort
Easy
2112,2248,2261
1,099
welcome to problem 1099 two sum less than k we'll read the problem real quick given an array a of integers and integer k we turn the maximum as such that there exists i is less than j with element i plus element j equals s and s is less than k if no i and j exists satisfying this equation return negative one so that wa...
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
187
Jhaal Hello Hi Guys Welcome To Dad Today's Question Is Repeated DNA Sequence In This Question In The Given To See All The Ne Is Composed Series Follow This Zee Tv For Example ACG Ek TCG Midning DNA Test Subscribe Video Function Latest Song Sequence Aa Jaaye Aksar More Than bansi dna molecule shop word in this question ...
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
263
hi guys how are you so today we will solve our 18 day challenge question that is the ugly number so here we need to return true here we have a number and we need to return true if it has a factor and that factor is only Prime and that is limited to only two three and five okay so 6 as a factor 2 and 3 and that is limit...
Ugly Number
ugly-number
An **ugly number** is a positive integer whose prime factors are limited to `2`, `3`, and `5`. Given an integer `n`, return `true` _if_ `n` _is an **ugly number**_. **Example 1:** **Input:** n = 6 **Output:** true **Explanation:** 6 = 2 \* 3 **Example 2:** **Input:** n = 1 **Output:** true **Explanation:** 1 has n...
null
Math
Easy
202,204,264
102
welcome to lead programmer today we are going to look at the question binary tree level order traversal so we have been given a root of a binary tree and we have to return the level order traversal of its nodes values that is from left to right level by level uh so if you look at the example one what it essentially mea...
Binary Tree Level Order Traversal
binary-tree-level-order-traversal
Given the `root` of a binary tree, return _the level order traversal of its nodes' values_. (i.e., from left to right, level by level). **Example 1:** **Input:** root = \[3,9,20,null,null,15,7\] **Output:** \[\[3\],\[9,20\],\[15,7\]\] **Example 2:** **Input:** root = \[1\] **Output:** \[\[1\]\] **Example 3:** **I...
null
Tree,Breadth-First Search,Binary Tree
Medium
103,107,111,314,637,764,1035