All Posts

Leetcode 338: Counting Bits

Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1’s in the binary representation of i.

Leetcode 343: Integer Break

You are given an integer n. Your task is to break it into a sum of at least two positive integers such that the product of these integers is maximized. Return the maximum product that can be obtained.

Leetcode 357: Count Numbers with Unique Digits

Given an integer n, return the count of all numbers with unique digits x, such that 0 <= x < 10^n.

Leetcode 368: Largest Divisible Subset

You are given a set of distinct positive integers. Return the largest subset where every pair of elements in the subset satisfies either ‘one element is divisible by the other’.

Leetcode 375: Guess Number Higher or Lower II

In this game, you must guess a number between 1 and n. Each wrong guess costs you the amount of the guessed number. Your goal is to minimize the total cost while guaranteeing a win. If you run out of money, you lose the game.

Leetcode 376: Wiggle Subsequence

A wiggle subsequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with one element and a sequence with two non-equal elements are trivially wiggle sequences. Given an integer array nums, return the length of the longest wiggle subsequence of nums.