본문 바로가기

코딩9

코딩테스트 입문 - Day 18 문자열안에 문자열class Solution { public int solution(String str1, String str2) { if(str1.contains(str2)){ return 1; } return 2; }}제곱수 판별하기import java.util.*;class Solution { public int solution(int n) { int sq = (int)Math.sqrt(n); int pow = (int) Math.pow((double)sq,2.0); if(n == pow){ return 1; } return 2; }}세균 증.. 2025. 4. 27.
오목 구현해보기 Player.javapackage omok;import lombok.AllArgsConstructor;@AllArgsConstructorpublic class Player { String name; String stone;}Board.javapackage omok;public class Board { int size; String[][] map; // 보드 초기화 Board(int size) { this.size = size; map = new String[size][size]; for (int row = 0; row = 0 && dj = 0 && map[di][dj] == owner.stone) { count++; } } if (count == 5) { isOmok .. 2025. 4. 20.
코딩테스트 입문 - Day 10 점의 위치 구하기class Solution { public int solution(int[] dot) { if(dot[0] > 0 && dot[1] > 0){ return 1; }else if(dot[0] 0){ return 2; }else if(dot[0] 2차원으로 만들기class Solution { public int[][] solution(int[] num_list, int n) { int[][] answer = new int[num_list.length / n][n]; for (int i = 0; i 공 던지기class Solution { public int solution(int[] numbers.. 2025. 4. 20.
코딩테스트 입문 - Day 9 개미 군단class Solution { public int solution(int hp) { int sum = 0; for(int i = 5; i > 0; i -= 2){ sum += hp/i; hp %= i; } return sum; }}모스 부호 (1)import java.util.HashMap;class Solution { static String[] morse = { ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", .. 2025. 4. 20.
4/14 - 컬렉션 자료 구조, 람다 목차수정할 수 없는 컬렉션대부분 빠름읽기 전용요소를 추가, 삭제할 수 없음.of( )를 이용하여 만듬.copyOf( )를 이용하여 만들 수 있음람다식함수형 프로그래밍줄이기 (생략)인터페이스를 구현한 구현클래스 (메서드 재정의) 객체 생성 사용간략한 표현 방식함수를 정의하고 이 함수를 데이터 처리부로 보내 데이터를 처리하는 기법외부에서 제공된 함수에 의존인터페이스가 단 하나의 추상 메소드를 가질 때, 이를 함수형 인터페이스라고 한다.인터페이스가 함수형 인터페이스임을 보장하기 위해서는 @FunctionalInterface 어노테이션을 붙이면 된다.생략 가능한 경우반드시 추상메서드가 하나인 인터페이스만 가능(@Functional Interface)실행문이 하나일 때 생략 가능실행문이 return 하나일 때 생.. 2025. 4. 19.
프로그래머스 - 특수문자 출력하기 문제 설명다음과 같이 출력하도록 코드를 작성해 주세요.출력 예시!@#$%^&*(\\'"?:;코드import java.util.Scanner;public class Solution { public static void main(String[] args) { System.out.print("!@#$%^&*(\\\\'\\"?:;"); }} 2025. 4. 12.
728x90
반응형