일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- dacon
- 우분투
- 코로나19
- Docker
- 데이콘
- 캐치카페
- 금융문자분석경진대회
- gs25
- ChatGPT
- Git
- Real or Not? NLP with Disaster Tweets
- 자연어처리
- 백준
- ubuntu
- Kaggle
- hackerrank
- leetcode
- programmers
- 파이썬
- AI 경진대회
- PYTHON
- Baekjoon
- github
- 프로그래머스
- 맥북
- 편스토랑 우승상품
- 프로그래머스 파이썬
- 더현대서울 맛집
- 편스토랑
- SW Expert Academy
- Today
- Total
목록
반응형
Programming (1169)
솜씨좋은장씨
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/JbvNR/btqFtv0VSsu/6HV7gea7lQp94rT1VjbZG1/img.png)
1일 1문제 152일차! 오늘의 문제는 백준의 알파벳 개수입니다. 10808번: 알파벳 개수 단어에 포함되어 있는 a의 개수, b의 개수, …, z의 개수를 공백으로 구분해서 출력한다. www.acmicpc.net Solution word_s = input() word_count_dic = {'a':0, 'b':0, 'c':0, 'd':0, 'e':0, 'f':0, 'g':0, 'h':0, 'i':0, 'j':0, 'k':0, 'l':0, 'm':0, 'n':0, 'o':0, 'p':0, 'q':0, 'r':0, 's':0, 't':0, 'u':0, 'v':0, 'w':0, 'x':0, 'y':0, 'z':0} index = ['a','b','c', 'd', 'e', 'f', 'g', 'h', 'i', ..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/c3LJyE/btqFrah8RZi/brGSKSgwdIeWpCIjUMRleK/img.png)
1일 1문제 151일차! 오늘의 문제는 알파벳 찾기 입니다. 10809번: 알파벳 찾기 각각의 알파벳에 대해서, a가 처음 등장하는 위치, b가 처음 등장하는 위치, ... z가 처음 등장하는 위치를 공백으로 구분해서 출력한다. 만약, 어떤 알파벳이 단어에 포함되어 있지 않다면 -1을 출 www.acmicpc.net Solution word_s = input() word_count_dic = {'a':0, 'b':0, 'c':0, 'd':0, 'e':0, 'f':0, 'g':0, 'h':0, 'i':0, 'j':0, 'k':0, 'l':0, 'm':0, 'n':0, 'o':0, 'p':0, 'q':0, 'r':0, 's':0, 't':0, 'u':0, 'v':0, 'w':0, 'x':0, 'y':0, '..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/ZtD2H/btqFqMhwpk5/H59Kfm25pMTHVOOvpYKLO1/img.png)
1일 1문제 150일차! 150일차의 문제는 백준의 2진수 8진수 입니다. 1373번: 2진수 8진수 첫째 줄에 2진수가 주어진다. 주어지는 수의 길이는 1,000,000을 넘지 않는다. www.acmicpc.net Solution print(oct(int(input(), 2))[2:]) SOMJANG/CODINGTEST_PRACTICE 1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub. github.com
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/dEuQSm/btqFrmQanJT/8mBKvl29kM9RmxrTKXSjbK/img.png)
1일 1문제 149일차! 149일차의 문제는 최소공배수 입니다. 1934번: 최소공배수 두 자연수 A와 B에 대해서, A의 배수이면서 B의 배수인 자연수를 A와 B의 공배수라고 한다. 이런 공배수 중에서 가장 작은 수를 최소공배수라고 한다. 예를 들어, 6과 15의 공배수는 30, 60, 90등이 있� www.acmicpc.net Solution def gcd(a, b): mod = a%b while mod > 0: a = b b = mod mod = a%b return b def lcm(a, b): return a*b//gcd(a,b) loopNum = int(input()) for i in range(loopNum): inputNums = input() inputNums = inputNums.spli..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/b8mdDF/btqFo5WAl0l/eIpOEfOWtZyJK3FaZqEZ7k/img.png)
1일 1문제 148일차! 148일차의 문제는 최대공약수와 최소공배수 입니다. 2609번: 최대공약수와 최소공배수 첫째 줄에는 입력으로 주어진 두 수의 최대공약수를, 둘째 줄에는 입력으로 주어진 두 수의 최소 공배수를 출력한다. www.acmicpc.net Solution inputNums = input() inputNums = inputNums.split() a = int(inputNums[0]) b = int(inputNums[1]) def gcd(a, b): mod = a%b while mod > 0: a = b b = mod mod = a%b return b def lcm(a, b): return a*b//gcd(a,b) print(gcd(a, b)) print(lcm(a, b)) SOMJANG/C..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bQn0Sm/btqFrn9pWMS/KoeUF9tOfgBUuvnvU8fphk/img.png)
1일 1문제 147일차! 147일차의 문제는 백준의 나머지 입니다. 10430번: 나머지 첫째 줄에 A, B, C가 순서대로 주어진다. (2 ≤ A, B, C ≤ 10000) www.acmicpc.net Solution a,b,c= map(int, input().split()) print((a+b)%c) print((a%c + b%c)%c) print((a*b)%c) print((a%c * b%c)%c) SOMJANG/CODINGTEST_PRACTICE 1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub. github.com
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/d3ahlt/btqFgydLnad/hp2JKKvsbq2oAki7XaVNck/img.png)
1일 1문제 146일차! 오늘은 쉬어가는 타임! 백준의 8진수 2진수 입니다. 1212번: 8진수 2진수 첫째 줄에 8진수가 주어진다. 주어지는 수의 길이는 333,334을 넘지 않는다. www.acmicpc.net Solution print(bin(int(input(), 8))[2:]) SOMJANG/CODINGTEST_PRACTICE 1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub. github.com
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bFkE48/btqFeOthgSC/q1U2l8bkzDWOcIxDdi7iKK/img.png)
Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and both would die. Given a flowerbed (represented as an array containing 0 and 1, where 0 means empty and 1 means not empty), and a number n, return if n new flowers can be planted in it without violating the no-adjacent-f..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/qdIHb/btqFeN1sFb1/UbkN31jvllECkd1yHVr2gk/img.png)
1일 1문제 144일차! 오늘의 문제는 Base Conversion입니다. 11576번: Base Conversion 타임머신을 개발하는 정이는 오랜 노력 끝에 타임머신을 개발하는데 성공하였다. 미래가 궁금한 정이는 자신이 개발한 타임머신을 이용하여 500년 후의 세계로 여행을 떠나게 되었다. 500년 후의 www.acmicpc.net Solution A, B = map(int, input().split()) m = int(input()) num = list(map(int, input().split())) result = [] n = 0 for i in range(len(num)): n = n + (num.pop() * (A**i)) while n: result.append(n%B) n //= B whi..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/ck6Xhs/btqFdmoVwGb/nzHfPYhl1EXZTMYRVFkbuk/img.png)
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one. Example 1: Input: [1,3,4,2,2] Output: 2 Example 2: Input: [3,1,3,4,2] Output: 3 Note: You must not modify the array (assume the array is read only). You must use only constant,..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/uZsPs/btqFdmCtOP8/Z43KS3gbmk1jA02K0bvtuK/img.png)
1일 1문제 142일차! 142일차의 문제는 진법 변환 2입니다. 11005번: 진법 변환 2 10진법 수 N이 주어진다. 이 수를 B진법으로 바꿔 출력하는 프로그램을 작성하시오. 10진법을 넘어가는 진법은 숫자로 표시할 수 없는 자리가 있다. 이런 경우에는 다음과 같이 알파벳 대문자를 �� www.acmicpc.net Solution B_jinbub_dic = { 0:'0', 1:'1', 2:'2', 3:'3', 4:'4', 5:'5', 6:'6', 7:'7', 8:'8', 9:'9', 10:'A', 11:'B', 12:'C', 13:'D', 14:'E', 15:'F', 16:'G', 17:'H', 18:'I', 19:'J', 20:'K', 21:'L', 22:'M', 23:'N', 24:'O', 25..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/M9hbI/btqFbA2IKuJ/S816jVd3tzgXh3k5BaBOd1/img.png)
1일 1문제 141일차! 141일차의 문제는 백준의 가장 큰 증가 부분 수열입니다. 11055번: 가장 큰 증가 부분 수열 수열 A가 주어졌을 때, 그 수열의 증가 부분 수열 중에서 합이 가장 큰 것을 구하는 프로그램을 작성하시오. 예를 들어, 수열 A = {1, 100, 2, 50, 60, 3, 5, 6, 7, 8} 인 경우에 합이 가장 큰 증가 부분 수� www.acmicpc.net Solution inputNum = int(input()) inputNums = input() inputNums = inputNums.split() inputNums = [int(num) for num in inputNums] nc = [0] * (inputNum) maxNum = 0 for i in range(0, in..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bC7qCO/btqFcugEe28/91kuh7yU3KMIS1XA1O8Uo1/img.png)
1일 1문제 140일차! 140일차의 문제는 백준의 가장 긴 바이토닉 부분 수열 입니다. 11054번: 가장 긴 바이토닉 부분 수열 첫째 줄에 수열 A의 크기 N이 주어지고, 둘째 줄에는 수열 A를 이루고 있는 Ai가 주어진다. (1 ≤ N ≤ 1,000, 1 ≤ Ai ≤ 1,000) www.acmicpc.net Solution import sys r = lambda : sys.stdin.readline() def _get_seq_len(a): dp = [1 for _ in range(len(a))] rev_dp = [1 for _ in range(len(a))] for i in range(len(a)): dp[i] = 1 for j in range(i, -1, -1): if a[i] > a[j] and..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/dwVVxh/btqFbUzQE5R/QQK0RGjpzhdKYdcjKeezM0/img.png)
1일 1문제 139일차! 139일차의 문제는 백준의 카드 구매하기 입니다. 11052번: 카드 구매하기 첫째 줄에 민규가 구매하려고 하는 카드의 개수 N이 주어진다. (1 ≤ N ≤ 1,000) 둘째 줄에는 Pi가 P1부터 PN까지 순서대로 주어진다. (1 ≤ Pi ≤ 10,000) www.acmicpc.net Solution cardNum = int(input()) NC = [0]*(cardNum+1) cardPrice = [0]+list(map(int, input().split())) def answer(): NC[0], NC[1] = 0, cardPrice[1] for i in range(2, cardNum+1): for j in range(1, i+1): NC[i] = max(NC[i], NC[i..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/qKRbE/btqE32EYSjs/Mcv8SPh9YdKjYS7C5dMm90/img.png)
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority element always exist in the array. Example 1: Input: [3,2,3] Output: 3 Example 2: Input: [2,2,1,1,1,2,2] Output: 2 Solution class Solution: def majorityElement(self, nums: List[int]) -> int: keys = set(nums) ans..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/3xADv/btqE14RaGaN/UoS5jXb3Z4A6eQeYzL59f1/img.png)
We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself.Now, given an integer n, write a function that returns true when it is a perfect number and false when it is not. Example: Input: 28 Output: True Explanation: 28 = 1 + 2 + 4 + 7 + 14 Note: The input number n will not exceed 100,000,000. (1e8) Solution import math class Solution(..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/cBmh2W/btqE2lZtY6J/R3HjssMfKkGeiGs2UdWdR0/img.png)
Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of them. If there are less than 2k but greater than or equal to k characters, then reverse the first k characters and left the other as original. Example: Input: s = "abcdefg", k = 2 Output: "bacdfeg" Rest..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/0tWqr/btqE0l6p62F/LbnpL6m3kMB1qUjfN7stcK/img.png)
Comparators are used to compare two objects. In this challenge, you'll create a comparator and use it to sort an array. The Player class is provided in the editor below. It has two fields: name : a string. score : an integer. Given an array of n Player objects, write a comparator that sorts them in order of decreasing score. If 2 or more players have the same score, sort those players alphabetic..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/dyqZon/btqE0kscvyH/KVB2iWfZCj95KVWcjC7oIk/img.png)
Given a non-negative integer c, your task is to decide whether there're two integers a and b such that a2 + b2 = c. Example 1: Input: 5 Output: True Explanation: 1 * 1 + 2 * 2 = 5 Example 2: Input: 3 Output: False Solution class Solution: def judgeSquareSum(self, c): for i in range(0,int(c**0.5)+1): extra=c-pow(i, 2) if (pow(int(extra**0.5),2)) == extra: return True return False SOMJANG/CODINGTE..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bv2JS5/btqEZMXdMWV/kJXZK7cMH0YEV5cOzkouk0/img.png)
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Example: Input: [0,1,0,3,12] Output: [1,3,12,0,0] Note: You must do this in-place without making a copy of the array. Minimize the total number of operations. Solution class Solution: def moveZeroes(self, nums): for i in range(len(nums))[::-1]: if nums[i] == 0: nu..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/cJ6MMr/btqEVJ7IRp7/jnYy7JC8nVPF87RC7pyHP0/img.jpg)
문자열 표현 방법 var a = '작은 따옴표 활용'; var b = "큰 따옴표 활용"; 작은 따옴표 또는 큰 따옴표로 묶어서 표현 작은 따옴표 표현 방법 var c = "큰 따옴표 안에 작은 따옴표 ' 사용"; var d = "역슬래시를 활용하여 표현 \' 할수도 있음"; var d = '역슬래시를 활용하여 표현 \' 할수도 있음'; 큰 따옴표로 묶은 후 그 안에 작은 따옴표를 활용하는 방법과 역슬래시를 활용하는 방법 두 가지 존재 큰 따옴표 표현 방법 var e = '작은 따옴표 안에 큰 따옴표 " 사용'; var f = "역슬래시를 활용하여 표현 \" 할수도 있음"; var f = '역슬래시를 활용하여 표현 \" 할수도 있음'; 작은 따옴표로 묶은 후 그 안에 큰 따옴표를 활용하는 방법과 역슬래시..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/be9Cms/btqETKyCbQN/d9e9UNgQdQgKkeOZKtEj71/img.png)
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Note that an empty string is also considered valid. Example 1: Input: "()" Output: true Example 2: Input: "()[]{}" Output: true Example 3: I..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/brLzUg/btqETnJahQE/qCClhS8SeT2ILN1uta64BK/img.png)
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose of this problem, we define empty string as valid palindrome. Example 1: Input: "A man, a plan, a canal: Panama" Output: true Example 2: Input: "race a car" Output: false Solution import re class Solution: def isPalindrome(self, s: str) -> bool: s = s.lower() text = ..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/6vOM3/btqERr56ruh/jk1OtbOLsFHck51oNXBDn0/img.png)
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. Solution from collections import Counter class Solution: def firstUniqChar(self, s: str) -> int: answer = -1 s = list(s) cnt_dict = Counter(s) i = 0 for word in s: if cnt_dict[word] == 1: answer = i break i = i + 1 re..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/DfNmM/btqEPeTZmX5/UWQ7bBJbOo14sGkumnoKZK/img.png)
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from nums2. Example: Input: nums1 = [1,2,3,0,0,0], m = 3 nums2 = [2,5,6], n = 3 Output: [1,2,2,3,5,6] Solut..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/eONbdq/btqEN96teEs/8jh5kHF0E5MOOoZRs1VBb1/img.png)
Given a non-empty array of integers, every element appears twice except for one. 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,1] Output: 1 Example 2: Input: [4,1,2,1,2] Output: 4 Solution from collections import Counter class Solution: def singleNumber(self, nums: List[int]) -> int: c..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bjcg5i/btqEP4IWrVG/iNIUxkqlHq7V4MiJjp4uGK/img.png)
Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”. Example: n = 15, Return: [ "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/Vamqa/btqENz3LAjY/k45k24csNJOKdny8amVEak/img.png)
Python으로 프로그래밍을 하다보면 가끔 아래와 같은 오류를 만나는 경우가 있습니다. SyntaxError: Non-ASCII character '\xeb' in file 위의 오류는 코드 내부에 한글 데이터가 포함 되어있을 경우 발생하는 문제입니다. 이걸 해결하기 위해서 코드에 있는 한글을 다 삭제하거나 영어로 번역하지 않아도 됩니다. 해결방법 #-*- coding:utf-8 -*- 해당 코드파일의 코드 맨 윗줄에 위의 코드를 추가해주고 다시 실행해보면 정상적으로 작동하는 것을 볼 수 있습니다! 읽어주셔서 감사합니다!
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/cbvZWx/btqEMwzutq3/TIZvMP5M93oVN17FSlB4K1/img.png)
Given an array of integers A, consider all non-empty subsequences of A. For any sequence S, let the width of S be the difference between the maximum and minimum element of S. Return the sum of the widths of all subsequences of A. As the answer may be very large, return the answer modulo 10^9 + 7. Example 1: Input: [2,1,3] Output: 6 Explanation: Subsequences are [1], [2], [3], [2,1], [2,3], [1,3]..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/b0PaQe/btqEK8TihBG/0oHAdwNqD2fh3G3BWkBDck/img.png)
We say that a string contains the word hackerrank if a subsequence of its characters spell the word hackerrank. For example, if string s = haacckkerrannkk it does contain hackerrank, but s = haacckkerannk does not. In the second case, the second r is missing. If we reorder the first string as hccaakkerrannkk, it no longer contains the subsequence due to ordering. More formally, let p[0], p[1], ...