본문 바로가기

전체 글

(133)
Git log 옵션/reset/commit 옵션 log -p (버전에 대해 파악) log -p 옵션을 사용하면 버전간의 차이점과 과거 어느시점의 내용을 파악할 수 있다. 각각의 커밋과 커밋사이 소스상의 차이점을 알 수 있다. commit 96f4ef4bc9d69df35bdd54c1529680eba9fc61b2 (HEAD -> master) Author: jeongmin Date: Tue Dec 27 13:57:17 2022 +0900 4 diff --git a/f2.txt b/f2.txt index 2456b16..d170595 100644 --- a/f2.txt +++ b/f2.txt @@ -1 +1 @@ -source : 2 +source : 4 commit 5d6ec50fbacee1d06a4c2d7e67a7a516321ca53a Author: j..
[Python] [LeetCode] Balanced Binary Tree (균형 이진 트리) https://leetcode.com/problems/balanced-binary-tree/description/ Balanced Binary Tree - LeetCode Can you solve this real interview question? Balanced Binary Tree - Given a binary tree, determine if it is height-balanced. Example 1: [https://assets.leetcode.com/uploads/2020/10/06/balance_1.jpg] Input: root = [3,9,20,null,null,15,7] Output: true Exam leetcode.com 문제 설명: 이진트리가 주어지면 균형 잡힌 이진트리인지 확인하고..
Git init/status/config/add/commit/log init(Git 저장소 생성) 현재 디렉토리에서 작업을 진행하겠다는 것을 알리는 명령어 -> 즉, 버전관리를 시작 .git 이 생성되는데 버전관리 정보를 담고있다. ( 삭제에 주의 ) f1.txt 파일을 만들어 source : 1 텍스트를 추가하고 저장했다. f1.txt source : 1 버전 : 작업의 단위, 작업이 완결된 상태 status( 파일 상태 확인하기 ) git status을 입력하게 되는 경우 다음과 같은 화면이 나옴 On branch master No commits yet Untracked files: (use "git add ..." to include in what will be committed) f1.txt nothing added to commit but untracked fi..
[Python][LeetCode] Invert Tree https://leetcode.com/problems/invert-binary-tree/description/ Invert Binary Tree - LeetCode Can you solve this real interview question? Invert Binary Tree - Given the root of a binary tree, invert the tree, and return its root. Example 1: [https://assets.leetcode.com/uploads/2021/03/14/invert1-tree.jpg] Input: root = [4,2,7,1,3,6,9] Output: [4 leetcode.com 문제 설명 주어진 리스트를 트리로 바꿔 왼쪽과 오른쪽이 바뀐 값을 출력..
Python None 리턴하는 경우 dfs 문제를 풀다가 값을 넘기려고 하는 것들은 print로 찍어보면 값이 잘나오고 있었지만 마지막 반환된 결과값을 확인하면 None 가 나오고 있었다. 1) 종료조건에서만 반환을 해주면 되었나 마지막 결과값을 종료조건에 반환해주면 되었나 생각했지만 아니였다. 종료조건에 반환이 되면 전 단계로 돌아가는데 이 때 return 값이 없다! return 문이 없으면 None을 반환하게 된다. def dfs(): if 재귀 종료 조건: return cnt dfs() 결국 이 함수에서는 cnt가 종료조건에 반환이 되었다고 하더라도 전 단계에서 반환해주는 값이 없어 None 값을 반환한다. cnt -> None -> None 을 반환하며 돌아가는 것 2) return None 을 사용해야 될 때 ~가 아닌 경우이다..
이진트리(Binary Tree) 출처:https://www.mathwarehouse.com/programming/gifs/binary-search-tree.php#binary-search-tree-insertion-node) Understand Binary Search Tree through Gifs Binary Search Tree Degredation Gif Insertion of a node into Tree Description --> Binary Search Tree vs Sorted Array Animated Gif Comparing Sorted Array vs Binary Search Tree Description --> Optimal Binary Search Tree from Sorted Array Subtopic --..
[Python] 백준 9095번. 1,2,3 더하기 https://www.acmicpc.net/problem/9095 9095번: 1, 2, 3 더하기 각 테스트 케이스마다, n을 1, 2, 3의 합으로 나타내는 방법의 수를 출력한다. www.acmicpc.net 정수 n 에 대해 1,2,3으로 합을 만들 수 있는 경우의 수를 구하는 문제이다. 여기서 주의: 1이 처음 빠진다고 해서 두번째에도 1이 들어 갈 수 있다. for문을 n이 0이 될때까지 돌려주면 된다. 반복되는 과정이기 때문에 재귀함수로 구현가능 def sum(n): def dfs(n, arr): for i in [1,2,3]: if n-i == 0: result.append(arr+[i]) return else: dfs(n-i, arr+[i]) result = [] dfs(n, []) ret..
[Python] 백준 1795번. 암호 만들기 https://www.acmicpc.net/problem/1759 1759번: 암호 만들기 첫째 줄에 두 정수 L, C가 주어진다. (3 ≤ L ≤ C ≤ 15) 다음 줄에는 C개의 문자들이 공백으로 구분되어 주어진다. 주어지는 문자들은 알파벳 소문자이며, 중복되는 것은 없다. www.acmicpc.net 문제: 주어진 문자를 가지고 L자리 비밀번호를 조합하여 비밀번호를 풀려고 한다. 주의 할 점은 비밀번호 조합에는 최소 하나의 모음과, 최소 두개의 자음을 포함하고 있어야 한다. 문자가 4개 만들어지면 반환하도록 한다. 입력받은 문자열은 정렬이 되어야 한다. 출력결과를 보면 문자가 오름차순으로 정렬이 된 것으로 보인다. 결국 첫번째 자리 < 두번째 자리 < 세번째 자리 < 네번째 자리순으로 정렬되어야 한..