All Posts

Leetcode 287: Find the Duplicate Number

You are given an array nums of n + 1 integers where each integer is in the range [1, n]. The array contains exactly one duplicate number. Find and return this duplicate number without modifying the array and using constant extra space.

Leetcode 318: Maximum Product of Word Lengths

Given a list of words, return the maximum product of lengths of two words such that the two words do not share common letters. If no such pair exists, return 0.

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 342: Power of Four

Given an integer n, return true if it is a power of four. Otherwise, return false. An integer n is a power of four if there exists an integer x such that n == 4^x.

Leetcode 371: Sum of Two Integers

You are given two integers a and b. Return their sum without using the + or - operators. You must implement the solution using bitwise operations.

Leetcode 393: UTF-8 Validation

You are given an array of integers data, where each integer represents one byte of data. Your task is to check whether this sequence of bytes forms a valid UTF-8 encoded string based on the UTF-8 encoding rules for 1 to 4 bytes characters.