[OJ.leetcode] rotate-image https://oj.leetcode.com/problems/rotate-image/ You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in-place? /* tese case 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 13 9 5 1 14 10 6 2 15 11 7 3 16 12 8 4 in-place 단순한 규칙을 찾고 loop를 2D로 구현하여야 함. */ class Solution { public: void rotate(vector &matrix) { int size = matrix.size().. 더보기 [OJ.leetcode] plus-one https://oj.leetcode.com/problems/plus-one/ Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. /* digit binaoperation은 언제나 carry 처리/자릿수 변경이 관건 맨 뒷자리부터 1씩 더해나가면서 carry 처리. O(n) carry 관련 문제는 언제나 loop끝나고 남은 carry를 처리해주는 것을 잊지 말것 001 111 101 */ class Solution { public: vector plu.. 더보기 [OJ.leetcode] remove-duplicates-from-sorted-array https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/ Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory. For example, Given input array A = [1,1,2], Your function should return length = 2, and A is now [1,2]. /* 똑같은 문제.. 더보기 이전 1 2 3 4 5 ··· 44 다음