Loading...

[swexpert] 1204. 최빈수 구하기 (python, java)

1. python 풀이 일단 개수를 반환해주는 Counter로 구했는데 arr.count(x)로 해서 찾아도 되었을 듯 하다 * 등장 개수가 같다면 더 큰 점수로 해줘야한다. 가장 큰 개수만을 구한다면 most_common을 쓰면 되는데 이 부분 때문에 for문을 한 번 더 돌아줬다 from collections import Counter t=int(input()) for _ in range(1,t+1): n=int(input()) arr=list(map(int,input().split())) counter=Counter(arr) max_cnt,letter=-1,-1 for x in counter: if counter[x]==max_cnt: if x>letter: letter=x if counter[x]..

[swexpert] 2047. 신문 헤드라인 (D1, python, java)

1. 파이썬 풀이 s=input() converted=[x.upper() for x in s] print(''.join(converted)) 2. 자바 풀이 import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String s=sc.next(); System.out.println(s.toUpperCase()); sc.close(); } }

[swexpert] 2046. 스탬프 찍기 (python, java, D1 )

1. 파이썬 풀이 n=int(input()) print(n*'#') 2. 자바 풀이 import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); String s=""; for (int i = 0; i < n; i++) { s+="#"; } System.out.println(s); sc.close(); } }

[swea] 2056. 연월일 달력 (python, java , D1)

문제풀이 언어를 파이썬으로 바꾼 이후로 쉬운 문제부터 다시 연습하고 있다 swea1, 2 부터 다 풀려고 한다 달력 일자 별로 배열에 담아 푸는 방법도 있는데 그게 더 나을 것 같다 1. python 풀이 t=int(input()) for i in range(t): print('#%s' %(i+1),end=' ') date=input() year=int(date[:4]) month=int(date[4:6]) dd=int(date[6:]) if month 12: print(-1) continue if month in [1,3,5,7,8,10,12]: if dd 31: print(-1) continue if month ==2: if dd28: print(-1) continue if month in [4,6,..