Zero to Hero
Flask 사용법
Programming 2021. 5. 17. 14:20

위키독스 온라인 책을 제작 공유하는 플랫폼 서비스 wikidocs.net JSON 받고, 반환하기 @app.route('/user', methods=['POST']) def userLogin(): user = request.get_json() # json 데이터를 받아옴 return jsonify(user) # 받아온 데이터를 다시 전송 URI Path값 읽고 사용하기 # Spring의 @PathVariable 사용법 @app.route('/env/') def environments(language): return jsonify({"language": language}) URI를 HTTP Method로 분기하기 @app.route('/user', methods=['GET', 'POST']) def use..

article thumbnail
279. Perfect Squares
Algorithm 2021. 5. 17. 13:14

Perfect Squares - 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. DP 풀이 class Solution: def numSquares(self, n: int) -> int: dp = [0] * (n + 1) for i in range(1, int(math.sqrt(n)) + 1): dp[i * i] = 1 for i in range(1, n + 1): if dp[i]: continue else: temp = int(math.sqrt(i)) dp[..

article thumbnail
236. Lowest Common Ancestor of a Binary Tree
Algorithm 2021. 5. 17. 10:57

Lowest Common Ancestor of a Binary Tree - 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. DFS class Solution: def lowestCommonAncestor(self, root: TreeNode, p: TreeNode, q: TreeNode) -> 'TreeNode': p_seq, q_seq = [], [] def dfs(cur, seq): nonlocal p_seq, q_seq if not cur: return..

article thumbnail
200. Number of Islands
Algorithm 2021. 5. 17. 09:58

Number of Islands - 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. BFS from collections import deque from typing import * class Solution: def numIslands(self, grid: List[List[str]]) -> int: answer = 0 height, width = len(grid), len(grid[0]) visited = [[0] * width for _ in range..

article thumbnail
JPA Study 03
Programming 2021. 5. 16. 17:40

책을 읽고 배운 내용을 정리한다. 맵핑은 다대일 단방향부터 생각하자 - JPA는 다양한 연관관계에 대한 맵핑 방법을 제공한다. - 그중 가장 기본이 되는 방법은 다대일 단방향 맵핑이다. - 2개의 테이블을 JOIN 했을 때 가장 연상하기도 쉽고 DB 관점에서도, 객체 관점에서도 개발자에게 익숙하다. - 양방향 맵핑은 필요한 경우에만 만들어주면 된다. - 단방향, 양방향의 차이는 객체 그래프 탐색의 루트를 한쪽에서만 할 수 있을지, 양 쪽에서 다 가능하게 할지의 차이기 때문이다. 다대다 맵핑 @Entity @Data public class Member { @Id @Column(name = "MEMBER_ID") private String id; @Column private String username; /..

article thumbnail
75. Sort Colors
Algorithm 2021. 5. 16. 11:48

Sort Colors - 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. sort() class Solution: def sortColors(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ nums.sort() 0,1,2로 이루어진 list를 오름차순 정렬하는 문제다. 이렇게도 그냥 풀린다. 2. Dutch national flag prob..