Lunski's Clutter

This is a place to put my clutters, no matter you like it or not, welcome here.

0%

前幾天多年老友傳來這首歌,雖然接下來一個月目標不在這,但還不錯聽,就抓來研究一下。

Read more »

Given two integers a and b, return the sum of the two integers without using the operators + and -.

Example 1:

1
2
Input: a = 1, b = 2
Output: 3

Example 2:

1
2
Input: a = 2, b = 3
Output: 5
Read more »

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
2
Input: nums = [1,1,1,2,2,3], k = 2
Output: [1,2]

Example 2:

1
2
Input: nums = [1], k = 1
Output: [1]
Read more »

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
2
3
4
5
6
Input: n = 2
Output: [0,1,1]
Explanation:
0 --> 0
1 --> 1
2 --> 10

Example 2:

1
2
3
4
5
6
7
8
9
Input: n = 5
Output: [0,1,1,2,1,2]
Explanation:
0 --> 0 // 2%2
1 --> 1 // out[2/2]
2 --> 10 // out[2] = out[2/2]+2%2
3 --> 11 // out[3] = out[3/2]+3%2
4 --> 100
5 --> 101
Read more »