[Easy] 191. Number of 1 Bits
leetCode 2022. 5. 24. 11:28

문제 Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight). Note: Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type. It should not affect your implementation, as the integer's internal binary representation is the same, whether it is sign..

[Easy] 70. Climbing Stairs
leetCode 2022. 5. 23. 15:52

문제 You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? 예시 Example 1: Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps Example 2: Input: n = 3 Output: 3 Explanation: There are three ways to climb to the top. 1. 1 step + 1 step + 1 s..

[Easy] 21. Merge Two Sorted Lists
leetCode 2022. 5. 18. 12:00

문제 You are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list. 예시 Example 1: Input: list1 = [1,2,4], list2 = [1,3,4] Output: [1,1,2,3,4,4] Example 2: Input: list1 = [], list2 = [] Output: [] Example 3: Input: list1 = [], list2..

[Easy] 206. Reverse Linked List
leetCode 2022. 5. 18. 11:35

문제 Given the head of a singly linked list, reverse the list, and return the reversed list. 예시 Example 1: Input: head = [1,2,3,4,5] Output: [5,4,3,2,1] Example 2: Input: head = [1,2] Output: [2,1] Example 3: Input: head = [] Output: [] 제약조건 Constraints: The number of nodes in the list is the range [0, 5000]. -5000