본문 바로가기

개발4

[Ubuntu] Failed to find libmagic. Check you installation. CC3M 데이터셋을 다운로드 받는 도중 아래 파일을 실행시켰을 때, python download_data.py Failed to find libmagic. Check you installation. 라는 에러메시지를 받았다. 인터넷에서 검색했을 때, 아래와 같이 설치하면 작동할 것이라하여 시도해 봤지만 여전히 해결이 되지 않았고, pip install python-magic-bin==0.4.14 좀 더 방법을 찾은 결과 아래의 명령어로 설치하니 해결되었다. sudo apt-get install libmagic1 2023. 2. 8.
[LeetCode] 121. Best Time to Buy and Sell Stock # 문제 설명 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 1: Input: prices = [7,1,5,3,6,4] Output: 5 .. 2023. 2. 7.
[LeetCode] 206. Reverse Linked List # 문제 설명 Given the head of a singly linked list, reverse the list, and return the reversed list. 이 문제는 링크드 리스트가 주어졌을 때 주어진 리스트의 역순 리스트를 반환하는 문제이다. # 예시 Input: head = [1,2,3,4,5] Output: [5,4,3,2,1] Input: head = [1,2] Output: [2,1] Input: head = [] Output: [] 이 문제를 보았을 때 쉽게 풀 수 있을 것이라 생각했지만 비효율적인 방법만 떠올랐다. class Solution: def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]: vals.. 2023. 2. 4.
[LeetCode] 21. Merge Two Sorted Lists # 문제 설명 You are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list. Input: list1 = [1,2,4], list2 = [1,3,4] Output: [1,1,2,3,4,4] Example 2: Input: list1 = [], list2 = [] Output: [] Example 3: Input: list1 = [], list2 = [0] Ou.. 2023. 2. 4.