結果

問題 No.69 文字を自由に並び替え
ユーザー muston
提出日時 2016-06-01 09:21:15
言語 Java
(openjdk 23)
結果
AC  
実行時間 134 ms / 5,000 ms
コード長 739 bytes
コンパイル時間 3,499 ms
コンパイル使用メモリ 75,352 KB
実行使用メモリ 54,252 KB
最終ジャッジ日時 2024-12-14 06:16:23
合計ジャッジ時間 6,220 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;
/*No69*/
public class No69 {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		//文字列Aを入力
		char[] a = scan.next().toCharArray();
		//文字列Bを入力
		char[] b = scan.next().toCharArray();
		//配列を文字コードに変換
		int[] aCord = new int[a.length];
		int[] bCord = new int[b.length];
		for(int i=0;i<a.length;i++){
			 aCord[i] = (int)a[i];
			 bCord[i] = (int)b[i];
		}
		//AとBを並び替え
		Arrays.sort(aCord);
		Arrays.sort(bCord);
		//一文字ずつ比較して出力
		for(int i=0;i<aCord.length;i++){
			if(aCord[i]!=bCord[i]){
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}
0