Python

    [LeetCode] 152. Maximum Product Array

    [LeetCode] 152. Maximum Product Array

    *알고리즘 스터디에 참여하면서 Blind 75 LeetCode Questions 목록에 있는 문제를 풀이합니다. https://leetcode.com/problems/maximum-product-subarray/ Maximum Product Subarray - 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 문제 해설 숫자 배열이 주어지고, 연속되고 빈 배열이 아닌 부분 배열 중 곱의 값이 가장 큰 것을 찾아 return 한다. 앞서 해설했던 53. Maximum..

    [Python] GIL, Global Interpreter Lock이란?

    [Python] GIL, Global Interpreter Lock이란?

    안녕하세요, 개발자 하댑입니다. 오늘은 파이썬 멀티스레드를 사용하려고 한다면 알아야하는 GIL에 대해 알아보겠습니다. 파이썬의 경우 단순히 멀티스레딩을 코드로 구현해서 테스팅을 해보면 멀티스레딩의 연산 속도가 성능이 나쁜 것을 확인할 수 있습니다. 이런 결과가 나오는 이유는 바로 CPython Global Interpreter Lock, 즉 GIL이 적용되기 때문입니다. Global Interpreter Lock, GIL이 뭔데? Python Wiki에서는 다음과 같이 설명합니다. CPython에서 GIL은 파이썬 코드(bytecode)를 실행할 때에 여러 스레드를 사용할 경우, 단 하나의 스레드만 파이썬 객체에 접근할 수 있도록 제한하는 mutex 이다. 그리고 이 lock이 필요한 이유는 CPytho..

    [LeetCode] 53. Maximum Subarray

    [LeetCode] 53. Maximum Subarray

    *알고리즘 스터디에 참여하면서 Blind 75 LeetCode Questions 목록에 있는 문제를 풀이합니다. https://leetcode.com/problems/maximum-subarray/ Maximum Subarray - 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 문제 해설 입력 값으로 nums 라는 배열이 들어오고, 배열에는 최소 하나의 정수가 존재한다. 배열 원소들 중 연속되는 subarray의 합이 최대가 되는 값을 찾아 return 해야 한..

    [LeetCode] 238. Product of Array Except Self

    [LeetCode] 238. Product of Array Except Self

    *알고리즘 스터디에 참여하면서 Blind 75 LeetCode Questions 목록에 있는 문제를 풀이합니다. 문제: https://leetcode.com/problems/product-of-array-except-self/ Product of Array Except Self - 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 배열에서 현재 요소를 뺀 나머지 요소들을 곱한 값을 그 자리에 넣어서 Return 해야한다. 1. 입력한 리스트와 같은 크기의 리스트를 ..

    [LeetCode] 217. Contains Duplicate

    [LeetCode] 217. Contains Duplicate

    *알고리즘 스터디에 참여하면서 Blind 75 LeetCode Questions 목록에 있는 문제를 풀이합니다. 문제: https://leetcode.com/problems/contains-duplicate/ Contains Duplicate - 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 풀이: class Solution: def containsDuplicate(self, nums: List[int]) -> bool: # Sol 1 -- O(n) # dist..

    [LeetCode] 121. Best Time to Buy and Sell Stock

    [LeetCode] 121. Best Time to Buy and Sell Stock

    *알고리즘 스터디에 참여하면서 Blind 75 LeetCode Questions 목록에 있는 문제를 풀이합니다. 문제: https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ Best Time to Buy and Sell Stock - 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 풀이: class Solution: def maxProfit(self, prices: List[int]) -> int: if ..

    [LeetCode] 1. Two Sum

    [LeetCode] 1. Two Sum

    *알고리즘 스터디에 참여하면서 Blind 75 LeetCode Questions 목록에 있는 문제를 풀이합니다. 문제: https://leetcode.com/problems/two-sum/ Two Sum - 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 풀이: class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: nums_dic = {} # Stores the dictionary..

    [Python] 파이썬으로 Json 인코더와 디코더 사용하기(읽고 쓰기)

    [Python] 파이썬으로 Json 인코더와 디코더 사용하기(읽고 쓰기)

    python으로 Json 데이터를 인코딩, 디코딩하는 방법을 알아보자. Json JSON은 Javascript Object Notation의 약자로 웹 브라우저와 웹 서버 사이에서 데이터 교환 시 널리 사용하고 있다. 가장 많이 사용되는 JSON 포맷은 key-value pair 컬렌션이다. 먼저, Json 데이터 타입에 대해 알아보면, json은 다음 중 하나 또는 여러개의 데이터 타입을 포함할 수 있다. string number object(JSON object) array boolean null 그리고 다음 데이터 타입은 포함하지 못 한다. function date undefined JSON 인코딩/디코딩 Python Object를 Json 문자열로 변경하는 과정을 Json 인코딩이라고 부르고, J..

    PyPI 패키지 업로드 해보기

    PyPI 패키지 업로드 해보기

    PyPI 패키지 업로드 해보기 파이썬 패키지 인덱스(PyPI)는 파이썬 프로젝트를 부품화해서 아카이빙할 수 있는 메타데이터 서비스이다. 최신 PyPI에 대한 문서는 Python Packaging 사용자 가이드에서 참고할 수 있다. Python은 다른 개발자가 오픈 소스 라이센스 조건에 따라 소프트웨어를 사용할 수 있도록하는 사용자 커뮤니티가 활발하게 지원된다. Udacity AWS ML Foundation 강의 내용을 참고해서 PyPI 패키지를 업로드해봤다. PyPi vs. Test PyPi pipy.org와 test.pypi.org는 다른 웹사이트다. 회원가입도 물론 각기 따로 해줘야한다. 패키지 이름은 반드시 유니크해야 한다. 커맨드 창에서 입력할 때는 언더데쉬(_)를 사용해도, repository에..