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 [leetcode][C++] rotate image 처음엔 노가다 구현을 했지만.. 배열을 시계방향으로 90도 회전 = 대각선 대칭 값 변경 + 좌우 대칭 값 변경 1 2 3 4 5 6 7 8 9 ↓ 대각선 대칭 값 변경 1 4 7 2 5 8 3 6 9 ↓ 좌우 대칭 값 변경 7 4 1 8 5 2 9 6 3 이렇..
https://leetcode.com/problems/sort-colors/ Sort Colors - 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][C++] sort colors class Solution { public: void sortColors(vector& nums) { int low = 0; int high = nums.size() - 1; for (int i = 0; i
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 [leetcode][C++][Java] jump game 처음 보자마자 생각난건 dp.. greedy로 풀면 코드도 간결하고 java로도 1ms가 나온다. C++ // greedy class Solution { public: bool canJump(vector& nums) { int last = nums.size() - 1..
https://leetcode.com/problems/search-in-rotated-sorted-array/ Search in Rotated Sorted Array - 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 input값은 정렬된 배열이기 때문에 바이너리 서치를 사용할 수 있다. 배열이 시작하는 시점 (정렬이 끝나는 시점)을 찾아서 범위마다 바이너리 서치를 실행해서 풀었다. nums[] = {5 1 < 2 < 3 < 4} binarySe..
https://leetcode.com/problems/generate-parentheses/ Generate Parentheses - 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][C++] generate parentheses class Solution { public: void dfs(int l, int r, int n, string s, vector& ret) { if (l == n && r == n) { ret.push_back(s); ..
https://leetcode.com/problems/letter-combinations-of-a-phone-number/ Letter Combinations of a Phone 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 [leetcode][C++][Java] letter combinations of a phone number C++ class Solution { public: string arr[10] = { "","","abc","def"..