분류 전체보기 240

351. Android Unlock Pattern

https://leetcode.com/problems/android-unlock-patterns/ Account Login - 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 unlock pattern하는 문제. 2차원 배열에서 방향을 줄때 상대적인 위치값을 주는게 익숙했는데 3x3로 고정되어있어서 방문했는지, 2칸 점프할 수 있는지 여부를 좀 더 효율적인 방법으로 확인 가능하다. 상대적인 위치값: {0, 1}, {1, 0}로 더하주면 각각 right로 1칸, b..

1171. Remove Zero Sum Consecutive Nodes from Linked List

문제: https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list/ Remove Zero Sum Consecutive Nodes from Linked List - 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 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * Lis..

1314. Matrix Block Sum

문제: https://leetcode.com/problems/matrix-block-sum/ Matrix Block Sum - 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 2d vector에서 특정 구간의 합을 구하는 문제다. k값이 주어지고, 2d vector 안의 (y,x) 포인트에서 i - k = lenX ? lenX - 1 : j + k; mat[i][j] = pSums[moreI + 1][moreJ + 1] + pSums[lessI][lessJ] - ..

1007. Minimum Domino Rotations For Equal Row

링크: https://leetcode.com/problems/minimum-domino-rotations-for-equal-row/ Minimum Domino Rotations For Equal Row - 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개의 도미노들 중 위아래 하나의 라인에서 같은 숫자가 이어지게끔 만드는 swap 개수 중 작은 값을 리턴하는 문제 class Solution { public: int minDominoRotations(vector..

1089. Duplicate Zeros

링크: https://leetcode.com/problems/duplicate-zeros/ Duplicate Zeros - 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에 0이 있으면 2개로 늘리는데, inplace가 제한조건이다. class Solution { public: void duplicateZeros(vector& arr) { int zeroCnt = 0; int right = arr.size() - 1; for(int i = 0; i < ar..

616. Add Bold Tag in String

링크: https://leetcode.com/problems/add-bold-tag-in-string/ 동일한 문제: https://leetcode.com/problems/bold-words-in-string/ Account Login - 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: s = "abcxyz123" dict = ["abc","123"] Output: "abcxyz123" dict에 존재하는 문자열이 s에 존재한다면 ", "로 감싸서 r..