분류 전체보기
-
[leetcode] 819. Most Common WordAlgorithm/1일 1코테 2021. 4. 28. 14:21
819. Most Common Word leetcode.com/problems/most-common-word/ Most Common Word - 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 조건 1. 금지어는 제거할 것 2. 특수문자 제거할 것 3. 소문자 혹은 대문자로 통일할 것 나의 답 def mostCommonWord(self, paragraph: str, banned: List[str]) -> str: import re # 전처리 paragraph = ..
-
[leetcode] 937. Reorder Log FilesAlgorithm/1일 1코테 2021. 4. 28. 09:12
leetcode.com/problems/reorder-data-in-log-files/submissions/ Reorder Data in Log Files - 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 로그를 재정렬 하는 문제 조건은 1. 문자가 숫자의 앞 2. 제일 앞 문자가 동일할 경우 식별자 순으로 나열 3. 숫자로그는 입력 순서대로 처음에 생각한 건 sort로 정렬시킨 다음에 문자/숫자 나누려고 했는데 그러면 숫자로그가 입력순이 아니게 됨 결국 하나하..
-
[JS] 자바스크립트 기본 - 코드 구조프로그래밍/JavaScript 2021. 4. 27. 22:14
코드 구조 세미콜론 대부분의 경우, 줄 바꿈이 있으면 자바스크립트는 '암시적' 세미콜론으로 해석하여 세미콜론을 따로 적지 않아도 된다. 하지만 대괄호 [ ]의 앞부분 등 인식하지 못하는 경우도 존재! 그러므로 세미콜론을 사용하는 것이 좋다. 주석 한줄 주석은 // 여러 줄은 /* */ use strict 지시자 기존 기능에 변경된 사항들을 활성화 하는 것 (엄격모드) 호환성 이슈 때문에 활성화 하지 않았던 것들을 활성화 시키는 지시자이다. 맨 상단에 "use strict"; 위치 시킬 것. 또한 일단 엄격모드가 실행되면 되돌릴 수 없다. (클래스와 함수를 사용한다면 이미 use strict가 적용되었기 때문에 따로 명시할 필요가 없다)
-
[leetcode] 344. Reverse StringAlgorithm/1일 1코테 2021. 4. 14. 19:56
문제 leetcode.com/problems/reverse-string/ Reverse String - 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 return할 필요없이 s 안의 값만 변경하는 문제. 단, 새로운 list 생성 등을 하면 안되고 s 안에서만 변경해야 한다. 모범답안 class Solution: def reverseString(self, s: List[str]) -> None: """ Do not return anything, modify s ..
-
[leetcode] 125.Valid PalindromeAlgorithm/1일 1코테 2021. 4. 14. 19:35
문제 입력 문자열이 팰린드롬인지 확인하는 문제 leetcode.com/problems/valid-palindrome/ # 내 답 class Solution: def isPalindrome(self, s: str) -> bool: p = '' # 전처리한 str 담아줄 변수 for i in s: if i.isalpha() or i.isdigit(): # 알파벳이거나 숫자일때만 i = i.lower() # 소문자로 바꿔준 뒤 더해줌 p += i p2 = p[::-1] # 팰린드롬인지 비교하기 위해 뒤집음 for i in range(len(p)): if p[i] != p2[i]: # 0번째부터 하나씩 출력해서 다르면 False return False return True isalpha() + isdigit()..
-
[node] 노드 기능 알아보기프로그래밍/JavaScript 2021. 3. 2. 21:30
REPL - read, eval, print, loop 모듈 // var.js const odd = '홀수입니다'; const even = '짝수입니다'; module.exports = { // 해당 파일을 모듈로서 사용 가능하게 한다. odd, even, }; // func.js const { odd, even } = require('./var'); // var 파일에서 가져옴 function checkOddOrEven(num) { if(num%2){ return odd; } return even; } module.exports = checkOddOrEven; // index.js const { odd, even } = require('./var'); const checkNumber = require(..
-
[JS] 자바스크립트 기본 문법 정리프로그래밍/JavaScript 2021. 2. 27. 14:59
변수 차이점 var 함수 스코프이기 때문에 블록 안에서 정의했어도 밖에서 사용 가능 const, let 블록 스코프를 가지므로 블록 밖에서는 접근 불가능 코드 관리가 수월해짐 const const는 한번 대입하면 다른 값 대입 불가 let let은 다른 값 재할당 가능 템플릿 문자열 string2 = `${num3} 더하기 ${num4}는 '${result2}'`; # 1 더하기 2는 '3' 객체 리터럴 const es = 'ES' const newObject = { sayJS(){ // sayJS: function()으로 정의할 필요 없이 가능 console.log('JS'); }, sayNode, [es + 6]: 'Fantastic', // 객체 리터럴 안에서 가능 }; console.log(new..