본문 바로가기

전체 글114

LeetCode - 98. Validate Binary Search Tree - swift https://leetcode.com/problems/validate-binary-search-tree/ Validate Binary Search Tree - 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 주어진 노드를 이진 탐색 트리인지 판별하는 문제다. 이진 탐색 트리는 왼쪽 자식 노드는 부모 노드보다 작아야 하며, 오른쪽 자식 노드는 부모 노드보다 커야 한다. 뿐만 아니라, 자식의 자식들도 부모 노드보다 크거나 작아야 한다. 즉 아래의 경우는 이진 탐색 트.. 2021. 8. 20.
LeetCode - 207. Course Schedule - swift 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 numCourse 라는 숫자변수가 총 들어야하는 수강과목 수 이다. prerequisits [Int] 배열이 들어오는데, 각각 [ a, b ] 를 갖는데, 이는 a를 수강하기 위해서는 b를 필수적으로 수강해야 한다는 뜻이다. a, b 는 numCourse보다 무조건 작은 숫자이다. prerequisit.. 2021. 8. 20.
LeetCode - 36. Valid Sudoku - swift https://leetcode.com/problems/valid-sudoku/ Valid Sudoku - 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 간단한 스도쿠 판별문제다. 행, 열, 그리고 3*3 행렬안에 중복된 숫자가 있는지 판별하는 문제다. 조건대로 행, 열을 모두 판별하면서, 3*3 행렬안에 중복된 숫자가 있는지 판별하는 것을 구현하면 된다. 3*3행렬은, i / 3, j / 3 으로 나눈값으로 판별했다. class Solution { func is.. 2021. 8. 20.
LeetCode - 31. Next Permutation - swift https://leetcode.com/problems/next-permutation/ Next Permutation - 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 한.. 2021. 8. 20.
RxSwift, RxCocoa 정리 우선.. 곰튀김님의 RxSwift 3시간 강의연상 정말 추천합니다. ( 저도 지인분을 통해서 추천받고 들었는데 정말 대박입니다 👍 ) ( 왜 RxSwift가 필요하고, 왜 쓰이는지, 왜 그토록 많은 기업에서 사용하는지 이유를 알 수 있을 거에요! ) 곰튀김님 강의 영상 이 글은 곰튀김님의 강의 영상을 보면서 정리한 글 및 추가적으로 제가 RxSwift, RxCocoa를 사용하면서 제가 필요한 내용들만 적은 글입니다. RxSwift github https://github.com/ReactiveX/RxSwift GitHub - ReactiveX/RxSwift: Reactive Programming in Swift Reactive Programming in Swift. Contribute to Reactive.. 2021. 8. 18.
CoreData와 CloudKit 연동하기 1. 세팅하기 우선 가장 좋은 방법은, 애초에 프로젝트를 만들 때 Use Core Data, Use CloudKit을 체크하는 게 좋다. 그리고 target에서 Signing에서, "Automatically mannage signing을 선택하고, 개발팀을 선택한다. 그리고 iCloud를 가능하게 만들어야 한다. target - Capabilities 에서 iCloud를 추가하고, CloudKit을 선택한다. 이렇게 되면 자동적으로 Push notification이 추가된다. 이를 통해 remote content가 변경됐을 때 알려주기 때문이다. Use default container를 선택한다. ( 하지만! Xcode11부터는 더 이상 Use default container 체크박스가 없어졌고, 새로 .. 2021. 8. 18.
LeetCode - 15. 3Sum - swift https://leetcode.com/problems/3sum/ 3Sum - 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 숫자가 들어있는 배열( arr ) 이 주어지는데, 이 배열에서, arr[ i ] + arr[ j ] + arr[ k ] == 0 이면서, i != j 이면서 j != k 이면서 i != k 인 경우의 [ arr[i] , arr[j], arr[k] ] 들을 찾는 문제다. 2개 이상의 경우에는 나름의 최적화가 필요하다. arr의 개수는 최대 3.. 2021. 8. 18.
LeetCode - 12. Integer to Roman - swift https://leetcode.com/problems/integer-to-roman/ Integer to Roman - 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,5,10,50,100,500,1000 이렇게 각 값마다 표기하는 로마 표기법이 있고, 8은 VIII 이렇게, 큰숫자부터 앞에서 쓴다. 하지만.. 4는 IIII가 아닌, IV 이다 ! ( ??? ) 9는 VIIII가 아닌, IX .. 2021. 8. 18.