일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
- react ag grid
- 자바 자동캐스팅
- 타입스크립트
- 자바 조건문
- TypeScript
- 프로그래머스
- MySQL
- java
- 자바 for문
- 항해99
- 자바 스캐너
- 자바 if문
- 자바 구구단 출력
- 자바 public
- 자바 switch문
- Til
- 자바 삼항연산자
- 자바 공배수
- 자바 강제 캐스팅
- 자바 반복문
- Vue3
- 자바 향상된 for문
- 항해99 2기
- react with typescript
- 변수
- 이클립스 DB연동
- 정보처리기사실기
- 자바
- 조코딩
- 자바 while문
- Today
- Total
목록알고리즘 (78)
뇌 채우기 공간

input = [3, 5, 6, 1, 2, 4] # 최댓값 찾기 def find_max_num(array): max_num = array[0] for num in array: if num>max_num: max_num = num return max_num result = find_max_num(input) print(result) 처음부터 for문을 돌면서 max_num보다 다음 숫자가 크면 max_num을 그 숫자로 바꾸는 로직이다.

처음에는 해시맵에 넣어서~~ 명칭으로 맵으로 만드는 방법도 헤매고~~ 그랬지만 이렇게 간단하게 풀 수 있었다.;; import java.util.HashMap; import java.util.Iterator; class Solution { public int solution(String[][] clothes) { int answer = 1; HashMap clothesmap = new HashMap(); for (int i = 0; i < clothes.length; i++) { String key = clothes[i][1]; if (!clothesmap.containsKey(key)) { clothesmap.put(key, 1); } else { clothesmap.put(key, clothesmap..

나의 풀이 class Solution { public boolean solution(String[] phone_book) { boolean answer = true; for (int i = 0; i < phone_book.length; i++) { for (int j = 0; j < phone_book.length; j++) { if (i==j) { continue; } if (phone_book[j].matches(phone_book[i]+"(.*)")) { answer=false; } } } return answer; } } 테스트 케이스는 통과했지만 효율성에서 모두 실패! matches대신 if(phone_book[j].indexOf(phone_book[i])==0) indexOf를 써도 케이스는 ..

import java.util.Arrays; import java.util.Comparator; public class solution { public String solution(int[] numbers) { String answer = ""; String[] str = new String[numbers.length]; for (int i = 0; i < numbers.length; i++) { str[i] = String.valueOf(numbers[i]); } Arrays.sort(str, new Comparator() { @Override public int compare(String a, String b) { return (b+a).compareTo(a+b); } }); if(str[0].equ..

1. 문제 길이가 예시보다 더어어어길게 주어지면 정답은 패턴을 가지고 반복한다. 2. 몇 개 맞았는지를 카운트 한다. 3. 개수가 가장 많은 인덱스를 출력하도록 하겠다. import java.util.*; public class solution { public int[] solution(int[] answers) { int[][] patterns = { {1,2,3,4,5}, {2,1,2,3,2,4,2,5}, {3,3,1,1,2,2,4,4,5,5} }; //순서대로 몇개 맞았는지 카운트 int[] hit = new int[3]; for (int i = 0; i < hit.length; i++) { for (int j = 0; j < answers.length; j++) { if (patterns[i][j..