All Posts

Leetcode 2466: Count Ways To Build Good Strings

You are tasked with constructing binary strings using the characters ‘0’ and ‘1’. The string can be built by repeatedly appending ‘0’ zero times or ‘1’ one times, where ‘zero’ and ‘one’ are given values. The length of the final string must lie between ’low’ and ‘high’, inclusive. Your task is to find how many different binary strings can be created that meet these requirements. Return the count modulo 1e9 + 7.

Leetcode 2467: Most Profitable Path in a Tree

In a tree with n nodes labeled from 0 to n - 1, each node has a gate with a price to open. Alice starts at node 0 and Bob starts at node bob. Alice moves towards a leaf node, and Bob moves towards node 0. At every node, both Alice and Bob either pay the price to open the gate, or they receive a reward. If they reach a node simultaneously, they share the price/reward equally. Return the maximum net income Alice can achieve if she travels towards the optimal leaf node.

Leetcode 2470: Number of Subarrays With LCM Equal to K

Given an integer array nums and an integer k, return the number of subarrays where the Least Common Multiple (LCM) of all the elements in the subarray equals k. A subarray is a contiguous subsequence of elements in the array.

Leetcode 2471: Minimum Number of Operations to Sort a Binary Tree by Level

You are given the root of a binary tree with unique values. In one operation, you can choose any two nodes at the same level and swap their values. Return the minimum number of operations needed to make the values at each level sorted in strictly increasing order.

Leetcode 2476: Closest Nodes Queries in a Binary Search Tree

You are given the root of a binary search tree (BST) and an array of queries. For each query, find the largest value smaller than or equal to the query value and the smallest value greater than or equal to the query value in the tree.

Leetcode 2477: Minimum Fuel Cost to Report to the Capital

A country network consists of n cities connected by n-1 bidirectional roads. The capital city is city 0, and each city has one representative with a car having a fixed number of seats. Calculate the minimum amount of fuel required for all representatives to reach the capital city.