[NeetCode/Python] Buy and Sell Crypto
·
Algorithm/NeetCode
문제 링크: https://neetcode.io/problems/buy-and-sell-crypto NeetCode neetcode.io 투 포인터/슬라이딩 윈도우 [내 풀이]class Solution: def maxProfit(self, prices: List[int]) -> int: maxProfit = 0 for i in range(len(prices)-1): for j in range(i, len(prices)): profit = prices[j] - prices[i] if profit > maxProfit: maxProfit = profit ret..
[NeetCode/Python] Min Cost Climbing Stairs
·
Algorithm/NeetCode
문제 링크: https://neetcode.io/problems/min-cost-climbing-stairs NeetCode neetcode.io 예전에 알고리즘 감을 살릴겸, 순차적으로 구하는 방법, 역순으로 구하는 방법 두 방법 모두를 사용해서 풀어보았다.점점 이제 이지 난이도에서 벗어나야할텐데... 준비중이다!  [내 코드 1: 순차적 풀이]class Solution: def minCostClimbingStairs(self, cost: List[int]) -> int: n = len(cost) result = [0 for i in range(len(cost))] # cost.length >= 2 result[0], result[1] = cost..
[B+Tree/BTree/BST/Hash Table] 인덱스에서 B+Tree를 사용하는 이유
·
Computer Science/Data Structure
DB 설계에서 가장 중요한 인덱스에 대해서 아는게 너무 없는 것 같아 개인적으로 공부한 내용들이다.  데이터 구조인덱스는 왜 B+Tree를 사용하고 있을까? 이 질문에 대한 해답을 찾기에 앞서, 탐색에 용이한 데이터 구조들과 특징들에 대해 살펴보자. Binary Search Tree(BST) 이진 탐색 트리(Binary Search Tree, BST)는 이진 탐색과 연결 리스트(Linked List)의 장점을 결합한 자료구조이다.이진탐색장점: 탐색에 소요되는 시간복잡도가 O(log N)으로 빠르다.연결 리스트장점: 자료 입력, 삭제에 필요한 시간 복잡도가 O(1). (하지만 맨 앞 또는 맨 뒤의 데이터에 대해서만 시간 복잡도가 O(1)이고 특정 노드 다음에 삽입, 삭제가 이루어지는 경우에는 O(n+1) ..
[LeetCode/Python] 9. Palindrome Number
·
Algorithm/LeetCode
문제 링크: https://leetcode.com/problems/palindrome-number/?envType=study-plan-v2&envId=top-interview-150 숫자를 문자열로 바꿔서 풀면 아주 쉬운 문제다.근데 문제 말미에 문자열로 안바꾸고 풀어보라는 챌린지가 있길래 시도했다가 처참히 실패했다..ㅠ 일단 인풋을 문자열로 바꾸지 않고 숫자 자체로 두고 푼 코드는 아래와 같다.class Solution: def isPalindrome(self, x: int) -> bool: if x 0: n = len(str(x)) divisor = 10 **(n-1) left = x // divisor ..
[LeetCode/Python] 67. Add Binary
·
Algorithm/LeetCode
문제 링크: https://leetcode.com/problems/add-binary/description/?envType=study-plan-v2&envId=top-interview-150 숫자로 쉽게 치환해서 패키지를 써서 이진법 덧셈을 할 생각이었는데, string 자체로 풀어보고 싶다고 생각했다.  [내 풀이]class Solution: def addBinary(self, a: str, b: str) -> str: # without converting string to int carry = 0 i, j = len(a) - 1, len(b) - 1 result = [] while i >= 0 or j >= 0 or carry: ..
[2024 KBW] Ethena(에테나) Side Event 후기
·
BlockChain/Meetup
kbw 기간에 다녀온 에테나 사이드 이벤트에서 들은 공동 창업자의 발표 내용을 중심으로 정리Ethena이더리움 기반의 합성달러(synthetic dollar) USDe의 프로토콜에테나의 목적은 탈중앙화 자체가 아니라 기존 금융 자산들로부터 독립되어있는 온체인 달러 자산을 만드는 것 합성 달러(USDe)를 만들게된 계기에테나는 아서 헤이즈가 제시한 문제로부터 시작했는데요.아서 헤이즈는, 크립토 산업에서 가장 큰 기회는 “확장 가능한”, “크립토 기반의 달러”를 만드는 것이다고 했습니다.이 아이디어에 착안해, 에테나 창업자는 기존의 은행 시스템에 의존하지 않고 크립토 생태계 내에서 자유롭게 거래될 수 있는 달러를 개발하게 된건데요! 중앙화된 시스템이 제공하는 안정성과 법적 인프라에 의존하지 않는 크립토 환경..