https://leetcode.com/problems/count-and-say/ Count and Say - 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 숫자를 입력받으면 숫자에 대한 counting을 진행한다 n = 1 return 1 n = 2 return 11 (1이 1개) n = 3 return 21 (1이 2개) n = 4 return 1211 (2가 1개, 1이 1개) n = 5 return 111221 (1이 1개, 2가 1개, 1이2개) impl..
https://leetcode.com/problems/rotate-image/ Rotate Image - 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 NxN의 크기를 가진 2차원 배열을 시계방향으로 한번 회전 시키는 문제이다. impl Solution { pub fn rotate(mut matrix: &mut Vec) { let mut v : Vec = matrix.clone(); let n = matrix.len(); for i in 0..n{ for j i..
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 주어진 숫자 n 만큼 계단을 올라가야 된다. 계단은 1칸 또는 2칸 올라갈 수 있다. 나올 수 있는 모든 경우의 수를 구하여 반환 한다. 문제에는 규칙이 있다. // 0 => 0 // 1 => 1 // 2 => 2 // 3 => 3 // 4 => 5 // 5 => 8 // 6 => 13 // 7 => ..
https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ Best Time to Buy and Sell Stock - 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 주식을 매수/매도 하여 가장 큰 차익의 결과를 반환하는 문제이다. 수익을 낼 수 없다면 0을 반환해야 된다. 숫자 배열이 주어진다. index는 하루를 의미하고 각 숫자는 그날의 주식 가격을 의미한다. ex) [7, 1, 5, 4, 6, 4]배열..
https://leetcode.com/problems/is-subsequence/ Is Subsequence - 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 문자열s, 문자열t를 준다. 문자열t에서 문자열s가 포함되어 있다면 true, 포함되어 있지 않다면 false 여기서 포함되어 있다는 의미는 문자열 s의 문자가 문자열 t의 문자에 순서대로 배치되어 있다는 의미이다. ex) s가 "abc", t가 "ahbgdc"일 경우 t의 0번째, 2번째, 5번째에 각각..
https://leetcode.com/problems/maximum-subarray/ Maximum Subarray - 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 정수 배열이 주어지면 배열내 인접 원소의 합중 가장 큰 합을 return 시키라는 문제이다 ex1) [-2,1,-3,4,-1,2,1,-5,4] 배열이 있다면 인접 원소중 4, -1, 2, 1을 합한 6이 가장 큰 숫자이다. ex2) [1] 배열에서는 1이 원소의 합 중 가장 큰 숫자이다. ex3) ..
![](http://i1.daumcdn.net/thumb/C148x148.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/dcehIa/btq4H8Vynho/YkKARHaa2WcRbr2Ok3HK9k/img.png)
leetcode.com/problems/k-closest-points-to-origin/submissions/ K Closest Points to Origin - 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 좌표를 가진 배열(points)과 반환 해야 되는 갯수(k)를 파라미터로 넘겨받는다. 좌표와 원점(0, 0) 사이의 거리가 가장 가까운 좌표를 반환시킨다. √(x₁ - x₂)² + (y₁ - y₂)² 유클리디안 계산법으로 계산한다. 튜플 형태의 check ..
leetcode.com/problems/intersection-of-two-arrays/ Intersection of Two Arrays - 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개 주고 중복되는 원소 있으면 그 원소를 배열에 담아서 반환 시키는 문제 2중 반복문으로 중복 원소를 배열에 쌓고 중복 제거 use std::collections::HashSet; impl Solution { pub fn intersection(nums1: Vec, nu..