All Posts

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 537: Complex Number Multiplication

Given two complex numbers represented as strings, multiply them and return the result as a string in the format ‘real+imaginaryi’.

Leetcode 539: Minimum Time Difference

Given a list of time points in ‘HH:MM’ format, return the minimum time difference between any two distinct time points in the list.

Leetcode 553: Optimal Division

Given an array of integers, you need to add parentheses in such a way that the division expression evaluates to the maximum possible value. The division must respect the adjacency of integers in the array.

Leetcode 556: Next Greater Element III

Given a positive integer n, find the smallest integer which can be formed by rearranging the digits of n and is greater than n. If no such integer exists, return -1.

Leetcode 592: Fraction Addition and Subtraction

Given a string expression representing a mathematical expression with fractions involving addition and subtraction, compute the result of the expression. The result should be simplified and returned in the form of a fraction. If the result is an integer, represent it as a fraction with denominator 1.