전체 글(118)
-
알고리즘 : 프로그래머스 : 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) { System.out.println("Hello World".length()); // 11 length() : 몇글자 인지 알려준다. System.out.println("fodfjdifdfhihdfeknkdkfnaksdfn".length()); // 29 System.out.println("Hello, [[[name]]]...bye".replace("[[[name]]]", "egoing")); // Hello, egoing...bye 라고 찍힘 [[[name]]] 안에 egoing을 넣어줌. } }
2022.01.17