반응형

코딩테스트준비 3

[Python] RESTful API 만들기

Python에서 HTTP 요청을 하려면 요청 라이브러리를 사용할 수 있습니다. 이 라이브러리는 Python에서 HTTP 요청을 보내기 위한 편리하고 사용하기 쉬운 인터페이스를 제공합니다. 다음은 요청 라이브러리를 사용하여 GitHub API에 GET 요청을 보내는 방법의 예입니다. import requests response = requests.get("https://api.github.com/user") if response.status_code == 200: # Success print(response.json()) else: # Failure print(f"Request failed with status code: {response.status_code}") 이 예제는 GitHub API에 GET ..

개발팁/Python 2022.12.17

[Java] 최적화된 Linked List 알고리즘

다음은 그 사용법을 보여주는 간단한 단위 테스트와 함께 Java로 단일 연결 목록을 구현한 것입니다. public class LinkedList { private Node head; private int size; public LinkedList() { head = null; size = 0; } public int getSize() { return size; } public boolean isEmpty() { return size == 0; } public void add(int data) { Node newNode = new Node(data); newNode.setNext(head); head = newNode; size++; } public void remove(int data) { if (hea..

개발팁/Java 2022.12.16

[Python] 최적화된 최단 경로 알고리즘 작성하기

다음은 소스 노드와 그래프의 다른 모든 노드 사이의 최단 경로를 찾기 위해 Dijkstra의 알고리즘을 구현하는 Python 함수입니다. import heapq def dijkstra(graph, source): # Set up distance dictionary and predecessor dictionary distances = {node: float('inf') for node in graph} predecessors = {node: None for node in graph} # Set the distance to the source node to be 0 distances[source] = 0 # Create a priority queue to store the nodes that need to ..

카테고리 없음 2022.12.16
반응형