내가 까먹을까봐 만든 블로그

전체 글

Coding Test

[Python] 백준 31562 - 전주 듣고 노래 맞히기

문제https://www.acmicpc.net/problem/31562 해설문자열 파싱과 해시 사용이 핵심이었다. Solution 1.해시를 이용한 기본적인 방식으로 풀어보았다. def solution(songs, trial): song_dict = {song[0]: song[1] for song in songs} for t in trial: cnt = 0 matched_song = "" for k, v in song_dict.items(): if v.startswith(t): matched_song = k cnt = cnt + 1 if cnt > 1: ..

Coding Test

[Python] 백준 27160 - 할리갈리

문제https://www.acmicpc.net/problem/27160 해설해시 사용이 핵심이었다. def solution(cards): game_dict = dict() for card in cards: card_val = card.split(" ") if game_dict.keys().__contains__(card_val[0]): game_dict[card_val[0]] = int(game_dict[card_val[0]]) + int(card_val[1]) else: game_dict[card_val[0]] = int(card_val[1]) for v in game_dict.values(): i..

Coding Test

[Python] 백준 29701- 모스 부호

문제https://www.acmicpc.net/problem/29701 해설해시 사용이 핵심이었다. morse_code_dict = { '.-': 'A', '-...': 'B', '-.-.': 'C', '-..': 'D', '.': 'E', '..-.': 'F', '--.': 'G', '....': 'H', '..': 'I', '.---': 'J', '-.-': 'K', '.-..': 'L', '--': 'M', '-.': 'N', '---': 'O', '.--.': 'P', '--.-': 'Q', '.-.': 'R', '...': 'S', '-': 'T', '..-': 'U', '...-': 'V', '.--': 'W', '-..-': 'X', '-.--': 'Y', '--..':..

Coding Test

[Python] 프로그래머스 - 숫자 문자열과 영단어

문제https://school.programmers.co.kr/learn/courses/30/lessons/81301 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 해설Solution 1.해시를 이용하여 풀어보았다. hash_dict = { "zero": "0", "one": "1", "two": "2", "three": "3", "four": "4", "five": "5", "six": "6", "seven": "7", "eight": "8", "nine": "9",}def solution(s): answer = s for k, v in..

Coding Test

[Python] 프로그래머스 - 문자열 나누기

문제https://school.programmers.co.kr/learn/courses/30/lessons/140108 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 해설def solution(s): answer = [] reset = True for c in s: if reset: answer.append(c) matched = 0 unmatched = 0 reset = False if c == answer[-1]: matched = matched + 1 ..

Coding Test

[Python] 프로그래머스 - 크기가 작은 부분 문자열

문제https://school.programmers.co.kr/learn/courses/30/lessons/147355 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 해설슬라이딩 윈도우 사용이 핵심이었다. def solution(t, p): cnt = 0 for i in range(len(t) - (p_len := len(p)) + 1): if int(t[i: i + p_len])

AlienCoder
외부 저장소
loading