목록문제 풀이 (103)
honey_pot
https://programmers.co.kr/learn/courses/30/lessons/87377 더보기 일반형 식에서의 교점 1234567891011121314151617181920212223242526272829303132333435363738394041from itertools import combinations def find_interaction(line1, line2): a,b,e = line1 c,d,f = line2 deno = a*d - b*c # 분모 if deno == 0: # 교점 없음 return # 통과 x = (b*f - e*d) / deno y = (e*c - a*f) / deno # 정수 좌표에만 별을 그리기 때문에 정수를 판별한다 if x == int(x) and y ..
문제 https://leetcode.com/problems/4sum/ 4Sum - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 풀이법 참고 https://leetcode.com/problems/4sum/discuss/2031134/Easy-Python-Solution 리트코드 문제풀이 책 3회독 하고 다른 문제들 푸는중 이 문제는 뭐야~? 당연히 DFS지~ 하고 DFS로 풀어봤지만 털렸습니다 디스커션 가니까 다들 투포인터로 풀더라 하지만 포인터가 4개면 투포인..
https://programmers.co.kr/learn/courses/30/lessons/17677 from collections import Counter def solution(str1, str2): answer = 0 str_1 = [] str_2 = [] # 알파벳만 소문자로 2글자씩 담기 for i in range(0,len(str1)): if len(str1[i:i+2]) >= 2: if str1[i:i+2].isalpha(): str_1.append(str1[i:i+2].lower()) for i in range(0,len(str2)): if len(str2[i:i+2]) >= 2: if str2[i:i+2].isalpha(): str_2.append(str2[i:i+2].lower()) ..
https://programmers.co.kr/learn/courses/30/lessons/42888 def solution(record): answer = [] dic = dict() codes = [] for rec in record: codes = list(rec.split(" ")) # 명령어, 아이디, (닉네임) if rec[0] != "L": dic[codes[1]] = codes[2] for rec in record: codes = list(rec.split(" ")) if codes[0] == "Enter": nick = dic[codes[1]] answer.append(nick+"님이 들어왔습니다.") if codes[0] == "Leave": nick = dic[codes[1]] ans..
보호되어 있는 글입니다.
보호되어 있는 글입니다.
https://programmers.co.kr/learn/courses/30/lessons/60057 def solution(s): answer = 5000000 for slicing in range(1, len(s)//2+2): res = '' # 결과를 담을 변수 cnt = 1 # 단위가 반복된 횟수 temp = s[:slicing] # 단위만큼 슬라이싱한 문자열을 담는다. for i in range(slicing, len(s)+slicing, slicing): # slicing부터 시작해서 slicing 만큼 더해서 len(s)+slicing(s 전체 길이)만큼 if temp == s[i:i+slicing]: cnt += 1 else: if cnt == 1: res += temp else: res ..
https://programmers.co.kr/learn/courses/30/lessons/42842 def solution(brown, yellow): # garo >= sero answer = [] # [garo, sero] whole = brown+yellow sero = 0 for garo in range(1,brown+1): if whole % garo == 0: # whole이 garo로 나뉘면 sero = whole // garo # sero는 whole // garo 가 됨 if garo >= sero and (garo-2)*(sero-2) == yellow: # garo >= sero, yellow가 직사각형이면 answer.append(garo) # answer에 담고 정지 answer..