K

@kimjuha19

문자열 내 가장 긴 팰린드롬

Python
5 months ago
def longest_palindrome(s): if not s: return "" start, end = 0, 0 for i in range(len(s)): len1 = expand_around_center(s, i, i) len2 = expand_around_center(s, i, i + 1) max_len = max(len1, len2)

주차 요금 정산 시스템

Python
5 months ago
from datetime import datetime def parking_fee(entry_time, exit_time): start = datetime.strptime(entry_time, "%H:%M") end = datetime.strptime(exit_time, "%H:%M") elapsed_min = (end - start).total_seconds() // 60 elapsed_min = int(

가로세로 퍼즐 유효성 검사

Python
5 months ago
def is_valid_grid(grid): n = len(grid) for i in range(n): for j in range(n): if grid[i][j] != grid[0][j] and grid[i][j] != grid[i][0]: return True return False grid = [

자동 로봇 청소기 경로 기록

Python
5 months ago
def robot_move(n, commands): answer = [1, 1] for i in range(len(commands)): if commands[i] == "R" and answer[1] < n: answer[1] += 1 elif commands[i] == "L" and answer[1] > 1: answer[1] -= 1 el

택배 배송 비용 최적화

Python
5 months ago
def calculate_shipping_fee(weight, distance): answer = 3000 if weight > 5: answer += (weight - 5) * 500 if distance > 50: answer += ((distance - 50) // 10) * 200 if weight > 10 and distance > 100: answer = a

쇠막대기

Python
5 months ago
s = input().strip() stack = [] answer = 0 for i in range(len(s)): if s[i] == '(': stack.append('(') else: stack.pop()

격자판 회전

Python
5 months ago
arr = [ [1,2,3], [4,5,6], [7,8,9] ] n = len(arr) m = len(arr[0]) result = [[0] * n for i in range(m)]

대표값과 최빈값

Python
5 months ago
Nums = [10, 40, 30, 60, 30, 20, 60, 30, 40, 50] count = 0 ans = {} for i in range(len(Nums)): count += Nums[i] for i in Nums: if i in ans: ans[i] += 1

약수 구하기

Python
5 months ago
N = 6 K = 3 count = 0 divisors = [] for i in range(1, N + 1): if N % i == 0: divisors.append(i) if divisors[2] in divisors: print(divisors[2])

색종이 넓이

Python
5 months ago
Positions = [(3, 7), (15, 7), (5, 2)] ans = set() for x,y in Positions: for i in range(x,x+10): for j in range(y,y+10): ans.add((i,j)) print(len(ans))

달팽이의 우물 탈출

Python
5 months ago
A = 2 B = 1 V = 5 total = A - B count = 0 for i in range(1,V): V -= total count += 1

카드 역배치

Python
5 months ago
arr = list(range(1,21)) a,b = map(int,input().split()) start,end = a-1,b-1 arr[start:end+1] = arr[end:start-1:-1] print(arr)

단어 정렬

Python
5 months ago
data = "but, i, wont, hesitate, no, more, no" words = data.split(", ") unique_words = [] for w in words: if w not in unique_words: unique_words.append(w) word_sorted = sorted(unique_words, key=len)

동전

Python
5 months ago
coins = [1, 5, 10, 50, 100, 500] coins.sort(reverse=True) K = 4200 count = 0 for coin in coins: num = K // coin count += num K -= coin * num

회사에 있는 사람

Python
5 months ago
person = [ ["Baha", "enter"], ["Askar", "enter"], ["Baha", "leave"], ["Artem", "enter"] ] answer = [] for i in range(len(person)):

듣보잡

Python
5 months ago
nohear = ["ohhenrie", "charlie", "baesangwook"] nosee = ["obama", "baesangwook", "ohhenrie"] common = set(nohear).intersection(nosee) common_sorted = sorted(common) print(common_sorted)

최소공배수와 최대공약수

Python
5 months ago
def gcd(a, b): while b != 0: a, b = b, a % b return a A = 10 B = 5 g = gcd(A, B) l = (A * B)

상근이의 상수

Python
5 months ago
num = 734 reversed= str(num)[::-1] reversed = int(reversed) if num > reversed: print(num) else: print(reversed)

가장 긴 단어 찾기

Python
5 months ago
text = "Tough times never last, but tough people do" words = text.split() longest_word = max(words, key=len) print(longest_word,len(longest_word))

뒤집은 소수

Python
5 months ago
num = int(input()) reversed= str(num)[::-1] reversed = int(reversed) if num < 2: print("NO") else: for i in range(2, int(num ** 0.5) + 1): if num % i == 0: print("NO")