300. Longest Increasing Subsequence
·
Algorithm/LeetCode
문제Given an integer array nums, return the length of the longest strictly increasingsubsequenceExample 1:Input: nums = [10,9,2,5,3,7,101,18]Output: 4Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4.Example 2:Input: nums = [0,1,0,3,2,3]Output: 4Example 3:Input: nums = [7,7,7,7,7,7,7]Output: 1Constraints:1 104 Solution 1class Solution { public int lengthO..
HTTP keep-alive란?
·
외부활동/JSCODE 네트워크
keep-alive란?서버와 클라이언트 간의 연결을 요청마다 닫지 않고 지속적으로 유지하는 방식입니다. HTTP/1.1부터 도입되어, TCP connection을 재사용할 수 있도록 설계되었습니다.HTTP/1.1 기본값: keep-alive 활성화서버 설정 필요: 서버 측 웹 서버에서 keep-alive 설정이 활성화되어 있어야 동작HTTP keep-alive 옵션 설정 방법keep-alive를 사용하려면 HTTP header에 아래와 같이 설정합니다. 서버가 keep-alive를 지원할 경우 response에도 같은 헤더가 포함되며, 지원하지 않을 경우 헤더 없이 응답합니다. 클라이언트는 응답에 헤더가 없으면 connection을 재사용하지 않습니다.HTTP/1.1 200 OKConnection: Ke..
322. Coin Change
·
Algorithm/LeetCode
문제You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1. You may assume that you have an infinite number of each kind of coin. Example 1:Input: coins = ..
[1주차] 네트워크 기초
·
외부활동/JSCODE 네트워크
컴퓨터 네트워크는 무엇인가요?컴퓨터 네트워크는 컴퓨터간에 서로 연결되어 데이터를 주고 받을 수 있는 통신망입니다.현대에는 월드 와이드 웹(www)이라는 네트워크 통신망에서 주로 HTTP를 사용해 데이터를 주고 받습니다.컴퓨터 네트워크에서 데이터를 전송하는 방식에 대해 설명해주세요.컴퓨터 네트워크에서 데이터를 전송하는 방식은 회선 교환 방식과 패킷 교환 방식이 있습니다. 회선 교환 방식은 일대일 네트워크 연결 회선을 미리 점유해서 데이터 전송을 하는 방식입니다.회선을 점유하는 동안은 다른 컴퓨터가 데이터를 전송할 수 없습니다. 패킷 교환 방식은 데이터를 패킷이라는 작은 단위로 나눠서 전송하는 방식입니다.회선을 점유하지 않기 때문에 여러 컴퓨터들이 데이터 전송을 할때 회선을 효율적으로 사용할 수 있습니다.프..
70. Climbing Stairs
·
Algorithm/LeetCode
문제You are climbing a staircase. It takes n steps to reach the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Example 2:Input: n = 3Output: 3Explanation: There are three ways to climb to the top.1 step + 1 step + 1 step1 step + 2 steps2 steps + 1 step링크: https://leetcode.com/problems/climbing-stairs/description/Solutionclass Solution { publ..
JDK와 JRE
·
Programming/Java
JDKJava Developmnet Kit개발과 실행을 위한 도구대표적으로 컴파일러(javac).java -> .calss 변환하여 JVM은 바이트코드(.class)를 기계어로 변환하여 실행JREJava Runtime Environment실행만을 위한 환경대표적으로 클래스 로더필요한 .class 파일을 메모리에 로드하여 JVM이 실행할 수 있도록 하는 역할
143. Reorder List
·
Algorithm/LeetCode
문제You are given the head of a singly linked-list. The list can be represented as:L0 → L1 → … → Ln - 1 → LnReorder the list to be on the following form:L0 → Ln → L1 → Ln - 1 → L2 → Ln - 2 → …You may not modify the values in the list's nodes. Only nodes themselves may be changed.링크: https://leetcode.com/problems/reorder-listSolution 1class Solution { public void reorderList(ListNode head) { if..
200. Number of Islands
·
Algorithm/LeetCode
문제전형적인 bfs 탐색 문제였다. 0은 물, 1은 땅을 의미하는 그래프 배열이 주어진다. 땅이 근접하게 모여 있으면 하나의 섬이다. 섬의 갯수를 요구하는 문제였다.링크: https://leetcode.com/problems/number-of-islands/description/Solutionclass Solution { static int[][] dirArray = {{-1,0},{1,0},{0,-1},{0,1}}; public int numIslands(char[][] grid) { int m = grid.length; int n = grid[0].length; boolean[][]visited = new boolean[m][n]; int ..
994. Rotting Oranges
·
Algorithm/LeetCode
문제그래프가 주어지고, 값은 0,1,2 중 하나이다. 1은 신선한 토마토, 2는 썩은 토마토, 0은 해당 위치에 토마토가 없음을 표현하였다. 썩은 토마토는 전염시킬 수 있어서, 근접 노드에 신선한 토마토가 있으면 전염시킨다. 전염은 1분 단위로 진행된다. 모든 토마토를 전염시키는데 걸리는 시간을 요구한다. 만약 모든 토마토를 전염시킬 수 없다면 -1를 반환한다.링크: https://leetcode.com/problems/rotting-oranges/?envType=study-plan-v2&envId=leetcode-75Solutionclass Solution { public int orangesRotting(int[][] grid) { int[][] visited = grid; ..
452. Minimum Number of Arrows to Burst Balloons
·
Algorithm/LeetCode
문제그리디 알고리즘 문제였다. 풍선의 위치(지름)가 범위로 표현되어 주어진다. 여러 풍선이 주어지고, 최대한 적은 갯수의 화살로 모든 풍선을 터트리는 문제였다. 풍선은 겹칠 수 있다(위치 범위가 일부 겹칠 수 있다). 그리디 알고리즘이란 Greedy(탐욕, 욕심쟁이) 이름 처럼 지금 당장 최적의 답을 선택하는 과정을 반복하여 결과를 도출하는 알고리즘이다. 링크: https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloonsSolution 1class Solution { public int findMinArrowShots(int[][] points) { int answer = 1; Arrays.sort(poi..