前幾天多年老友傳來這首歌,雖然接下來一個月目標不在這,但還不錯聽,就抓來研究一下。
371. Sum of Two Integers
Given two integers a and b, return the sum of the two integers without using the operators + and -.
Example 1:
1 | Input: a = 1, b = 2 |
Example 2:
1 | Input: a = 2, b = 3 |
347. Top K Frequent Elements
Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.
Example 1:
1 | Input: nums = [1,1,1,2,2,3], k = 2 |
Example 2:
1 | Input: nums = [1], k = 1 |
英文補全
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.
Example 1:
1 | Input: n = 2 |
Example 2:
1 | Input: n = 5 |