Java(30)
-
알고리즘 : 프로그래머스 : JAVA : 문자열 다루기 기본
class Solution { public boolean solution(String s) { boolean answer = true; // 길이가 4나 6이 아닌경우 => false if(s.length() != 4 && s.length() != 6) answer = false; for(int i=0; i false if(s.charAt(i) >= 'A') answer = false; return answer; } } 문자열 길이가 4, 6이 아닌 경우 -> false 문자열에서 문자가 있는 경우 -> false class Solution { public boolean solution(String s) { // 길이가 4 또는 6 이고, if(s.length() == 4 || s.length() == ..
2022.01.17 -
알고리즘 : 프로그래머스 : JAVA : 내적
class Solution { public int solution(int[] a, int[] b) { int answer = 0; for(int i=0; i
2022.01.17 -
알고리즘 : 프로그래머스 : JAVA : 나누어 떨어지는 숫자 배열
import java.util.*; class Solution { public int[] solution(int[] arr, int divisor) { int[] answer = {}; ArrayList a1 = new ArrayList(); for(int i = 0; i
2022.01.17 -
알고리즘 : 프로그래머스 : JAVA : 2016년
class Solution { public String solution(int a, int b) { int total = 0; String w[] = {"FRI", "SAT", "SUN", "MON", "TUE", "WED", "THU"}; // 2016년은 윤년이므로 2월은 29일로 설정 int m[] = {31, 29, 31, 30, 31, 30,31, 31, 30, 31, 30, 31}; for(int i =0;i
2022.01.17 -
알고리즘 : 프로그래머스 : JAVA : 문자열 내 p와 y의 개수
class Solution { boolean solution(String s) { //입력으로 주어지는 문자열 s에 대하여 boolean answer = true; int cnt = 0; char ch = ' '; //char : 하나의 문자를 저장하기 위한 자료형 for (int i = 0; i < s.length(); i++) { ch = s.charAt(i); //s가 가리키고 있는 문자열에서 i번째에 있는 문자를 char타입으로 변환한다는 의미. if(ch == 'p' || ch== 'P') cnt++; else if (ch == 'y' || ch == 'Y') cnt--; } if(cnt != 0) return false; return true; } } 입력으로 주어지는 문자열 s에 대하여 fo..
2022.01.17 -
생활코딩 : JAVA1 - 문자열의 표현
public class StringApp { public static void main(String[] args) { // Character VS String System.out.println("Hello World"); // String 문자열(Character들이 모여있는 것) System.out.println('H'); // Character 문자(한 단어만 가능) System.out.println("H"); //String System.out.println("Hello " + "World"); // World 앞에서 엔터를 치면 이렇게 자동으로 분리해주는 // 이클립스의 편리한 기능. //그런데 줄바꿈은 안된다. Hello World 라고 찍힘 // new line System.out.printl..
2022.01.17