Blog
-
1157_Python // 단어 공부 (실패)IT_Baekjoon 단계별로 풀어보기/문자열 2020. 1. 12. 23:28
Python import sys s = sys.stdin.readline().upper() c = 'A' for i in range(len(s)-1) : if(s.count(s[i]) > s.count(c) and c != "?") : c = s[i] elif(s.count(s[i]) == s.count(c) and s[i] != c) : c = "?" print(c) 이 코드는 아래 코드가 if문이 너무 많아서 그런가 해서 줄여본 코드입니다 하지만 두 코드 모두 시간초과가 뜨네요 import sys s = sys.stdin.readline().upper() c = 'a' for i in range(len(s)) : if(s.count(s[i]) >= s.count(c)) : if(s.count(s[i]..
-
10809_Python // 알파벳 찾기IT_Baekjoon 단계별로 풀어보기/문자열 2020. 1. 12. 01:18
Python import sys st = str(sys.stdin.readline()) alp = [-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1] for i in range(len(st)-1) : if(alp[int(ord(st[i])) - 97] == -1) : alp[int(ord(st[i])) - 97] = i for j in range(len(alp)) : print(alp[j],"",end = '') ===