알고리즘 - java

임지원·2024년 6월 13일

import

import java.util.*;

scanner

Scanner sc = new Scanner(System.in);
int n = sc.nextInt();

BufferReader

 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 String[] input = br.readLine().split(" ");

GCD 최대 공약수

public static long GCD(long a, long b){
	if(b == 0) return a;
    return GCD(b, a % b);
}

LCM 최소 공배수

private static int lcm(int a, int b) {
        return a * b / gcd(a, b);
    }

문자열 뒤집기

String str = "hello";
String reverse = new StringBuffer(str).reverse().toString();
// reverse = "olloeh"
profile
백엔드 새싹

0개의 댓글