이카's
반응형
[Algorithm] LeetCode #5 Maximum Subarray
LeetCode 2022. 5. 11. 22:52

Problems Maximum Subarray Easy Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. A subarray is a contiguous part of an array. Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: [4,-1,2,1] has the largest sum = 6. Example 2: Input: nums = [1] Output: 1 Example 3: Input: nums = [5,4,-1,7,8] ..

[Algorithm] LeetCode #4 Product of Array Except Self
LeetCode 2022. 5. 10. 23:06

Problem 238 Product of Array Except Self Medium 12160 740 Add to List Share Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. You must write an algorithm that runs in O(n) time and without using the division operation. Exa..

[Algorithm] LeetCode #3 Contains Duplicate
LeetCode 2022. 5. 10. 23:05

Problems Contains Duplicate Easy 4591 953 Add to List Share Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. Example 1: Input: nums = [1,2,3,1] Output: true Example 2: Input: nums = [1,2,3,4] Output: false Example 3: Input: nums = [1,1,1,3,3,4,3,2,4,2] Output: true 문제 이해 굉장히 쉬운 문제다. 배열안에 중복되는 숫자가 있으면 True없으면..

[Algorithm] LeetCode #2 Best time to buy and sell stock
LeetCode 2022. 5. 8. 20:15

LeetCode - Best time to buy and sell stock Problems You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0. Example..

[Algorithm] LeetCode #1 Two Sum solved
LeetCode 2022. 5. 8. 02:31

Brute Force 내 방식 def twoSum(self, nums: List[int], target: int) -> List[int]: for i in range(len(nums)): for j in range(i + 1 , len(nums)): if nums[i] + nums[j] == target: return [i, j] Other Method Two pass Hash Table def twoSum(self, nums: List[int], target: int) -> List[int]: talbe = {num: i for i, num in enumerate(nums)} for idx, num in enumerate(nums): if ((target - num) in table) and (idx ..

[Ubuntu] Kill port command
카테고리 없음 2022. 4. 29. 12:23

포트번호 확인 netstat -nap|grep 전체 포트 번호 확인을 할 수 있다. netstat -nap|grep {certain port number} 특정 포트만 검색하여 확인 할 수 있다. 포트 프로세스 죽이기 sudo kill $(sudo lsof -t -i:{want port number}) 다른방법으로 포트 번호가 죽지 않다가 이 방법으로 중지시킬 수 있었다. 하지만 다른 방법이 존재한다. 그 밖에 방법 fuser fuser -k {want port number}/tcp command kill PID kill -9 {PID}

[Algorithm] 올림피아드 최대점수구하기 python
BOJ 2022. 4. 5. 20:19

최대점수 구하기(DFS) 이번 정보올림피아드대회에서 좋은 성적을 내기 위하여 현수는 선생님이 주신 N개의 문제를 풀려고 합니다. 각 문제는 그것을 풀었을 때 얻는 점수와 푸는데 걸리는 시간이 주어지게 됩 니다. 제한시간 M안에 N개의 문제 중 최대점수를 얻을 수 있도록 해야 합니다. (해당문제는 해당시간이 걸리면 푸는 걸로 간주한다, 한 유형당 한개만 풀 수 있습니다.) ▣ 입력설명 첫 번째 줄에 문제의 개수N(1

article thumbnail
[TypeScript] OOP(객체 지향 프로그래밍) 기본 개념과 원칙 예시
Language/TypeScript 2022. 1. 16. 15:54

Class template declare once no data in Data가 없는 정의만 하는 template 같은 형식 Object instance of a class created many times data in 실질적으로 data를 넣어 만드는 친구 Object 구성 data (데이터) function (행동) 예시 차를 형상하는 Object가 있다고 생각하여 예시를 들어보자 차의 부품, 가격, 이름 - data 바퀴, 유리, 문, 차의 틀 등등... 주행법 - function 엑셀 브레이크 ... 여기에 조금을 더 추가해야한다. Error Exception Event ... OOP 원칙 OOP를 만드는 것이 위의 예시처럼이라면 쉽겠지만, 사실은 그렇지 않다. 정해진 것은 아니지만 4가지의 대..

[DB] Schema & Query Design
SW/Data Base 2022. 1. 16. 15:53

Schema & Query Design 데이터 간의 관계 데이터 간 관계를 기술하는 SQL 효율적인 방법으로 DB 구성 방법이해 DB에서 관련 찾기 위한 SQL 작성 방법 Schema Schema란? 스키마(Schema) DB에서 데이터가 구성되는 방식과 서로 다른 Entity 간의 관계에 대한 설명이다. Entity : 하나의 정보의 단위(굳이 비유하자면 JS에서 객체 하나 같은 것) Field : 하나의 정보에서 속성들의 집합 Record : 하나의 정보의 행 (수강원 테이블 Entity에서 -> name : kimcoding, age : 19) 단위 Entity 간의 관계 Teacher 과 Student가 있다면, 한명의 Teacher은 여러명의 Student를 가지므로 1:N(일대다) 관계에 있다..

[DB] Transaction Isolation Level (트랜잭션 고립 수준)
SW/Data Base 2022. 1. 16. 15:48

Transaction Isolation Level Concurrency control에서는 상황3을 다뤘다. 상황3 은 T1, T2가 모두 쓰기를 할 때 하지만 Transaction Isolation Level에서는 상황2를 다룬다. T1 읽기, T2 쓰기 상황2 에서 Lock을 사용하여 해결하는 것도 가능하나, 두 트랜잭션의 동시 진행 정도를 과도하게 막기 때문에 Performance issue가 발생한다. 이를 완하하기 위해 다른 방법을 찾을 필요가 있어 Isolation level이 있다. Read Error 트랜잭션1이 읽기, 트랜잭션2가 쓰기인 시나리오에서 트랜잭션1의 읽기 도중 문제가 발생한다. 아래 모든 시나리오는 T1-read T2-write로 생각한다. Dirty read T1, T2가 ..

[DB] Transaction Concurrency control (동시성 제어)
SW/Data Base 2022. 1. 16. 15:46

Concurrency control 트랜잭션이 동시에 수행 될 때, 일관성을 해치지 않도록 트랜잭션의 데이터 접근을 제어하는 DBMS의 기능을 동시성 제어(Concurrency control)이라고 한다. 동시성 제어 시나리오 상황 트랜잭션1 트랜잭션2 상황1 읽기 읽기 상황2 읽기 쓰기 상황3 쓰기 쓰기 읽기만 한다면 크게 문제가 없지만 문제는 상황2, 상황3에서 나타난다. 상황2는 Isoltion level에서 다루고 동시성 제어에서는 상황3을 살펴보자 갱신손실 문제 갱신손실(lost update) 문제는 두 개의 트랜잭션이 한 개의 데이터를동시에 갱신할 때 발생한다. 작업 설명 T1(트랜잭션1)은 예금을 인출하는 작업 T2(트랜잭션2)는 입금하는 작업 T1은 계좌 X에서 100을 뺀다. T2는 계좌..

반응형