일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- SW Expert Academy
- Real or Not? NLP with Disaster Tweets
- github
- 파이썬
- 데이콘
- 맥북
- gs25
- hackerrank
- programmers
- PYTHON
- Docker
- 더현대서울 맛집
- ChatGPT
- leetcode
- 자연어처리
- 프로그래머스 파이썬
- AI 경진대회
- dacon
- 프로그래머스
- Kaggle
- Baekjoon
- 금융문자분석경진대회
- 우분투
- Git
- 백준
- 캐치카페
- 코로나19
- 편스토랑
- ubuntu
- 편스토랑 우승상품
- Today
- Total
목록
반응형
Programming (1169)
솜씨좋은장씨
Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character but a character may map to itself. Example 1: Input: s = "egg", t = "add" Output: true Example 2: In..
Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters. Please note that the string does not contain any non-printable characters. Example: Input: "Hello, my name is John" Output: 5 Solution class Solution: def countSegments(self, s: str) -> int: answer = len(s.split()) return answer SOMJANG/CODINGTEST_PRACTICE 1일 1문제 since 2020.0..
Given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string. Return the shuffled string. Example 1: Input: s = "codeleet", indices = [4,5,6,7,0,2,1,3] Output: "leetcode" Explanation: As shown, "codeleet" becomes "leetcode" after shuffling. Example 2: Input: s = "abc", indice..
We are given two sentences A and B. (A sentence is a string of space separated words. Each word consists only of lowercase letters.) A word is uncommon if it appears exactly once in one of the sentences, and does not appear in the other sentence. Return a list of all uncommon words. You may return the list in any order. Example 1: Input: A = "this apple is sweet", B = "this apple is sour" Output..
Given two arrays, write a function to compute their intersection. Example 1: Input: nums1 = [1,2,2,1], nums2 = [2,2] Output: [2] Example 2: Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] Output: [9,4] Note: Each element in the result must be unique. The result can be in any order. Solution class Solution: def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]: return list(set(nums1..
Example 3: Given a date, return the corresponding day of the week for that date. The input is given as three integers representing the day, month and year respectively. Return the answer as one of the following values {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}. Example 1: Input: day = 31, month = 8, year = 2019 Output: "Saturday" Example 2: Input: day = 18, mo..
Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. Example: Input: [1,2,1,3,2,5] Output: [3,5] Note: The order of the result is not important. So in the above example, [5, 3] is also correct. Your algorithm should run in linear runtime complexity. Could you implement it using..
You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. Follow up: What if you cannot modify the input lists? In other words, reversing the li..
Write a program to count the number of days between two dates. The two dates are given as strings, their format is YYYY-MM-DD as shown in the examples. Example 1: Input: date1 = "2019-06-29", date2 = "2019-06-30" Output: 1 Example 2: Input: date1 = "2020-01-15", date2 = "2019-12-31" Output: 15 Constraints: The given dates are valid dates between the years 1971 and 2100. Solution import datetime ..
Given a string date representing a Gregorian calendar date formatted as YYYY-MM-DD, return the day number of the year. Example 1: Input: date = "2019-01-09" Output: 9 Explanation: Given date is the 9th day of the year in 2019. Example 2: Input: date = "2019-02-10" Output: 41 Example 3: Input: date = "2003-03-01" Output: 60 Example 4: Input: date = "2004-03-01" Output: 61 Constraints: date.length..
Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example 1: Input: 16 Output: true Example 2: Input: 5 Output: false Follow up: Could you solve it without loops/recursion? Accepted Solution class Solution: def isPowerOfFour(self, num: int) -> bool: if num
Given a non-empty list of words, return the k most frequent elements. Your answer should be sorted by frequency from highest to lowest. If two words have the same frequency, then the word with the lower alphabetical order comes first. Example 1: Input: ["i", "love", "leetcode", "i", "love", "coding"], k = 2 Output: ["i", "love"] Explanation: "i" and "love" are the two most frequent words. Note t..
Given an integer n, return 1 - n in lexicographical order. For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9]. Please optimize your algorithm to use less time and space. The input size may be as large as 5,000,000. Solution class Solution: def lexicalOrder(self, n: int) -> List[int]: my_nums = [str(i) for i in range(1, n+1)] my_nums = list(sorted(my_nums)) return my_nums SOMJANG/CODI..
[Python] Python3에서 venv로 가상환경 만들고 사용하기! 예전 Ubuntu에서 Python 가상환경을 만들때에는 virtualenv를 활용하여 가상환경을 만들고 사용했었습니다. Windows에서도 virtualenv를 설치하고자 검색 중 venv라는 더 편하고 쉽게 사용할 수 있는 방법을 somjang.tistory.com 위와 같은 방법으로 Python에서 만든 가상환경을 Jupyter Notebook에 추가하는 방법은 다음과 같습니다. 먼저 만든 가상환경을 활성화 시킵니다. 만들어둔 가상환경의 이름이 myvenv라고 가정하면 $ source myvenv/bin/activate 위와 같은 방법으로 활성화시켜줍니다. 윈도우의 경우 $ myvenv\Scripts\activate 그 다음 pi..
Given an integer n, return the number of trailing zeroes in n!. Example 1: Input: 3 Output: 0 Explanation: 3! = 6, no trailing zero. Example 2: Input: 5 Output: 1 Explanation: 5! = 120, one trailing zero. Note: Your solution should be in logarithmic time complexity. Solution class Solution: def trailingZeroes(self, n: int) -> int: answer = 0 while n: n //= 5 answer += n return answer SOMJANG/COD..
Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? Example 1: Input: [2,2,3,2] Output: 3 Example 2: Input: [0,1,0,1,0,1,99] Output: 99 Solution from collections import Counter class Solution: def sin..
Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; otherwise, it will return false. Each letter in the magazine string can only be used once in your ransom note. Example 1: Input: ransomNote = "a", magazine = "b" Output: false Example 2: Input: ransom..
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: Input: -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome. Example 3: Input: 10 Output: false Explanation: Reads 01 from right to left. Therefore it ..
Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is at least one word that isn't banned, and that the answer is unique. Words in the list of banned words are given in lowercase, and free of punctuation. Words in the paragraph are not case sensitive. The answer is in lowercase. Example: Input: paragraph = "..
평소와 같이 아나콘다로 만든 가상환경을 활성화하기 위하여 $ conda activate tensorflow_1_11_p36 위처럼 가상환경 활성화 명령어를 입력하였으나 CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. If your shell is Bash or a Bourne variant, enable conda for the current user with $ echo ". /home/ubuntu/anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc or, for all users, enable conda with $ sudo ln -s /home/ubunt..
Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array. Example 1: Input: a = 2, b = [3] Output: 8 Example 2: Input: a = 2, b = [1,0] Output: 1024 Solution class Solution: def superPow(self, a: int, b: List[int]) -> int: answer = 1 for b_val in b[::-1]: answer = answer * a ** b_val % 1337 a = pow(a, 10) % 133..
자바스크립트에서 배열의 앞뒤에 데이터를 추가하는 방법입니다. 다음과 같이 배열 하나가 생성되어있을때 var myArray = [] 배열의 앞에 데이터를 추가하는 방법 myArray.unshift(추가할 항목); 배열의 가장 뒤에 데이터를 추가하는 방법 myArray.push(추가할 항목); 이렇게 unshift와 push를 이용하여 데이터를 추가할 수 있습니다. 반대로 삭제하는 방법은 다음과 같습니다. 배열의 앞의 데이터를 삭제하는 방법 myArray.shift(); 배열의 뒤의 데이터를 삭제하는 방법 myArray.pop();
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example 1: Input: a = 1, b = 2 Output: 3 Example 2: Input: a = -2, b = 3 Output: 1 Solution class Solution: def getSum(self, a: int, b: int) -> int: answer = sum([a, b]) return answer SOMJANG/CODINGTEST_PRACTICE 1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating..
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1]. Solution class Solution: def twoSum(self, nums: List[int], target: int) -> List[..
Given an integer, write a function to determine if it is a power of two. Example 1: Input: 1 Output: true Explanation: 20 = 1 Example 2: Input: 16 Output: true Explanation: 24 = 16 Example 3: Input: 218 Output: false Solution class Solution: def isPowerOfTwo(self, n: int) -> bool: answer = False pow_2s = [] for i in range(50): pow_2s.append(pow(2, i)) if n in pow_2s: answer = True return answer ..
For a non-negative integer X, the array-form of X is an array of its digits in left to right order. For example, if X = 1231, then the array form is [1,2,3,1]. Given the array-form A of a non-negative integer X, return the array-form of the integer X+K. Example 1: Input: A = [1,2,0,0], K = 34 Output: [1,2,3,4] Explanation: 1200 + 34 = 1234 Example 2: Input: A = [2,7,4], K = 181 Output: [4,5,5] E..
The absolute difference between two integers, a and b, is written as |a - b|. The maximum absolute difference between two integers in a set of positive integers, elements, is the largest absolute difference between any two integers in elements. The Difference class is started for you in the editor. It has a private integer array (elements) for storing N non-negative integers, and a public intege..
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night. Given a list of non-negative integers representing the amount..
1일 1문제 153일차! 153일차의 문제는 백준의 1, 2, 3 더하기 입니다. 9095번: 1, 2, 3 더하기 문제 정수 4를 1, 2, 3의 합으로 나타내는 방법은 총 7가지가 있다. 합을 나타낼 때는 수를 1개 이상 사용해야 한다. 1+1+1+1 1+1+2 1+2+1 2+1+1 2+2 1+3 3+1 정수 n이 주어졌을 때, n을 1, 2, 3의 합으로 나타내는 www.acmicpc.net Solution loopN = int(input()) answers = [] for i in range(loopN): inputNum = int(input()) if inputNum == 1: answers.append(1) elif inputNum == 2: answers.append(2) elif input..
이 글은 새로운 방법을 알게 될 때 마다 계속 업데이트 할 예정입니다. 우리는 종종 별도의 설정없이 matplotlib으로 한글이 들어간 그래프를 그리고자 할때 아래와 같이 한국어가 ㅁ로 깨져서 나오는 것을 볼 수 있습니다. 이 글에서는 위처럼 matplotlib 활용 시 한글이 깨져나올 때 해결하는 방법에 대해서 적어보려 합니다. Mac OSX 1. matplotlib의 rcParams를 통해 전역 폰트 설정하기 먼저 matplotlib의 rcParams를 통해 전역 폰트를 설정해주는 방법입니다. 별도의 폰트 설치 없이도 가장 쉽게 설정할 수 있는 방법입니다. import matplotlib.pyplot as plt import matplotlib matplotlib.rcParams['axes.unic..