목록전체 글 (772)
컴공생의 다이어리
백준 14621번 : 나만 안되는 연애 (문제 바로가기) 내 코드 import sys input = sys.stdin.readline def find_parent(parent, x): if parent[x] != x: parent[x] = find_parent(parent, parent[x]) return parent[x] def union(parent, a, b): a = find_parent(parent, a) b = find_parent(parent, b) if a < b: parent[b] = a else: parent[a] = b n, m = map(int, input().split()) # n : 학교의 수, m : 도로의 개수 univ = list(input().split()) # 대학교 정..
[프로그래머스] K번째수 - 자바스크립트(JS) function solution(array, commands) { return commands.map((v) => { return array.slice(v[0] - 1, v[1]).sort((a, b) => a - b)[v[2] - 1]; }); } solution([1, 5, 2, 6, 3, 7, 4], [[2, 5, 3], [4, 4, 1], [1, 7, 3]]); https://school.programmers.co.kr/learn/courses/30/lessons/42748 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. progra..
[프로그래머스] 가장 큰 수 - 자바스크립트(JS) function solution(numbers) { let answer = numbers .map((v) => String(v)) .sort((a, b) => (b + a) - (a + b)) .join(""); return answer[0] === "0" ? "0" : answer; } solution([6, 10, 2]); solution([3, 30, 34, 5, 9]); https://school.programmers.co.kr/learn/courses/30/lessons/42746 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요...
vscode Code Runner로 빌드 및 실행 개인적으로 vscode에서는 intellij와 같은 IDE와 다르게 빌드와 실행 설정 하기가 불편했다. 빠르게 실행해볼 수 있는 extension을 찾던 도중 Code Runner를 발견했다. Code Runner는 C, C++, Java, JavaScript, PHP, Python ... 등 대부분의 언어를 빌드 및 실행할 수 있다. 그렇다고 언어를 빌드하는 프로그램이 없으면 안 되고 이미 설치되어 있어야 한다. 설치 방법 및 실행 vscode의 마켓플레이스에 들어가 code runner를 검색한 후 설치한다. 파일의 오른쪽 상단에 실행버튼을 누르면 실행된다. 혹은 우클릭해서 나오는 탭의 Run Code 혹은 실행 단축키인 Ctrl+Alt+N을 입력해도..
백준 4097번 : 수익 (문제 바로가기) 내 코드 import sys input = sys.stdin.readline while n := int(input()): arr = list(int(input()) for _ in range(n)) # 수익 리스트 for i in range(1, n): arr[i] = max(arr[i], arr[i] + arr[i - 1]) print(max(arr))
JavaScript 스코프(scope) - 전역, 지역(함수, 블록) 변수의 스코프는 변수에 접근할 수 있는 위치를 제어한다. 스코프는 전역 스코프와 지역 스코프로 나뉜다. 전역 스코프 전역에 선언되어 있어서 어느 곳에서든 해당 변수에 접근 가능하다. const hello = "Hello World"; // 전역 스코프로 hello 변수 선언 console.log(hello); function printHello() { console.log(hello); // 전역 스코프에 선언된 hello 변수 참조 } 지역 스코프 해당 지역에서만 접근할 수 있어 지역을 벗어난 곳에서는 해당 변수에 접근 불가하다. 크게 함수 스코프와 블록 스코프로 나뉜다. 함수 스코프 : 함수에서 선언한 변수는 해당 함수 내에서만 접..
백준 20922번 : 겹치는 건 싫어 (문제 바로가기) 내 코드 import sys from collections import defaultdict input = sys.stdin.readline n, k = map(int, input().split()) arr = list(map(int, input().split())) max_len = 0 left, right, count = 0, 0, defaultdict(int) while right < n: if count[arr[right]] < k: count[arr[right]] += 1 right += 1 else: count[arr[left]] -= 1 left += 1 max_len = max(max_len, right - left) print(max..
백준 2003번 : 수들의 합 2 (문제 바로가기) 내 코드 import sys input = sys.stdin.readline n, m = map(int, input().split()) arr = list(map(int, input().split())) cnt, temp_sum, left = 0, 0, 0 for right in range(n): temp_sum += arr[right] while temp_sum > m: # 지금까지 합이 m보다 크다면 temp_sum -= arr[left] # 구했던 합의 제일 왼쪽에서 값 삭제 left += 1 if temp_sum == m: cnt += 1 print(cnt)
백준 16507번 : 어두운 건 무서워 (문제 바로가기) 내 코드 import sys input = sys.stdin.readline r, c, q = map(int, input().split()) arr = [list(map(int, input().split())) for _ in range(r)] sum_arr = [[0] * (c + 1) for _ in range(r + 1)] for i in range(1, r + 1): for j in range(1, c + 1): sum_arr[i][j] = sum_arr[i - 1][j] + sum_arr[i][j - 1] + arr[i - 1][j - 1] - sum_arr[i - 1][j - 1] for _ in range(q): r1, c1, r2, ..
JavaScript 운영체제 확인 자바스크립트에서 아래와 같이 os모듈을 통해 시스템 정보를 알 수 있다. import os from "os"; console.log(os.type()); // 운영체제 이름 console.log(os.platform()); // 운영체제 플랫폼 console.log(os.arch()); // 운영체제 아키텍처 console.log(os.release()); // 운영체제 버전 console.log(os.uptime()); // 운영체제가 실행된 시간 console.log(os.tmpdir()); // 임시 저장 폴더의 위치 console.log(os.endianness()); // CPU의 endianness(BE 또는 LE) console.log(os.hostname(..