All Posts

Leetcode 477: Total Hamming Distance

The Hamming distance between two integers is the number of positions at which the corresponding bits differ. Given an integer array nums, return the sum of Hamming distances between all pairs of integers in nums.

Leetcode 486: Predict the Winner

You are given an integer array nums. Two players, Player 1 and Player 2, take turns to pick numbers from either end of the array. Each player adds the selected number to their score. The goal is to determine if Player 1 can win the game. Player 1 wins if they have a higher score or if the scores are tied.

Leetcode 497: Random Point in Non-overlapping Rectangles

You are given an array of non-overlapping axis-aligned rectangles. Each rectangle is represented by its bottom-left and top-right corner. Your task is to design a system that can pick a random integer point from the space covered by one of the given rectangles. A point on the perimeter of a rectangle is considered inside the rectangle.

Leetcode 509: Fibonacci Number

The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, starting from 0 and 1. Given an integer n, return the nth Fibonacci number.

Leetcode 519: Random Flip Matrix

You are given a binary grid of size m x n, where each cell is initially set to 0. The task is to design an algorithm that can randomly pick a cell that is still 0, flip it to 1, and ensure that all available cells are equally likely to be selected.

Leetcode 523: Continuous Subarray Sum

Given an integer array nums and an integer k, return true if there exists a good subarray, otherwise return false. A good subarray is defined as a subarray whose length is at least 2 and the sum of its elements is a multiple of k.