All Posts

Leetcode 475: Heaters

You are given the positions of houses and heaters along a horizontal line. Your task is to find the minimum radius required for the heaters so that all houses are within the heater’s warm radius.

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 528: Random Pick with Weight

You are given a 0-indexed array of positive integers w, where w[i] describes the weight of the ith index. You need to implement the function pickIndex() which randomly picks an index in the range [0, w.length - 1] (inclusive), and the probability of picking index i is w[i] / sum(w).

Leetcode 532: K-diff Pairs in an Array

Given an array of integers nums and an integer k, return the number of unique k-diff pairs in the array. A k-diff pair is a pair of integers (nums[i], nums[j]) where the absolute difference between the values of the pair is k, and i != j.

Leetcode 540: Single Element in a Sorted Array

You are given a sorted array where every element appears exactly twice, except for one element which appears only once. Find and return the single element that does not have a pair.

Leetcode 611: Valid Triangle Number

Given an array of integers, return the number of triplets that can form a valid triangle. A valid triangle is formed when the sum of any two sides is greater than the third side.