분류 전체보기 288

[1분 면접] 사용자가 웹사이트에 처음 접근했을 때 발생하는 일련의 과정

[면접 대답]1. Clinet가 URL 입력  ( HTTP 프로토콜을 사용해 구글 웹 서버와 통신 시도) 2. 브라우저는 도메인 네임에 대한 IP 주소를 알아야 하기 때문에 DNS 서버에 질의 응답으로 해당 도메인에 대한 IP 주소 응답 받음3. IP 주소를 얻은 후, 브라우서는 구글 서버와 통신TCP/IP를 기반으로 TCP 3-Way Handshake 과정 필요 4. TCP 연결이 성립된 후, 브라우저는 HTTP Request 메시지 생성데이터 패킷 형태로 네트워크에 전달5. 서버는 클라이언트의 요청을 수신하고, HTTP Response 메시지를 생성하여 응답서버는 상태 코드와 함께 웹 페이지 데이터 전송브라우저는 데이터(HTML/CSS, JS)를 해석하여 화면에 페이지 렌더링6. 모든 데이터 전송이 ..

[MySQL][Leet Code] 1633. Percentage of Users Attended a Contest (Easy)

https://leetcode.com/problems/percentage-of-users-attended-a-contest/?envType=study-plan-v2&envId=top-sql-50🗒️SQL 코드 풀이 SELECT R.contest_id, ROUND(COUNT(DISTINCT R.user_id)/(SELECT COUNT(DISTINCT user_id)FROM Users)*100 ,2) percentage FROM Register R GROUP BY contest_id ORDER BY percentage DESC, contest_id 1. 메인 테이블은 Register의 테이블이다.  2. Register 테이블을 cont..

[Python][프로그래머스] 프로세스 / 스택, (Lv2)

🖇️ 링크 https://school.programmers.co.kr/learn/courses/30/lessons/42587🗒️ 파이썬 코드 풀이def solution(priorities, location): queue = [(i,p) for i,p in enumerate(priorities)] answer = 0 while True : cur = queue.pop(0) if any(cur[1]  시간 복잡도 O( N² ) 1. deque 라이브러리 없이 풀이한 코드이다. deque를 안써도 되기는 하지만 pop(0)의 시간복잡도는 O(N)pop()의 시각복잡도는 O(1) 지금은 pop(0)을 써도 큰 상관은 없어서 쓰지만, 문제 생길 경우 deqeu..

[1분 면접] DB에서 커넥션 풀을 사용하지 않을 때 발생하는 문제는 ?

DB 커넥션 Life Cyle DB 드라이버를 사용하여 DB 연결read/write를 위한 TCP 소켓 열기소켓을 통해 read/write연결 종료 소켓 닫기  커넥션 풀이 없다면  애플리케이션에서 DB 접근에 위와 같은 과정을 반복이 과정은 비용이 상당히 많이 들고, 요청의 응답시간이 길음 커넥션 풀 사용 장점커넥션 풀을 사용함으써 연결을 미리 생성이를 재사용하여 성능을 향상시키고 자원 사용을 최적화 DB 부하 감소 (최대 연결 수 제한)  NestJS 같은 경우 TypeORM이 자동으로 커넥션 풀을 적용시켜준다.

[MySQL][Leet Code] 197. Rising Temperature (Easy)

https://leetcode.com/problems/rising-temperature/description/?envType=study-plan-v2&envId=top-sql-50 🗒️SQL 코드 풀이 SELECT idFROM Weather W1 INNER JOIN ( SELECT DATE_ADD(recordDate, INTERVAL 1 DAY) recordDate2, temperature FROM Weather ) W2 ON W1.recordDate = W2.recordDate2WHERE W1.temperature - W2.temperature > 0 1. 문제에서 요구하는 것은 간단하다. 전날과 비교해서 기온이 떨어지는 id를 출력하는 것이다. 2. ..

[MySQL][Leet Code] 1581. Customer Who Visited but Did Not Make Any Transactions (Easy)

https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions/description/?envType=study-plan-v2&envId=top-sql-50🗒️SQL 코드 풀이 SELECT customer_id, COUNT(*) count_no_trans FROM Visits v LEFT JOIN Transactions t ON v.visit_id = t.visit_idWHERE t.visit_id IS NULLGROUP BY customer_id 1. LEFT JOIN을 하고 , visit_id 컬럼이 2개가 나오는데, 그 중 Transactions의 컬럼의 visit_id 의 NULL 값을 조회한다. 2. 이후 ..

[MySQL][Leet Code] 1378. Replace Employee ID With The Unique Identifier (Easy)

https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier/description/?envType=study-plan-v2&envId=top-sql-50https://leetcode.com/problems/article-views-i/?envType=study-plan-v2&envId=top-sql-50🗒️SQL 코드 풀이 1SELECT unique_id , nameFROM Employees e LEFT JOIN EmployeeUNI eu ON e.id = eu.id 1. 간단한 JOIN 문제로 먼저 가져올 테이블 Employee를 선택한다. 2. 이후 EmployeeUNI와 JOIN을 하는데, id를 기준으로 해준다.  📌..