전체 글
-
[Leetcode] 1189. Maximum Number of Balloons 문제풀이카테고리 없음 2021. 9. 13. 22:40
https://leetcode.com/problems/maximum-number-of-balloons/ Maximum Number of Balloons - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 내용 섞여있는 문자중에 balloon 이라는 단어가 몇개 나오는지 출력 Input: text = "nlaebolko" Output: 1 문제 풀이 알파벳이 몇개 나오는지만 확인하고 ballon 빈도수가 얼마나 되는지 출력한다. class Solution { ..
-
[Leetcode] 136. Single Number 문제 풀이Algorithm/문제풀이 2021. 9. 12. 21:30
https://leetcode.com/problems/single-number/ Single Number - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 내용 배열에 2개씩 숫자쌍이 있는데 혼자만 있는 숫자 찾기 Example 1: Input: nums = [2,2,1] Output: 1 문제 풀이 hash로 count 하는 단순한 방법은 공간 복잡도가 O(n) 만큼 든다. 공간 복잡도가 O(1) 만큼 하는 방법이 있다. xor 연산자를 활용하는 방법이다..
-
[Leetcode] 190. Reverse Bits 문제 풀이Algorithm/문제풀이 2021. 9. 12. 16:35
https://leetcode.com/problems/reverse-bits/ Reverse Bits - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 내용 주어진 bit를 reverse 하는 문제 Input: n = 00000010100101000001111010011100 Output: 964176192 (00111001011110000010100101000000) Explanation: The input binary string 000000101001..
-
[Leetcode] 191. Number of 1 Bits 문제 풀이Algorithm/문제풀이 2021. 9. 12. 16:17
https://leetcode.com/problems/number-of-1-bits/ Number of 1 Bits - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 내용 숫자 n이 있을 때, bit가 1인 갯수가 몇개인지 출력 Example 1: Input: n = 00000000000000000000000000001011 Output: 3 Explanation: The input binary string 000000000000000000000000000..
-
[Leetcode] 231. Power of Two 문제풀이Algorithm/문제풀이 2021. 9. 12. 16:10
https://leetcode.com/problems/power-of-two/ Power of Two - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 내용 주어진 정수 n이 2의 제곱인지 확인하는 문제 Example 1: Input: n = 1 Output: true Explanation: 2^0 = 1 문제 풀이 2의 제곱근을 생각하면 bit로 표현했을 때 1인 개수가 1개인 숫자이다. 처음에는 loop를 돌면서 bit개수를 세고 판단하려고 했으나 O(..
-
[Leetcode] 120. Triangle 문제풀이Algorithm/문제풀이 2021. 9. 12. 15:45
https://leetcode.com/problems/triangle/ Triangle - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 내용 삼각형 배열에서 탑에서 바닥까지 경로를 구할 때 경로의 합이 최소인 값을 구하는 문제 경로는 i, i + 1칸 움직일 수 있다. Example 1: Input: triangle = [[2],[3,4],[6,5,7],[4,1,8,3]] Output: 11 Explanation: The triangle looks lik..
-
[Leetcode] 198. House Robber 문제풀이Algorithm/문제풀이 2021. 9. 10. 19:54
https://leetcode.com/problems/house-robber/ House Robber - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 내용 도둑질 하는데 인접한 집은 할 수 없다. 주어진 배열은 집의 돈이라고 볼 수 있고 클수록 좋다. 가장 많이 돈을 벌 수 있는 값을 찾는 문제 Example 1: Input: nums = [1,2,3,1] Output: 4 Explanation: Rob house 1 (money = 1) and then..
-
[Leetcode] 70. Climbing Stairs 문제풀이Algorithm/문제풀이 2021. 9. 10. 19:44
https://leetcode.com/problems/climbing-stairs/ Climbing Stairs - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 내용 1칸 또는 2칸을 갈 수 있는데 도착할때 까지 가능한 모든 경우의 수 구하는 문제 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 ..