java

[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…