BLBruce Lininblog.brucelinweb.com·Jun 29, 2025 · 4 min readLeetCode 153. Find Minimum in Rotated Sorted ArrayQuestion Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become: [4,5,6,7,0,1,2] if it was rotated 4 times. [0,1,2,4,5,6,7] if it was rotated 7 times. No...00
BLBruce Lininblog.brucelinweb.com·Jun 27, 2025 · 2 min readLeetCode 268: Missing Numberclass Solution { public: int missingNumber(vector<int>& nums) { int result = nums.size(); for (int i = 0; i < nums.size(); i++) { result ^= i ^ nums[i]; } return result; } }; Question Given an ar...00
BLBruce Lininblog.brucelinweb.com·Jun 26, 2025 · 2 min readLeetCode 338: Counting BitsProblem Overview Given an integer n, return an array ans of length n + 1 where ans[i] is the number of set bits in the binary representation of i. Example: n = 5 → Output: [0, 1, 1, 2, 1, 2] Constraints: 0 <= n <= 10^5 Solution 1: Brute Force Thi...00
BLBruce Lininblog.brucelinweb.com·Jun 12, 2025 · 2 min readLeetCode 191. Number of 1 BitsProblem Overview The goal is to write a function that takes an unsigned integer and returns the number of ‘1’ bits it has in its binary representation. This value is also known as Hamming weight. This is the classic bit manipulation problem. Solution...00