All Posts

Leetcode 1509: Minimum Difference Between Largest and Smallest Value in Three Moves

You are given an integer array. In one move, you can change any element of the array to any value. Perform at most three moves to minimize the difference between the largest and smallest values of the array.

Leetcode 1512: Number of Good Pairs

You are given an array of integers. A pair (i, j) is called a good pair if nums[i] == nums[j] and i < j. Your task is to find the number of good pairs in the array.

Leetcode 1514: Path with Maximum Probability

You are given an undirected, weighted graph of n nodes, represented by an edge list, where each edge connects two nodes with a given success probability. Given two nodes, start and end, find the path with the maximum probability of success to go from start to end.

Leetcode 1524: Number of Sub-arrays With Odd Sum

You are given an array of integers arr. Your task is to count the number of subarrays whose sum is odd. Since the answer can be a large number, return it modulo (10^9 + 7).

Leetcode 1535: Find the Winner of an Array Game

You are given an array of distinct integers and an integer k. The game is played between the first two elements of the array. In each round, the larger integer wins and remains at position 0, while the smaller integer moves to the end of the array. The game ends when one integer wins k consecutive rounds. Your task is to return the integer that wins the game.

Leetcode 1536: Minimum Swaps to Arrange a Binary Grid

You are given an n x n binary grid, and in one move, you can swap any two adjacent rows. The grid is valid if all the cells above the main diagonal are zeros. Your task is to return the minimum number of swaps needed to make the grid valid, or -1 if it’s not possible.