
SQLite 다양한 테이블의 데이터 조회 방법
2022. 10. 4. 21:26
SQLite
-- 이름과 나이를 조회 SELECT first_name, age FROM users; -- 전체 데이터를 조회 SELECT * FROM users; -- rowid와 이름을 조회 SELECT rowid, first_name FROM users; -- 이름과 나이를 나이가 어린 순으로 조회하기 SELECT first_name, age FROM users ORDER BY age ASC; -- 이름과 나이를 나이가 많은 순으로 조회하기 SELECT first_name, age FROM users ORDER BY age DESC; -- 이름, 나이, 계좌 잔고를 나이가 어린순으로, -- 만약 같은 나이라면 계좌 잔고가 많은 순으로 정렬해서 조회하기 SELECT first_name, age, balance FR..

SQLite 테이블 만들기
2022. 10. 4. 21:24
SQLite
CREATE TABLE users ( first_name TEXT NOT NULL, last_name TEXT NOT NULL, age INTEGER NOT NULL, country TEXT NOT NULL, phone TEXT NOT NULL, balance INTEGER NOT NULL );

백준 7562 나이트의 이동 (파이썬)
2022. 10. 3. 18:55
백준
풀이 및 해설(주석) import sys from collections import deque # sys.stdin = open('S1_7562_나이트의 이동.txt', 'r') sys.setrecursionlimit(10**6) # 나이트가 갈 수 있는 방향 dr = [-1, -2, -2, -1, 1, 2, 2, 1] dc = [-2, -1, 1, 2, 2, 1, -1, -2] def solve(r, c, er, ec): global cnt, visit, Q, record # 현재 위치 방문 체크 visit.add((r, c)) Q.append((r, c)) while Q: r, c = Q.popleft() # 목표 위치에 도달하면 적어뒀던 거리를 반환하고 함수 종료 if r == er and c ==..

리트코드 134 Gas Station (파이썬)
2022. 10. 2. 16:19
리트코드
https://leetcode.com/problems/gas-station/ Gas Station - 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 풀이 class Solution(object): def canCompleteCircuit(self, gas, cost): # 만약 gas의 총 합이 cost의 총 합보다 작다는 것은, 어느 칸에서든 한 바퀴를 못돈다는 것이다. if sum(gas) < sum(cost): return -1 # start는 인덱스 번호..

리트코드 787 Cheapest Flights Within K Stops
2022. 10. 1. 20:31
리트코드
https://leetcode.com/problems/cheapest-flights-within-k-stops/ Cheapest Flights Within K Stops - 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 풀이 및 해설(주석) import collections, heapq class Solution(object): def findCheapestPrice(self, n, flights, src, dst, K): # 정점: 인접정점, 가중치 딕셔너리 ..

리트코드 743 Network Delay Time (파이썬)
2022. 10. 1. 17:08
리트코드
https://leetcode.com/problems/network-delay-time/ Network Delay Time - 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 풀이 및 해설(주석) import collections import heapq from collections import defaultdict class Solution(object): def networkDelayTime(self, times, n, k): graph = defaultdic..

SWEA 4008 숫자 만들기 (파이썬)
2022. 9. 30. 17:18
SWEA
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWIeRZV6kBUDFAVH SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 풀이 def solve(index, AA): global max_AA, min_AA, oper if index == N: max_AA = max(max_AA, AA) min_AA = min(min_AA, AA) return # 계산할 피연산자 solve함수의 매개변수 index를 사용해서 지정 val = nums[index] # 사칙연산의 경우의 수 4개 candi = [AA+val, AA - va..

SWEA 1952 수영장 (파이썬)
2022. 9. 30. 16:14
SWEA
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5PpFQaAQMDFAUq SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 풀이 def solve(index, cost): global rst if cost > rst: return if index >= 12: rst = min(cost, rst) return if schedule[index]: solve(index+1, cost+(schedule[index] * d)) solve(index+1, cost+m) solve(index+3, cost+m3) solve(inde..