結果

問題 No.69 文字を自由に並び替え
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-09-18 23:02:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 39 ms / 5,000 ms
コード長 770 bytes
コンパイル時間 3,864 ms
コンパイル使用メモリ 71,512 KB
実行使用メモリ 33,736 KB
最終ジャッジ日時 2023-08-20 23:49:10
合計ジャッジ時間 5,336 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
33,480 KB
testcase_01 AC 37 ms
33,436 KB
testcase_02 AC 37 ms
33,484 KB
testcase_03 AC 37 ms
33,540 KB
testcase_04 AC 37 ms
33,380 KB
testcase_05 AC 38 ms
33,408 KB
testcase_06 AC 38 ms
33,488 KB
testcase_07 AC 37 ms
33,296 KB
testcase_08 AC 39 ms
33,480 KB
testcase_09 AC 39 ms
33,392 KB
testcase_10 AC 38 ms
33,588 KB
testcase_11 AC 39 ms
33,488 KB
testcase_12 AC 38 ms
33,736 KB
testcase_13 AC 38 ms
33,472 KB
testcase_14 AC 38 ms
33,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class No69 {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] chrA = br.readLine().toCharArray(); //一文字ずつ分割して配列に入れる
		char[] chrB = br.readLine().toCharArray();
		Arrays.sort(chrA); //アルファベットをソートする
		Arrays.sort(chrB);
		
		int count = 0;
		for (int i = 0; i < chrA.length; i++){
			if(Arrays.equals(chrA, chrB)) count++; //配列の一致確認はArrays.equals(x,y)
		}
		    if (count == chrA.length) System.out.println("YES"); //全部一致ならYES
			else System.out.println("NO");
	}
}
0