contest

[Solved] Minimum Recolors to Get K Consecutive Black Blocks LeetCode Contest

[Solved] Minimum Recolors to Get K Consecutive Black Blocks LeetCode Contest

You are given a 0-indexed string blocks of length n, where blocks[i] is either ‘W’ or ‘B’, representing the color of the ith block. The characters ‘W’ and ‘B’ denote the colors white and black, respectively. You are also given an integer k, which is the desired number of consecutive black blocks. In one operation, you can recolor a white block…

[Solved] Construct Smallest Number From DI String LeetCode Contest Problem

[Solved] Construct Smallest Number From DI String LeetCode Contest Problem

You are given a 0-indexed string pattern of length n consisting of the characters ‘I’ meaning increasing and ‘D’ meaning decreasing. A 0-indexed string num of length n + 1 is created using the following conditions: num consists of the digits ‘1’ to ‘9’, where each digit is used at most once. If pattern[i] == ‘I’, then num[i] < num[i + 1]. If pattern[i] == ‘D’, then num[i] >…

[Solved] Node With Highest Edge Score LeetCode Contest Problem

[Solved] Node With Highest Edge Score LeetCode Contest Problem

You are given a directed graph with n nodes labeled from 0 to n – 1, where each node has exactly one outgoing edge. The graph is represented by a given 0-indexed integer array edges of length n, where edges[i] indicates that there is a directed edge from node i to node edges[i]. The edge score of a node i is defined as…

[Solved] Minimum Replacements to Sort the Array LeetCode Contest

[Solved] Minimum Replacements to Sort the Array LeetCode Contest

You are given a 0-indexed integer array nums. In one operation you can replace any element of the array with any two elements that sum to it. For example, consider nums = [5,6,7]. In one operation, we can replace nums[1] with 2 and 4 and convert nums to [5,2,4,7]. Return the minimum number of operations to make an…

[Solved] Task Scheduler II LeetCode Contest

[Solved] Task Scheduler II LeetCode Contest

You are given a 0-indexed array of positive integers tasks, representing tasks that need to be completed in order, where tasks[i] represents the type of the ith task. You are also given a positive integer space, which represents the minimum number of days that must pass after the completion of a task before another task…

[Solved] Number of Excellent Pairs LeetCode Contest Problem

[Solved] Number of Excellent Pairs LeetCode Contest Problem

You are given a 0-indexed positive integer array nums and a positive integer k. A pair of numbers (num1, num2) is called excellent if the following conditions are satisfied: Both the numbers num1 and num2 exist in the array nums. The sum of the number of set bits in num1 OR num2 and num1 AND num2 is greater than…