언어_자바 프로그래머스_마지막 두 원소 public class LastTwo { public static void main(String[] args) { Test3 t = new Test3(); int[] num_list = {5, 2, 1, 7, 5}; t.test3(num_list); } } class Test3{ public int[] test3(int[] num_list) { int[] answer = new int[num_list.length +1]; // 새로운 배열을 생성한다. 중요한 점은 +1 하여 길이를 확장하는 것. int last = 0; if(num_list[num_list.length-1] > num_list[num_list.length-2] ){ last = num_list[nu..
알고리즘
![](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FllnZY%2FbtsCiwOTBDI%2FYxt97ZGmgXqvjmJHJzcAak%2Fimg.png)
백준 3단계_ 빠른 A + B 언어_ Java 생각 정리 1️⃣ 🙋♀️ 처음으로 제출한 답안은 바로 아래와 같다. 하지만 시간 초과… 입력 때 Scanner 대신에 BufferedRedaer로 받았지만 뭐가 문제일까 고민했다. 👩💻 입력 방법 ) BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { System.out.print("정수를 입력하세요: "); int num = Integer.parseInt(br.readLine()); System.out.println("입력한 정수: " + num); System.out.print("문자열을 입력하세요: "); String str = br..