All Posts

Leetcode 268: Missing Number

Given an array nums containing n distinct numbers, each in the range [0, n], return the only number in the range that is missing from the array.

Leetcode 278: First Bad Version

You are managing a product development process where each version of the product is based on its previous version. However, you have a version that failed the quality check. Since all subsequent versions are based on the previous ones, they also fail the quality check. Your task is to find the first bad version that caused all subsequent versions to be bad. You are given an API bool isBadVersion(version) that returns true if the version is bad, and false otherwise. Your goal is to find the first bad version while minimizing the number of calls to the API.

Leetcode 283: Move Zeroes

Given an integer array nums, move all the zeros to the end while maintaining the relative order of the non-zero elements. Perform the operation in-place without making a copy of the array.

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 344: Reverse String

You are given a list of characters s. Your task is to reverse the order of characters in the list in-place, modifying the input list directly and without using any extra memory.