- 173
- 6 725
Code With K5KC
Germany
Приєднався 18 сер 2020
Welcome to Code with K5KC!
Dive into the ultimate destination for all things coding interviews and beyond. Our channel is dedicated to providing high-quality, comprehensive tutorials and insights that will help you ace your coding interview and excel in your tech career.
Learn from basic to advance coding skills and become a better programmer:
- Datastructure and Algorithms
- System Design
- Programming Languages like Java, Python, and more
And Much More: Stay tuned for a variety of content that will take your coding skills to the next level.
Whether you're prepping for an upcoming interview or looking to broaden your programming knowledge, Code with K5KC is here to support you every step of the way. Subscribe and join our community of learners and future tech leaders! 🚀
Dive into the ultimate destination for all things coding interviews and beyond. Our channel is dedicated to providing high-quality, comprehensive tutorials and insights that will help you ace your coding interview and excel in your tech career.
Learn from basic to advance coding skills and become a better programmer:
- Datastructure and Algorithms
- System Design
- Programming Languages like Java, Python, and more
And Much More: Stay tuned for a variety of content that will take your coding skills to the next level.
Whether you're prepping for an upcoming interview or looking to broaden your programming knowledge, Code with K5KC is here to support you every step of the way. Subscribe and join our community of learners and future tech leaders! 🚀
Construct String With Repeat Limit
Problem Description
You are given a string s and an integer repeatLimit. Construct a new string repeatLimitedString using the characters of s such that no letter appears more than repeatLimit times in a row. You do not have to
use all characters from s.
Return thelexicographically largest repeatLimitedString possible.
A string a is lexicographically larger than a string b if in the first position where a and b differ, string a has a letter that appears later in the alphabet than the corresponding letter in b. If the first min(a.length, b.length) characters do not differ, then the longer string is the lexicographically larger one.
Problem: leetcode.com/problems/construct-string-with-repeat-limit/
Code link: k5kc.com/cs/algorithms/construct-string-with-repeat-limit-problem/
You are given a string s and an integer repeatLimit. Construct a new string repeatLimitedString using the characters of s such that no letter appears more than repeatLimit times in a row. You do not have to
use all characters from s.
Return thelexicographically largest repeatLimitedString possible.
A string a is lexicographically larger than a string b if in the first position where a and b differ, string a has a letter that appears later in the alphabet than the corresponding letter in b. If the first min(a.length, b.length) characters do not differ, then the longer string is the lexicographically larger one.
Problem: leetcode.com/problems/construct-string-with-repeat-limit/
Code link: k5kc.com/cs/algorithms/construct-string-with-repeat-limit-problem/
Переглядів: 5
Відео
Final Array State After K Multiplication Operations I - Leetcode 3264 - Java
Переглядів 72 години тому
Problem Description You are given an integer array nums, an integer k, and an integer multiplier. You need to perform k operations on nums. In each operation: Find the minimum value x in nums. If there are multiple occurrences of the minimum value, select the one that appears first. Replace the selected minimum value x with x * multiplier. Return an integer array denoting the final state of num...
Find Score of an Array After Marking All Elements - Leetcode 2593 - Java
Переглядів 329 годин тому
Problem Description You are given an array nums consisting of positive integers. Starting with score = 0, apply the following algorithm: - Choose the smallest integer of the array that is not marked. If there is a tie, choose the one with the smallest index. - Add the value of the chosen integer to `score`. - Mark the chosen element and its two adjacent elements if they exist . - Repeat until a...
Take Gifts From the Richest Pile
Переглядів 1212 годин тому
Problem Description You are given an integer array gifts denoting the number of gifts in various piles. Every second, you do the following: Choose the pile with the maximum number of gifts. If there is more than one pile with the maximum number of gifts, choose any. Leave behind the floor of the square root of the number of gifts in the pile. Take the rest of the gifts. Return the number of gif...
Special Array II - Leetcode 3152 - Java
Переглядів 6319 годин тому
Problem Description An array is considered special if every pair of its adjacent elements contains two numbers with different parity. You are given an array of integer nums and a 2D integer matrix queries, where for queries[i] = [fromi, toi] your task is to check that subarray nums[fromi..toi] is special or not. Return an array of booleans answer such that answer[i] is true if nums[fromi..toi] ...
Maximum Number of Integers to Choose From a Range I - Leetcode 2554 - Java
Переглядів 24День тому
Problem Description You are given an integer array banned and two integers n and maxSum. You are choosing some number of integers following the below rules: The chosen integers have to be in the range [1, n]. Each integer can be chosen at most once. The chosen integers should not be in the array banned. The sum of the chosen integers should not exceed maxSum. Return the maximum number of intege...
Move Pieces to Obtain a String - Leetcode 2337 - Java
Переглядів 27День тому
You are given two strings start and target, both of length n. Each string consists only of the characters 'L', 'R', and '_' where: The characters 'L' and 'R' represent pieces, where a piece 'L' can move to the left only if there is a blank space directly to its left, and a piece 'R' can move to the right only if there is a blank space directly to its right. The character '_' represents a blank ...
Make String a Subsequence Using Cyclic Increments - Leetcode 2825 - Java
Переглядів 26День тому
You are given two 0-indexed strings str1 and str2. In an operation, you select a set of indices in str1, and for each index i in the set, increment str1[i] to the next character cyclically. That is 'a' becomes 'b', 'b' becomes 'c', and so on, and 'z' becomes 'a'. Return true if it is possible to makestr2 a subsequence ofstr1 by performing the operationat most once , and false otherwise. Note: A...
Maximum XOR for Each Query - Leetcode 1829 - Java
Переглядів 24Місяць тому
Problem Description You are given a sorted array nums of n non-negative integers and an integer maximumBit. You want to perform the following query n times: Find a non-negative integer k < 2maximumBit such that nums[0] XOR nums[1] XOR ... XOR nums[nums.length-1] XOR k is maximized. k is the answer to the ith query. Remove the last element from the current array nums. Return an array answer, whe...
Largest Combination With Bitwise AND Greater Than Zero - Leetcode 2275 - Java
Переглядів 39Місяць тому
Problem Description The bitwise AND of an array nums is the bitwise AND of all integers in nums. For example, for nums = [1, 5, 3], the bitwise AND is equal to 1 & 5 & 3 = 1. Also, for nums = [7], the bitwise AND is 7. You are given an array of positive integers candidates. Evaluate the bitwise AND of every combination of numbers of candidates. Each number in candidates may only be used once in...
Find if Array Can Be Sorted - Leetcode 3011 - Java | 3 Approaches
Переглядів 67Місяць тому
Problem Description You are given a 0-indexed array of positive integers nums. In one operation, you can swap any two adjacent elements if they have the same number of set bits. You are allowed to do this operation any number of times (including zero). Return true if you can sort the array, else return false. Problem: leetcode.com/problems/find-if-array-can-be-sorted Code link: k5kc.com/cs/algo...
Minimum Number of Changes to Make Binary String Beautiful - Leetcode 2914 - Java
Переглядів 82Місяць тому
Problem Description You are given a 0-indexed binary string s having an even length. A string is beautiful if it's possible to partition it into one or more substrings such that: Each substring has an even length. Each substring contains only 1's or only 0's. You can change any character in s to 0 or 1. Return the minimum number of changes required to make the string s beautiful. Problem: leetc...
String Compression III - Leetcode 3163 - Java
Переглядів 99Місяць тому
Problem Description Given a string word, compress it using the following algorithm: Begin with an empty string comp. While word is not empty, use the following operation: Remove a maximum length prefix of word made of a single character c repeating at most 9 times. Append the length of the prefix followed by c to comp. Return the string comp. Problem: leetcode.com/problems/string-compression-ii...
Circular Sentence - Leetcode 2490 - Java
Переглядів 34Місяць тому
Problem Description A sentence is a list of words that are separated by a single space with no leading or trailing spaces. For example, "Hello World", "HELLO", "hello world hello world" are all sentences. Words consist of only uppercase and lowercase English letters. Uppercase and lowercase English letters are considered different. A sentence is circular if: The last character of a word is equa...
Delete Characters to Make Fancy String - Leetcode 1957 - Java
Переглядів 69Місяць тому
Problem Description 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. Problem: leetcode.com/problems/delete-characters-to-make-fancy-string Code link: k5kc.com/cs/algorithms/delete...
Remove Sub-Folders from the Filesystem - Leetcode 1233 - Java
Переглядів 27Місяць тому
Remove Sub-Folders from the Filesystem - Leetcode 1233 - Java
Longest Square Streak in an Array - Leetcode 2501 - Java
Переглядів 31Місяць тому
Longest Square Streak in an Array - Leetcode 2501 - Java
Height of Binary Tree After Subtree Removal Queries - Leetcode 2458 - Java
Переглядів 37Місяць тому
Height of Binary Tree After Subtree Removal Queries - Leetcode 2458 - Java
Flip Equivalent Binary Trees - Leetcode 951 - Java
Переглядів 48Місяць тому
Flip Equivalent Binary Trees - Leetcode 951 - Java
Cousins in Binary Tree II - Leetcode 2641 - Java
Переглядів 18Місяць тому
Cousins in Binary Tree II - Leetcode 2641 - Java
Kth Largest Sum in a Binary Tree - Leetcode 2583 - Java
Переглядів 25Місяць тому
Kth Largest Sum in a Binary Tree - Leetcode 2583 - Java
Split a String Into the Max Number of Unique Substrings - Leetcode 1593 - Java
Переглядів 97Місяць тому
Split a String Into the Max Number of Unique Substrings - Leetcode 1593 - Java
Count Number of Maximum Bitwise-OR Subsets - Leetcode 2044 - Java
Переглядів 28Місяць тому
Count Number of Maximum Bitwise-OR Subsets - Leetcode 2044 - Java
Longest Happy String - Leetcode 1405 - Java
Переглядів 472 місяці тому
Longest Happy String - Leetcode 1405 - Java
Separate Black and White Balls - Leetcode 2938 - Java
Переглядів 522 місяці тому
Separate Black and White Balls - Leetcode 2938 - Java
Maximal Score After Applying K Operations - Leetcode 2530 - Java
Переглядів 552 місяці тому
Maximal Score After Applying K Operations - Leetcode 2530 - Java
The Number of the Smallest Unoccupied Chair - Leetcode 1942 - Java
Переглядів 662 місяці тому
The Number of the Smallest Unoccupied Chair - Leetcode 1942 - Java
Minimum Add to Make Parentheses Valid - Leetcode 921 - Java
Переглядів 422 місяці тому
Minimum Add to Make Parentheses Valid - Leetcode 921 - Java
Thanks
Excellent explanation, thank you
great
❤❤❤❤
Happy Coding 😊
Thank you 🫰
Very well explained!
NICE 🎉
Nice explanation
I saw this solution in TS, it was so confusing but this explanation cleared everything up. It makes a lot of sense, it's like a sliding window, you're just upping the frequency of each number already present when shifting each duplicate to become a unique number wow. Ty!
Glad that it makes sense to you :)
Nice Video, straight to the point and the slides are well made