본문 바로가기

반응형

코딩 테스트/LeetCode(swift)

(28)
[LeetCode] 207. Course Schedule 문제 https://leetcode.com/problems/course-schedule/ Course Schedule - 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 ——————————————————————————— 잠깐만 로직에 대한 아이디어가 없으면 코드를 바로 보세요. ——————————————————————————— 코드 class Solution { let visited = 1 //이전에 방문한 course에 대한 값 let visiting = -1 ..
[LeetCode] 133. Clone Graph 문제 https://leetcode.com/problems/clone-graph/ Clone Graph - 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 ——————————————————————————— 잠깐만 leetCode에서 그래프 문제는 처음이에요. 그래서 그런지, 그래프 개념은 있지만, leetCode의 그래프 문제에 대한 input과 output에 대한 이해가 어려웠어요. 문제나 input, output을 이해하셨다면, 문제 풀이에 문제 없어요. ——..
[LeetCode] 55. Jump Game 문제 https://leetcode.com/problems/jump-game/ Jump Game - 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 ——————————————————————————— 잠깐만 이중 포문이 생각날수 있는데, 참아보세요. ——————————————————————————— 코드 class Solution { func canJump(_ nums: [Int]) -> Bool { var maxJumps = 1 for index in 0..
[LeetCode] 62. Unique Paths 문제 https://leetcode.com/problems/unique-paths/ Unique Paths - 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 ——————————————————————————— 코드 class Solution { func uniquePaths(_ m: Int, _ n: Int) -> Int { var map: [[Int]] = Array(repeating: Array(repeating: 0, count: n), count: m) f..
[LeetCode] 91. Decode Ways 문제 https://leetcode.com/problems/decode-ways/ Decode Ways - 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 ——————————————————————————— 잠깐만 이것 또한 체크하고 더하면서 진행해볼까요? ——————————————————————————— 코드 class Solution { func numDecodings(_ s: String) -> Int { var countFrom1: [Int] = Array(..
[LeetCode] 213. House Robber II 문제 https://leetcode.com/problems/house-robber-ii/ House Robber II - 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 ——————————————————————————— 잠깐만 이 문제에선 첫번째 집에 대한 도둑질 여부가 중요해보이네요. 아주 잘 생각해보면 198. House Robber 문제의 코드를 재활용할 수 있겠는데요??? 먼저 문제 풀고 오세요. https://skillist.tistory.com/325 ..
[LeetCode] 198. House Robber 문제 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 ——————————————————————————— 잠깐만 백준, 포도주 시식 문제 기억나세요? https://skillist.tistory.com/233?category=258048 DP - 2156. 포도주 시식 문제 www.acmicpc.net/problem/2156 2156번: 포도주 시식 효주는 포도..
[LeetCode] 377. Combination Sum IV 문제 https://leetcode.com/problems/combination-sum-iv/ Combination Sum IV - 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 ——————————————————————————— 잠깐만 우리가 함께 풀었던 322 Coin Change 문제와 로직의 거의 비슷해요. https://skillist.tistory.com/253?category=469513 [LeetCode] 322. Coin Change 문제 leet..
[LeetCode] 139. Word Break 문제 https://leetcode.com/problems/word-break/ Word Break - 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 ——————————————————————————— 잠깐만 word를 체크할때마다, 재귀함수를 호출하지 말고, 체크를 해볼까요???? ——————————————————————————— 코드 class Solution { func wordBreak(_ s: String, _ wordDict: [String]) -> B..
[LeetCode] 300. Longest Increasing Subsequence 문제 leetcode.com/problems/longest-increasing-subsequence/ Longest Increasing 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 코드 22년 2월 17일 코드 class Solution { func lengthOfLIS(_ nums: [Int]) -> Int { var maxLength = 0 var lengths = Array(repeating: 1, count: nums.count..

반응형