<![CDATA[LeetCode on Roman Kurnovskii]]>Follow LeetCode on Roman Kurnovskii, filter it, and define how you want to receive the news (via Email, RSS, Telegram, WhatsApp etc.)
https://follow.it/leetcode-on-roman-kurnovskii
Fri, 01 Dec 2023 08:44:27 +0200<![CDATA[1887. Reduction Operations to Make the Array Elements Equal]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZTlVcttSdja68qfTAM-Smm
LeetCode Problem 1887
Problem Statement The goal of this problem is to make all elements in a given integer array nums equal, through a series of reduction operations. In each operation, we find the largest element in the array, find the next largest element that is strictly smaller than the largest, and reduce the largest element to this next largest value. The task is to return the number of such operations needed to make all array elements equal.]]>Sun, 19 Nov 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZTlVcttSdja68qfTAM-Smm<![CDATA[343. Integer Break]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsbhxqVyi154X8qq6eZJzUh9
LeetCode problem 343
Problem Statement Given a positive integer n, our task is to divide it into the sum of ( k ) positive integers, where ( k \geq 2 ), in such a way that the product of these integers is maximized. Our goal is to determine the maximum possible product.
Naive Solution A straightforward or naive way to solve this would be to consider all potential combinations to divide the number n and calculate the product for each division.]]>Fri, 06 Oct 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsbhxqVyi154X8qq6eZJzUh9<![CDATA[229. Majority Element II]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsbhxqVyi154X58v71dCn6bG
LeetCode problem 229
Problem Statement Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.
Naive Solution The immediate solution would involve using a hashmap or dictionary to track the occurrence of each number in the array. After which, we can iterate over the dictionary to find numbers whose occurrences are greater than n/3.
Hints & Tips There can be at most one or two majority elements which appear more than n/3 times in the array.]]>Thu, 05 Oct 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsbhxqVyi154X58v71dCn6bG<![CDATA[389. Find the Difference]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsbGZVI1yjKcFSRFMxTa8z4W
LeetCode problem 389
Problem Statement Given two strings s and t, the string t is generated by shuffling the characters of s and adding one additional character at a random position. The task is to identify and return that extra character.
Naive Solution A naive solution would involve comparing the characters in both strings one by one to detect the extra character in t. This method is not efficient as it could take a linear amount of time for strings of considerable lengths.]]>Tue, 26 Sep 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsbGZVI1yjKcFSRFMxTa8z4W<![CDATA[799. Champagne Tower]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsYETYD-ARb9m-ifqJurszLU
LeetCode problem 799
Problem Statement You are tasked with modeling a champagne tower. Glasses are stacked in a pyramid, with each row having one more glass than the previous. When champagne is poured into the top glass and it overflows, the overflowed champagne is split equally between the two glasses below. The objective is to determine how full a specified glass will be after pouring a given amount of champagne.
Naive Solution One could imagine a simulation, where we pour champagne into the top glass and then, glass-by-glass, simulate the overflow until we reach the desired glass.]]>Sat, 23 Sep 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsYETYD-ARb9m-ifqJurszLU<![CDATA[1048. Longest String Chain]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsYETYD-ARb9m5u9CxXrVx4c
LeetCode problem 1048
Problem Statement You are given an array of words where each word consists of lowercase English letters. Your task is to determine the longest string chain you can form given this list. A word A can be a predecessor of word B if by adding exactly one letter to A (at any position), B is formed. The objective is to find the longest sequence where each word is a predecessor of the next.
Naive Solution The straightforward brute-force way would be to try all possible combinations of word chains.]]>Fri, 22 Sep 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsYETYD-ARb9m5u9CxXrVx4c<![CDATA[1658. Minimum Operations to Reduce X to Zero]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsb0fqm2RHUUuGsGk81fO-bN
LeetCode problem 1658
Problem Statement You have an integer array nums and another integer x. In a single operation, you can either remove the leftmost or the rightmost element from the array nums and decrement x by the value of the removed element. The question is: What is the minimum number of operations required to reduce x to exactly zero? If it’s not feasible, the answer should be -1.
Naive Solution The naive approach would be to explore every possible combination of removing elements from the start or the end, recursively.]]>Wed, 20 Sep 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsb0fqm2RHUUuGsGk81fO-bN<![CDATA[847. Shortest Path Visiting All Nodes]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsYqZYjcQprZBKgzzHWHxDTV
LeetCode problem 847
Problem Statement Given an undirected, connected graph of n nodes labeled from 0 to n - 1. An array graph is provided where graph[i] is a list of all the nodes connected with node i by an edge. The objective is to determine the length of the shortest path that visits every node.
It’s permissible to start and stop at any node, revisit nodes multiple times, and reuse edges.
Naive Solution A naive approach would be to attempt all possible paths (brute force) until all nodes are visited.]]>Sun, 17 Sep 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsYqZYjcQprZBKgzzHWHxDTV<![CDATA[2856. Minimum Array Length After Pair Removals]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZs8C6tb1cTmJNaYRWadcX6
LeetCode problem
Problem Statement Given a 0-indexed sorted array of integers nums, you can perform a specific operation an unlimited number of times:
Choose two indices, i and j, where i < j and nums[i] < nums[j]. Remove the elements at indices i and j from nums. The remaining elements retain their original order and the array is re-indexed. The task is to determine and return the smallest possible length of nums after executing the operation as many times as you wish.]]>Sat, 16 Sep 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZs8C6tb1cTmJNaYRWadcX6<![CDATA[1372. Longest ZigZag Path in a Binary Tree]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZLDyhRwtZHTMlTP0vptTFR
LeetCode problem 1372
Problem Statement Given the root of a binary tree, the task is to find the longest ZigZag path contained in that tree. A ZigZag path is defined by a sequence starting at any node and switching between left and right directions at each subsequent step.
Naive Solution A simplistic approach would be to kick off from every node and emulate the ZigZag movement until it’s no longer feasible, all the while updating the longest path encountered.]]>Sun, 10 Sep 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZLDyhRwtZHTMlTP0vptTFR<![CDATA[1359. Count All Valid Pickup and Delivery Options]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZLDyhRwtZHTN5ZnUTwRGH7
LeetCode problem 1359
Problem Statement You’re tasked with finding all valid sequences of pickup and delivery events for n orders such that for every order, the delivery always comes after its respective pickup. Because the answer can be immense, you’re to return the result modulo (10^9 + 7).
Naive Solution A straightforward approach might be to generate all potential permutations of pickup and delivery actions and then exclude the unsuitable ones. However, this method would be exceedingly inefficient and would not scale for larger n values.]]>Sun, 10 Sep 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZLDyhRwtZHTN5ZnUTwRGH7<![CDATA[725. Split Linked List in Parts]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsY5xQUx4wvu1oMOI2eu70Rg
LeetCode problem 725
Problem Statement The problem asks you to divide a given singly linked list into k different parts such that the sizes of these parts are as nearly equal as possible. The parts should appear in the same order as in the original list, and earlier parts should not be smaller than later parts.
Naive Solution A naive approach would involve counting the length of the list and then traversing the list multiple times to create each part.]]>Wed, 06 Sep 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsY5xQUx4wvu1oMOI2eu70Rg<![CDATA[2842. Count K-Subsequences of a String with Maximum Beauty]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZKCf6cGnsQx-Gkz6RCC25z
LeetCode problem
Problem Statement You are given a string s and an integer k. A k-subsequence is a subsequence of s, having length k, and all its characters are unique. The beauty of a k-subsequence is the sum of f(c) for every character c in the k-subsequence. Here, f(c) denotes the number of times the character c occurs in s.
The task is to find the number of k-subsequences whose beauty is maximum among all k-subsequences. Return the answer modulo $(10^9 + 7)$.]]>Sat, 02 Sep 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZKCf6cGnsQx-Gkz6RCC25z<![CDATA[2841. Maximum Sum of Almost Unique Subarray]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZKCf6cGnsQx1hGNgNo2_0q
LeetCode Problem 2841
Problem Statement You are given an integer array nums and two positive integers m and k.
The task is to return the maximum sum out of all almost unique subarrays of length k of nums. If no such subarray exists, return 0.
A subarray is almost unique if it contains at least m pairwise distinct elements.
Naive Solution A naive solution would be to generate all the possible subarrays of length k and check each one to see if it is almost unique and what its sum is.]]>Sat, 02 Sep 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZKCf6cGnsQx1hGNgNo2_0q<![CDATA[2840. Check if Strings Can be Made Equal With Operations II]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZKCf6cGnsQxwVLTsI7B9NX
LeetCode Problem 2840
Problem Statement You are given two strings s1 and s2, both of length n, consisting of lowercase English letters. You can apply certain operations to make them equal. The question is, is it possible?
Naive Solution A naive approach would be to try all possible swap operations and compare the two strings at each step, which would be highly inefficient.
Hints & Tips Observe that swapping can only occur at indices i and j where j - i is even.]]>Sat, 02 Sep 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZKCf6cGnsQxwVLTsI7B9NX<![CDATA[2839. Check if Strings Can be Made Equal With Operations I]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZKCf6cGnsQx-QEmsPXZ5C9
LeetCode Problem
Problem Statement You are given two strings s1 and s2, both of length 4, consisting of lowercase English letters. The objective is to find out if it’s possible to make the two strings equal by swapping certain pairs of characters.
Naive Solution A naive approach would be to try out all possible swap combinations. However, this can be very inefficient, especially when the strings have a large number of characters.
Hints & Tips Observe that the swapping condition is quite specific: j - i = 2.]]>Sat, 02 Sep 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZKCf6cGnsQx-QEmsPXZ5C9<![CDATA[2390. Removing Stars From a String]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZKCf6cGnsQx2sGk81fO-bN
LeetCode problem
Problem Statement You are provided with a string s that contains asterisks or stars (*). Your task is to transform this string. In each operation, you’ll select a star and remove the character immediately to its left and the star itself. Continue this process until there are no stars left in the string.
The challenge guarantees that the input string can always be transformed as per the given operation, and the result will always be unique.]]>Thu, 24 Aug 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZKCf6cGnsQx2sGk81fO-bN<![CDATA[LeetCode Top 75]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZKCf6cGnsQxx-xWH3zZqEA
Array / String # Problem Difficulty Slides/Video 1 1768. Merge Strings Alternately Easy ✅ ✅ 2 1071. Greatest Common Divisor of Strings Easy ✅ ✅ 3 1431. Kids With the Greatest Number of Candies Easy ✅ ✅ 4 605. Can Place Flowers Easy 5 345. Reverse Vowels of a String Easy 6 151. Reverse Words in a String Medium ✅ 7 238. Product of Array Except Self Medium 8 334. Increasing Triplet Subsequence Medium 9 443. String Compression Medium Two Pointers # Problem Difficulty 10 283.]]>Tue, 01 Aug 2023 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZKCf6cGnsQxx-xWH3zZqEA<![CDATA[Easy]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZKCf6cGnsQxyuZukmJ4mr4
]]>Sun, 16 Oct 2022 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZKCf6cGnsQxyuZukmJ4mr4<![CDATA[Hard]]>
https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZKCf6cGnsQxxeIF_fEM9tn
]]>Sun, 16 Oct 2022 02:00:00 +0200https://api.follow.it/track-rss-story-click/v3/Gl9rgkxTNsZKCf6cGnsQxxeIF_fEM9tn