Java 로 풀어보는 알고리즘입니다. 📖
코딩테스트를 대비하여 JAVA1.8 부터 제공되는 함수형 API 는 사용하지 않았습니다.

문제 : https://www.algospot.com/judge/problem/read/MISPELL

 

algospot.com :: MISPELL

Mispelling 문제 정보 문제 Misspelling is an art form that students seem to excel at. Write a program that removes the nth character from an input string. 입력 The first line of input contains a single integer N, (1 ≤ N ≤ 1000) which is the numb

www.algospot.com

 

풀이입니다. 🤔

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int cases = scanner.nextInt();
        for (int i = 1; i <= cases; ++i) {
            int number = scanner.nextInt();
            String character = scanner.next();
 
            System.out.printf("%d ", i);
            for (int j = 0, size = character.length(); j < size; ++j) {
                if (j + 1 != number) System.out.print(character.charAt(j));
            }
            System.out.println();
        }
    }
}
cs

 

 

이 포스트를 읽어주셔서 감사합니다. 🙇🏻‍♂️

반응형

'개발이야기 > 알고스팟' 카테고리의 다른 글

[WORDLENGTH] 단어 길이 재기  (0) 2022.01.07
[MVP] Most Valuable Programmer  (0) 2022.01.07
[DIAMOND] 다이아몬드  (0) 2022.01.06
[ENCODING] Encoding  (0) 2022.01.06
[CANDLESTICK] Candlestick Charts  (0) 2022.01.06
Posted by N'