목록LeetCode 코딩테스트 (34)
무냐의 개발일지

| 터미널 프롬프트를 통해 Github(깃허브)에 프로젝트 업로드하는 방법 1. 프로젝트 진행 중인 로컬 파일 위치로 이동#플젝 진행중인 해당 폴더로 이동 (예시)cd /Users//Documents/HTML/Project_name 2. git 으로 현재 진행중인 내용 기록하고, Commit 하기 (remote에 저장할 친구들을 준비시키는 과정) | 전체 FLOW : Working Directory -> (git add) -> Staging Area -> (commit) -> Local Repository# 깃을 작동한다git init# 숨겨진 파일을 다 확인한다ls -a#나의 staging area에 뭐가 있나 확인git status#빨간 파일은 아직 staging area에 없는거고, 이거 추가하는..
strip과 split은 Python에서 문자열을 처리할 때 자주 사용하는 메서드이다. |strip문자열의 양쪽 끝에 있는 공백이나 특정 문자를 제거string.lstrip([chars])와 string.rstrip([chars])는 각각 문자열의 왼쪽 또는 오른쪽 끝에서 문자를 제거.s = " hello world "print(s.strip()) # "hello world"print(s.lstrip()) # "hello world "print(s.rstrip()) # " hello world" s = "xxhelloxworldxx"print(s.strip('x')) # "helloxworld"print(s.lstrip('x')) # "helloxworldxx"print(s.rstrip('x'..
isalpha()와 isalnum()은 Python에서 문자열 메서드로, 문자열의 특정 특성을 확인하는 데 사용됩니다. isalpha()문자열이 알파벳 문자로만 구성되어 있는지 확인합니다. (A-Z 및 a-z)공백, 숫자, 특수 문자 등이 포함되어 있으면 False를 반환 s1 = "Hello"s2 = "Hello123"s3 = "Hello World"print(s1.isalpha()) # Trueprint(s2.isalpha()) # False (숫자가 포함되어 있음)print(s3.isalpha()) # False (공백이 포함되어 있음)isalnum()문자열이 알파벳 문자 또는 숫자로만 구성되어 있는지 확인합니다.문자열에 공백, 특수 문자 등이 포함되어 있으면 False를 반환합니다.s1 = ..
| sort 메서드원본 리스트를 직접 정렬합니다.리스트 메서드로, 리스트 객체에서만 호출할 수 있습니다.반환값이 없습니다 (None을 반환).시간 복잡도는 최악의 경우 O(nlogn)O(n \log n)O(nlogn)입니다.my_list = [3, 1, 4, 1, 5, 9, 2]my_list.sort()print(my_list) # [1, 1, 2, 3, 4, 5, 9] | sorted 함수새로운 리스트를 반환합니다.모든 반복 가능한 객체에서 사용할 수 있습니다 (리스트, 튜플, 문자열, 딕셔너리 등).원본 데이터를 변경하지 않습니다.my_list = [3, 1, 4, 1, 5, 9, 2]sorted_list = sorted(my_list)print(sorted_list) # [1, 1, 2, 3..
리스트 두 개를 연결하는 방법으로 append와 extend가 있는데, 이 둘은 다르게 작동합니다.append는 하나의 객체를 리스트의 끝에 추가합니다. 즉, 리스트를 다른 리스트의 끝에 추가하면 중첩된 리스트가 됩니다.extend는 하나의 리스트의 모든 요소를 다른 리스트의 끝에 추가합니다. 즉, 두 리스트를 하나의 리스트로 결합합니다.차이를 코드 예시로 설명하면 다음과 같습니다. | append 사용 예시list1 = [1, 2, 3]list2 = [4, 5, 6]list1.append(list2)print(list1) 이 경우, list1은 다음과 같이 중첩된 리스트를 갖게 됩니다:[1, 2, 3, [4, 5, 6]] | extend 사용 예시list1 = [1, 2, 3]list2 = [4, 5,..
👩💻 문제Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Then return the number of unique elements in nums.Consider the number of unique elements of nums to be k, to get accepted, you need to do the following things:Change the array nums such that..
👩💻 문제Given a binary search tree, find the kth smallest element in the tree. For example, if the tree contains the elements [1, 2, 3, 4, 5], the 3rd smallest element would be 3.The solution to this problem usually involves traversing the tree in-order (left, root, right) and keeping track of the number of nodes visited until you find the kth smallest element. There are two main approaches to d..
👩💻 문제You are tasked with writing a method called is_valid_bst in the BinarySearchTree class that checks whether a binary search tree is a valid binary search tree.Your method should use the dfs_in_order method to get the node values of the binary search tree in ascending order, and then check whether each node value is greater than the previous node value.If the node values are not sorted in ..