일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- Git
- Docker
- 자연어처리
- Real or Not? NLP with Disaster Tweets
- ubuntu
- 우분투
- github
- AI 경진대회
- 더현대서울 맛집
- Baekjoon
- 캐치카페
- PYTHON
- 편스토랑
- programmers
- Kaggle
- 금융문자분석경진대회
- ChatGPT
- dacon
- SW Expert Academy
- 코로나19
- hackerrank
- 맥북
- 백준
- 편스토랑 우승상품
- 프로그래머스 파이썬
- 프로그래머스
- 파이썬
- 데이콘
- gs25
- leetcode
- Today
- Total
목록
반응형
Programming (1169)
솜씨좋은장씨
Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create. You can return the output in any order. Example 1: Input: S = "a1b2" Output: ["a1b2","a1B2","A1b2","A1B2"] Example 2: Input: S = "3z4" Output: ["3z4","3Z4"] Example 3: Input: S = "12345" Output: ["12345"] Example 4: Input: S = ..
Python과 elasticsearch 라이브러리를 통하여 nested 또는 object 형식으로 매핑되어 있는 필드에 인덱싱을 진행하려고 하는데 ValueError: Circular reference detected 위와 같은 오류가 계속 발생하여 이게...뭐지....? 매핑 형식이 잘 못 된 것인가... 고민을 했습니다. 구글을 검색하다보니 json 을 만들때 자기 자신 json을 다시 자기 자신에게 특정 키로 접근을 하려고 할 때 위와 같은 오류가 발생하는 것 같았습니다. 이렇게 알고 다시 코드를 확인해보니 position['bounding_box'] = position 인덱싱하려고 데이터를 만드는 반복문 안에서 자기 자신을 계속 자기 자신에게 넣으려고 하는 곳을 발견하였고 해당 부분을 수정하니 해..
OpenCV를 활용하여 이미지를 열고 특정 위치에 원과 사각형을 그린 후에 다시 저장하는 코드를 작성하였는데 error: (-215:Assertion failed) !_src.empty() 뭔가 cv2.imwrite를 통하여 저장하려고 하면 위와 같은 오류가 발생했습니다. 위의 오류가 발생하는 원인은 두 가지가 있습니다. 1. 잘못된 파일 경로 img = cv2.imread("{{ 파일 경로 }}") 첫 번째는 위와 같이 cv2.imread를 활용하여 파일을 불러올 때 입력한 파일 경로가 잘못 되어 입력한 파일 경로로 파일을 찾으려고 하여 오류가 발생하는 경우 입니다. 이를 해결하는 방법은 내가 불러오고자 하는 파일의 위치를 다시 확인하고 수정해주면 됩니다. 2. 파일 이름이 한글로 되어있는 경우 만약 ..
Given a positive integer num, write a function which returns True if num is a perfect square else False. Follow up: Do not use any built-in library function such as sqrt. Example 1: Input: num = 16 Output: true Example 2: Input: num = 14 Output: false Constraints: 1
International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a" maps to ".-", "b" maps to "-...", "c" maps to "-.-.", and so on. For convenience, the full table for the 26 letters of the English alphabet is given below: [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...
Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same frequency, sort them in decreasing order. Return the sorted array. Example 1: Input: nums = [1,1,2,2,2,3] Output: [3,1,1,2,2,2] Explanation: '3' has a frequency of 1, '1' has a frequency of 2, and '2' has a frequency of 3. Example 2: Input: nums = [2,3,1,3,2]..
In English, we have a concept called root, which can be followed by some other word to form another longer word - let's call this word successor. For example, when the root "an" is followed by the successor word "other", we can form a new word "another". Given a dictionary consisting of many roots and a sentence consisting of words separated by spaces, replace all the successors in the sentence ..
Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length. Do not allocate extra space for another array; you must do this by modifying the input array in-place with O(1) extra memory. Clarification: Confused why the returned value is an integer, but your answer is an array? Note that the input array is passed in by reference,..
Given a sentence text (A sentence is a string of space-separated words) in the following format: First letter is in upper case. Each word in text are separated by a single space. Your task is to rearrange the words in text such that all words are rearranged in an increasing order of their lengths. If two words have the same length, arrange them in their original order. Return the new text follow..
You are given a string text of words that are placed among some number of spaces. Each word consists of one or more lowercase English letters and are separated by at least one space. It's guaranteed that text contains at least one word. Rearrange the spaces so that there is an equal number of spaces between every pair of adjacent words and that number is maximized. If you cannot redistribute all..
Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middle node. Example 1: Input: [1,2,3,4,5] Output: Node 3 from this list (Serialization: [3,4,5]) The returned node has value 3. (The judge's serialization of this node is [3,4,5]). Note that we returned a ListNode object ans, such that: ans.val = 3, an..
We have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 or 11). Now given a string represented by several bits. Return whether the last character must be a one-bit character or not. The given string will always end with a zero. Example 1: Input: bits = [1, 0, 0] Output: True Explanation: The only way to decode i..
Given an array A of integers, for each integer A[i] we may choose any x with -K
Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of the following cases holds: All letters in this word are capitals, like "USA". All letters in this word are not capitals, like "leetcode". Only the first letter in this word is capital, like "Google". Otherwise, we define that this word doesn't use..
최근 프로젝트를 진행하면서 개발하는 서버에 Elasticsearch를 설치해두고 편하게 사용하기 위하여 Elasticsearch의 9200 포트, Kibana의 5601 포트에 대해서 외부의 모든 접근을 허용하도록 인바운드 규칙을 설정해 두었었습니다. 설치를 하고 테스트로 제대로 동작하는지 인덱스를 생성해보고 더미 데이터를 인덱싱 해두었다가 이제 실제로 사용하려고 다시 Kibana를 켜서 인덱스 목록을 보았는데 ???????????????????????????????????????????? 테스트를 하면서 만들었던 인덱스는 사라져있고 그 자리에 인덱스 이름부터 날좀보소 하는 인덱스 하나만 남아 있었습니다. 뭐지? 하고 궁금해서 확인해보니 확인에 사용한 검색식 GET /read_me/_search { "q..
gunicorn을 활용하여 Flask로 만든 API를 배포하기 위하여 gunicorn --bind 0.0.0.0:5000 -w=2 -k=gevent --threads=2 app:app 위의 명령어를 활용하여 실행을 하니 [Ubuntu] ModuleNotFoundError: No module named '_bz2' 해결 방법 우분투에서 아래의 명령어를 통해 api를 gunicorn을 활용하여 띄우려고 할때 gunicorn --bind 0.0.0.0:5000 -w=2 -k=gevent --threads=2 app:app /usr/local/lib/python3.7/importlib/_bootstrap.py:219: Runtime.. somjang.tistory.com [Ubuntu] UserWarning: ..
Write a function to delete a node in a singly-linked list. You will not be given access to the head of the list, instead you will be given access to the node to be deleted directly. It is guaranteed that the node to be deleted is not a tail node in the list. Example 1: Input: head = [4,5,1,9], node = 5 Output: [4,1,9] Explanation: You are given the second node with value 5, the linked list shoul..
A web developer needs to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L and width W satisfy the following requirements: The area of the rectangular web page you designed must equal to the given target area. The width W should not be larger than the length L, which means L >= W. The differ..
The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance. Note: 0 ≤ x, y < 231. Example: Input: x = 1, y = 4 Output: 2 Explanation: 1 (0 0 0 1) 4 (0 1 0 0) ↑ ↑ The above arrows point to positions where the corresponding bits are different. Soltuion class Solution: def hammingDist..
S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sorted in some custom order previously. We want to permute the characters of T so that they match the order that S was sorted. More specifically, if x occurs before y in S, then x should occur before y in the returned string. Return any permutation of T (as a string) that satisfies this property. Exam..
Given a string S and a character C, return an array of integers representing the shortest distance from the character C in the string. Example 1: Input: S = "loveleetcode", C = 'e' Output: [3, 2, 1, 0, 1, 0, 0, 1, 2, 2, 1, 0] Note: S string length is in [1, 10000]. C is a single character, and guaranteed to be in string S. All letters in S and C are lowercase. 첫번째 시도 class Solution: def shortest..
Given an integer array arr, return the mean of the remaining integers after removing the smallest 5% and the largest 5% of the elements. Answers within 10-5 of the actual answer will be considered accepted. Example 1: Input: arr = [1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3] Output: 2.00000 Explanation: After erasing the minimum and the maximum values of this array, all elements are equal to 2, so ..
Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the binary representation of a number. Return the decimal value of the number in the linked list. Example 1: Input: head = [1,0,1] Output: 5 Explanation: (101) in base 2 = (5) in base 10 Example 2: Input: head = [0] Output: 0 Example 3: Input: head = [1]..
Given an array nums of integers, return how many of them contain an even number of digits. Example 1: Input: nums = [12,345,2,6,7896] Output: 2 Explanation: 12 contains 2 digits (even number of digits). 345 contains 3 digits (odd number of digits). 2 contains 1 digit (odd number of digits). 6 contains 1 digit (odd number of digits). 7896 contains 4 digits (even number of digits). Therefore only ..
wand 라이브러리 설치 $ pip install wand 위의 라이브러리는 ImageMagick이라는 것을 활용하므로 이것도 같이 설치해주어야 합니다. ImageMagick 설치 Ubuntu 에서 설치하는 방법 sudo apt-get install libmagickwand-dev 위의 명령어로 설치한 이후에 사용할 설정을 수정해주면 완료입니다. [Python] wand.exceptions.PolicyError: not authorized `./test.pdf' @ error/constitute.c/ReadImage/412 해결방법 wand와 ImageMagick을 설치한 후 pdf를 tiff로 변환하려고 할 때 wand.exceptions.PolicyError: not authorized `./test..
wand와 ImageMagick을 설치한 후 pdf를 tiff로 변환하려고 할 때 wand.exceptions.PolicyError: not authorized `./test.pdf'@ error/constitute.c/ReadImage/412 위와 같은 오류를 만나게 되었습니다. 위는 imageMagick의 설정에 pdf 관련 설정이 none으로 설정되어있기 때문입니다. 이를 해결하는 방법은 다음과 같습니다. 먼저 설정을 변경할 파일을 vi 편집기로 열어줍니다. $ sudo vi /etc/ImageMagick-6/policy.xml $ sudo vi /etc/ImageMagick/policy.xml 위의 두 경로 중 본인의 설치 버전에 맞는 버전의 경로로 들어가면됩니다. 여러 부분 중에서 위의 부분을 ..
이 글에서는 자주 사용하는 정규식을 정리하려합니다. XXXX년 XX월 XX일 ( 년 월 일 형식 추출 정규식 ) import re value = "오늘은 2020년 12월 29일 입니다." pattern = r"\d+년 \d+월 \d+일" regex_result = re.search(pattern, value) result = regex_result.group() 특수문자 제거 정규식 import re regex_text = re.sub('[-=+,#/\?:^$.@*\"※~&%ㆍ!』\\‘|\(\)\[\]\`\'…》]', '', text) XX-XXX-XXXX | XX-XXXX-XXXX | XXX-XXX-XXXX | XXX-XXXX-XXXX ( 전화번호 추출 정규식 ) import re value = "내..
Given an array of unique integers salary where salary[i] is the salary of the employee i. Return the average salary of employees excluding the minimum and maximum salary. Example 1: Input: salary = [4000,3000,1000,2000] Output: 2500.00000 Explanation: Minimum salary and maximum salary are 1000 and 4000 respectively. Average salary excluding minimum and maximum salary is (2000+3000)/2= 2500 Examp..
Given two non-negative integers low and high. Return the count of odd numbers between low and high (inclusive). Example 1: Input: low = 3, high = 7 Output: 3 Explanation: The odd numbers between 3 and 7 are [3,5,7]. Example 2: Input: low = 8, high = 10 Output: 1 Explanation: The odd numbers between 8 and 10 are [9]. Constraints: 0
Given an array arr of positive integers sorted in a strictly increasing order, and an integer k. Find the kth positive integer that is missing from this array. Example 1: Input: arr = [2,3,4,7,11], k = 5 Output: 9 Explanation: The missing positive integers are [1,5,6,8,9,10,12,13,...]. The 5th missing positive integer is 9. Example 2: Input: arr = [1,2,3,4], k = 2 Output: 6 Explanation: The miss..