목록분류 전체보기 (150)
코딩응급실
class Solution { public String solution(int[] numbers, String hand) { String answer = ""; /* 1 2 3 4 5 6 7 8 9 * 0 # */ // 좌표 개념임 int left =10; // * = 10번째자리 int right =12; // # = 12번째자리 // thumb: 엄지손가락 for(int thumb: numbers){ // 1, 4, 7을 이용하면 왼손 if(thumb==1||thumb==4||thumb==7){ answer+="L"; left = thumb; // 3, 6, 9를 이용하면 오른손 }else if(thumb==3||thumb==6||thumb==9){ answer+="R"; right = thumb; ..
class Solution { public String solution(String new_id) { // 1단계:대문자 'B'와 'T'가 소문자 'b'와 't'로 String answer = new_id.toLowerCase(); // 2단계: '!', '@', '#', '*' 문자가 제거 answer = answer.replaceAll("[^-_.a-z0-9]", ""); // 3단계: '...'와 '..' 가 '.'로 answer = answer.replaceAll("[.]{2,}", "."); // 4단계: 아이디의 처음에 위치한 '.'가 제거 answer = answer.replaceAll("^[.]|[.]$", ""); // 5단계: 아이디가 빈 문자열이 아니므로 변화가 없음 if (answe..
import java.util.HashSet; public class Solution { public int[] solution(int[] lottos, int[] win_nums) { HashSet winNumSet = new HashSet(); for (int num : win_nums) { winNumSet.add(num); } int matchCount = 0; int zeroCount = 0; for (int num : lottos) { if (num == 0) { zeroCount++; } else if (winNumSet.contains(num)) { matchCount++; } } int max, min; //최고순위, 최저 순위 int val = matchCount + zeroCount;..
class Solution { public int solution(int[] a, int[] b) { int answer = 0; for (int x=0; x
class Solution { public int solution(int[] absolutes, boolean[] signs) { int answer = 0; for (int x=0; x
class Solution { public int solution(int left, int right) { int answer = 0; for (int x=left; x
class Solution { public int solution(String s) { String[] arr = {"zero","one","two","three","four","five","six","seven","eight","nine"}; for(int i=0;i
class Solution { public long solution(int price, int money, int count) { long answer = -1; for (int x=1; x money) { return answer - money; } else { return 0; } } public static void main(String[] args) { int price = 3, money = 20, count = 4; Solution sol = new Solution(); long result = sol.solution(price, money, count); System.out.println(result); } }