작업하다가 실수로 다른 팀원의 파일을 건드려서 변경한 내용을 없던 일로 하고 싶을 수 있다 변경된 파일 목록을 확인하고 변경을 취소하고 원래대로 되돌려보자 #변경된 파일 목록 확인 git status #변경 취소하고 원래대로 되돌리기 git restore [파일명] git status를 통해 원하는 파일의 경로+파일명 전체를 복사해서 git restore 명령어와 함께 사용하면 된다. 다시 git status를 해보면 해당 파일이 목록에 보이지 않을 거다!
전체 글
삼시세끼 잔잔하게 개발하는 백엔드 지망생 수련기 : Spring boot, Algorithmhttps://leetcode.com/problems/balanced-binary-tree/ Balanced Binary 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 Think 재귀로 풀 수 있는 문제 이진트리의 균형은 효율면에서 중요한 부분이라고 한다. Solution # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None..
https://leetcode.com/problems/maximum-depth-of-binary-tree/ Maximum Depth of Binary 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 Think 책대로 스택을 사용하는 BFS 반복구조로 풀이해보자! 파이썬의 큐 자료형보다는 데크를 쓰는 게 성능이 좋다. Solution # Definition for a binary tree node. # class TreeNode(object): # de..
문제 상황 잘 작업하던 프로젝트 MySQL WorkBench로 AWS RDS로 올려둔 DB 에 접속하려고 했는데 갑자기 아래와 같은 창을 마주했다 포스트맨으로 보낸 DB사용하는 요청은 잘 되는 걸 보니 RDS 서버에는 문제가 없는 것 같았다 원인 & 해결 생각해보니 작업하는 장소와 사용하는 와이파이가 바뀌었다. IP주소가 바뀌었을 것이다. 참고로 와이파이는 같은 와이파이라도 껐다 켜기만 해도 IP주소가 바뀌는 경우가 있다. 보안그룹에 가서 RDS의 보안그룹에 내 IP를 추가해줬다. (하는 김에 EC2 보안그룹도 수정했다) RDS 보안그룹을 누르고 위에 있던 인바운드 규칙과 동일하게 하나 더 만들고 내 현재 IP를 추가해줬다. 저장~ 다시 접속해본다 잘됨~
https://leetcode.com/problems/subsets/ Subsets - 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 Think dfs 탐색 과정의 모든 걸 저장하면 됨 Solution class Solution(object): def subsets(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ def dfs(index, path) : # 매번 결과에 추가함. 그래프 끝까지..
https://leetcode.com/problems/combinations/ Combinations - 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 Think 이번에도 영상을 보자..~ https://www.youtube.com/watch?v=q0s6m7AiM7o Solution 1. 파이썬 답게,, 라이브러리를 사용하는 풀이 class Solution(object): def combine(self, n, k): """ :type n: int :type k:..
Think 나 왜 이렇게 재귀만 나오면 머리가 멈출까?...... 책 풀이만으로는 이해가 안되어서 영상 찾아봤다 https://www.youtube.com/watch?v=0snEunUacZY 코드에서 len(path)와 len(digits)의 값이 같을 때 깊이 탐색을 멈추고 백트래킹을 한다는 말이 이해가 안 갔는데 이번에도~ 영상 속 그림을 보고 한방에 이해 됐다 digit이 두개니까 지금 탐색중인 path의 길이가 두개이면 끝까지 갔다는 얘기 -> 백트래킹! 지금까지 따라온 경로 = 문자열 하나 인 path를 결과 배열에 저장하고 return 으로 한꺼풀 빠져나온다. Solution class Solution(object): def letterCombinations(self, digits): """ ..
https://leetcode.com/problems/jewels-and-stones/ Jewels and Stones - 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 Think 오늘 푼 것 중에 제일 할 만 했던 것 같다^^..! 문제도 귀여웠음 보석찾기 해시테이블에 존재하는 키 값을 찾을 때 딕셔너리 자료형의 무슨 메서드가 있는지부터 고민했는데 단순히 in 연산자로 해결..~ 파이썬에 더 익숙해지는 과정이 필요할 듯 Solution class Solutio..
https://leetcode.com/problems/design-circular-queue/ Design Circular Queue - 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 Think 왜 시작을 못하겠지? 경험이 부족함을 느꼈다 앞부분을 참고해서 적고나니 뒷부분은 얼추 구현해볼 수 있었다 공부하자!! 그리고 파이썬은 모든 내장 변수에 self를 붙여야 하는 점이 너무 불편하고 가독성도 안 좋은 것 같다 하지만 어쩌겠어 내가 고른 길인걸~~ 사람은 적응..
https://leetcode.com/problems/implement-stack-using-queues/ Implement Stack using Queues - 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 Think 뭘로 뭘 구현해라..라는 문제 형식 자체가 낯설어서 읽어보는 것만으로 공부였던 문제 뭘 써서 구현해야 할 지도 몰랐다 ㅋㅋㅋㅋ...~ 게다가 deque도 모르고~ 그리고 리트코드에서 적어둔 코멘트들 읽으면서 풀 것.. 문제 좀 읽어라 Soluti..
https://leetcode.com/problems/remove-duplicate-letters/ Remove Duplicate Letters - 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 Think 재귀는 많이 연습해야 겠다.. 함수 만들어서 재귀로 푸는 거에 쫄지 말기. 스택으로 푸는 법도 다시 풀어보기. Solution 1. 재귀 class Solution(object): def removeDuplicateLetters(self, s): """ :ty..
Think 역순 연결 리스트 2번째 문제. 전에 봤던 206. 역순 연결 리스트도 완벽히 이해하지 못한 상황이라 206번을 설명해주는 영상을 찾아 보고 왔다. 이해가 훨씬 잘 됐다! 반복과 재귀 두 방법 모두.. 그림이 역시 짱이다 https://www.youtube.com/watch?v=G0_I-ZF0S38 206번 풀이했던 내용을 바탕으로 이번 문제는 스스로 풀어보자 반복이 재귀방법보다 공간복잡도도 더 낮고 시간도 짧다. 반복으로 풀어보자 . . . 절반밖에 못풀었다^^! 영상을 찾아봤다! 같은 채널에서 올린 영상이 있었고 이해가 역시 잘 됨... https://www.youtube.com/watch?v=RF_M9tX4Eag 이 문제에서는 주어진 연결리스트의 맨 앞 head노드를 가리키는 root노드..
Think 혼자 풀기 실패 풀이 설명을 읽는데 이해가 안됨 리트 코드 solution탭을 살펴봤는데 아래 그림 보고 설명 바로 이해함!! Solution 투 포인터 사용 class Solution(object): def trap(self, height): """ :type height: List[int] :rtype: int """ #빈 인풋값이 들어왔을 경우를 처리 if not height : print(0) left = 0 right = len(height) - 1 #포인터 0부터 시작 left_max, right_max = height[left], height[right] volume = 0 while left < right : #서로 만나기 전까지 실행 #왼, 오 최댓값을 현재값과 비교해 갱신 l..
직전 커밋 메세지를 수정해보자. 이미 푸시했더라도 괜찮다! //직전 커밋 확인 한번 하고 git log //커밋 메세지를 덮어쓰기 한다 git commit --amend -m "새로 작성한 커밋메세지" //원격 레포에 올린 직전 커밋을 무시하고 로컬의 내용으로 덮어쓴다. git push -f origin 브랜치명 끝~~
Spring Boot 에서 JPA를 사용해서 자동을 테이블을 생성하기 위해 create-drop 을 사용했다 에러 o.h.t.s.i.ExceptionHandlerLoggedImpl : GenerationTarget encountered exception accepting command : Error executing DDL "..." org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "..." 원인 여러가지 원인이 있다고 나왔는데 나 같은 경우에는 Entity를 구성하는 코드 중에 SQL 예약어가 있었다 최신 날짜를 의미하려고 update라는 컬럼을 사용하려고 했다; ㅋㅋㅋㅋ 어쩐지 다른 테이블들은 잘 생성되는데 한..