본문 바로가기

분류 전체보기264

[LEET CODE] 5. Longest Palindromic Substring #Problem Given a string s, return the longest palindromic substring in s. Example 1: Input : s = "babad" Output : "bab" Note : "aba" is also a valid answer. Constraints: 1 str: # 팰린드롬 판별 및 투 포인터 확장 # expand 함수는 중심에서 양쪽으로 계속 뻗어나간다. def expand(left: int, right: int) -> str: while left >= 0 and right < len(s) and s[left] == s[right]: left -= 1 right += 1 return s[left + 1:right] # 해당 사항이 없을때 빠르게 리턴.. 2021. 3. 16.
[코딩+알고리즘 완주반] 2일차. Print 함수, 가상환경 설정 # Print 가장 기본적인 출력 함수 Separator, End 옵션 사용 Format 형식 출력 Escape Code 사용 #Print 구문 #기본 출력 print('Hello python') print("Hello python") print("""hello python""") print('''hello python''') print() # 줄바꿈 #Separator 옵션 사용 print('T','E','S','T') print('T','E','S','T',sep='') print('2019','02','19',sep='-') print('niceman','google.com',sep='@') #end 옵션 사용 print('Welcome To',end=' ') print('the black para.. 2021. 3. 16.
[코딩 + 알고리즘 온라인 완주반] 1일차. 파이썬 설치, 가상환경 설정 # 개발 환경 - 사용 언어 및 버전 : 파이썬 3.7.6 - 통합 개발 환경 : Visual Studio Code ( 터미널에서 'code' 입력) # 파이썬 언어 장점 - 문법이 간결 - 다양한 운영체제 지원 - GUI Application 개발 (PyQT) - 방대한 라이브러리 지원 (프레임워크, 오픈소스,...) - 범용언어 (네트워크, 웹, 데이터분석, 기계학습 등) # 가상환경 설정하기 MacBookPro ~ % cd /Users/사용자이름/Documents/FastCampus MacBookPro FastCampus % python -m venv python_basic # 새로운 폴더 생성 MacBookPro FastCampus % cd python_basic MacBookPro python_.. 2021. 3. 15.
[LEET CODE] 49. Group Anagrams (dict 자료형, sort(), sorted()) # Problem * anagram(애너그램) : 일종의 언어유희로 문자를 재배열하여 다른 뜻을 가진 단어로 바꾸는 것 Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Example 1: Input : strs = ["eat","tea","tan","ate","nat","bat"] Output : [["bat.. 2021. 3. 15.
[LEET CODE] 819. Most Common Word ( 정규표현식 ) #Problem Given a string paragraph and a string array of the banned words banned, return the most frequent word that is not banned. It is guaranteed there is at least one word that is not banned, and that the answer is unique. The words in paragraph are case-insensitive and the answer should be returned in lowercase. Example 1: Input : paragraph : "Bob hit a ball, the hit BALL flew far after it w.. 2021. 3. 15.
[LEET CODE] 937. Reorder Data in Log Files ( lambda 함수, 문자열 확인 함수 ) # Problem You are given an array of logs. Each log is a space-delimited string of words, where the first word is the identifier. There are two types of logs: Letter-logs: All words (except the identifier) consist of lowercase English letters. Digit-logs: All words (except the identifier) consist of digits. Reorder these logs so that: The letter-logs come before all digit-logs. The letter-logs ar.. 2021. 3. 14.
반응형