본문 바로가기

알고리즘 문제연습33

[프로그래머스] 신규아이디 추천 import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; class Solution { public String solution(String new_id) { String answer = ""; List availStr = new ArrayList(Arrays.asList("-", "_", ".")); String id = new_id.toLowerCase(); // 1단계 List eachList = new ArrayList(); for(int i=0; i { return Character.isLowerCase(each) || (Character.isDigit(each)).. 2023. 2. 13.
[프로그래머스] 키패드 누르기 import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; class Solution { public String solution(int[] numbers, String hand) { String answer = ""; int[] left = new int[]{1,4,7}; int[] right = new int[]{3,6,9}; int tempLeft = 10; int tempRight = 12; for (int i=0; i< numbers.length; i++) { if(numbers[i] == 0) numbers[i] = 11; } for (int num : number.. 2023. 2. 13.
[프로그래머스] 크레인 인형 뽑기 게임 import java.util.*; class Solution { public int solution(int[][] board, int[] moves) { int answer = 0; List list = new ArrayList(); for (int place: moves) { for(int i=0; i 1 && (list.get(list.size()-2) == pick)) { // list안에 2개 이상이면 비교 && 직전 인형 = 고른 인형 answer++; list.remove(list.size()-1); list.remove(list.size()-1); } break; } } } return answer * 2; } } 2023. 2. 13.
[프로그래머스] 실패율 import java.util.*; class Solution { public int[] solution(int N, int[] stages) { int[] answer = new int[N]; int stageNum = N; int[] player = new int[stageNum]; int[] fail = new int[stageNum]; Map map = new HashMap(); List answerList = new ArrayList(); for(int x=0; xinteger).toArray(); } } 2023. 2. 13.
[030] 더하기 빼기 번갈아가면서 출력 package AlgorithmEasy; import java.util.Scanner; public class Algorithm30 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("숫자를 입력하세요 >> "); int num = sc.nextInt(); for(int i = 1; i 2021. 6. 17.
[029] 음계 (백준 2920번) package AlgorithmEasy; import java.util.Arrays; import java.util.Scanner; public class Algorithm29 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] input = new int[8]; String result = ""; System.out.println("1부터 8까지의 수를 입력하세요 >> "); for(int i = 0; i < input.length; i++) { input[i] = sc.nextInt(); } //System.out.print(Arrays.toString(input)); Lable:for(int i =.. 2021. 6. 17.