結果

問題 No.69 文字を自由に並び替え
ユーザー GchansanjouGchansanjou
提出日時 2018-02-12 00:43:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 42 ms / 5,000 ms
コード長 1,149 bytes
コンパイル時間 3,163 ms
コンパイル使用メモリ 75,492 KB
実行使用メモリ 49,436 KB
最終ジャッジ日時 2023-08-20 23:58:33
合計ジャッジ時間 4,550 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
49,436 KB
testcase_01 AC 40 ms
49,304 KB
testcase_02 AC 41 ms
49,304 KB
testcase_03 AC 41 ms
49,288 KB
testcase_04 AC 41 ms
49,276 KB
testcase_05 AC 42 ms
49,312 KB
testcase_06 AC 40 ms
49,280 KB
testcase_07 AC 42 ms
49,392 KB
testcase_08 AC 42 ms
49,340 KB
testcase_09 AC 41 ms
49,304 KB
testcase_10 AC 41 ms
49,428 KB
testcase_11 AC 41 ms
49,328 KB
testcase_12 AC 40 ms
49,276 KB
testcase_13 AC 40 ms
49,316 KB
testcase_14 AC 40 ms
49,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukiCoder;

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

public class No00069 {

	public static void main(String[] args) {
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

		try {
			String input1 = bufferedReader.readLine();
			String input2 = bufferedReader.readLine();

			System.out.println(isEqual(input1, input2) ? "YES" : "NO");

		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static Boolean isEqual(String input1 , String input2) {
		String[] indexArray = new String[input1.length()];
		for(int i = 0 ; i < input2.length() ; i++) {
			String input2Digit = String.valueOf(input2.charAt(i));
			for(int j = 0 ; j < input1.length() ; j++) {
				String input1Digit = String.valueOf(input1.charAt(j));
				if(indexArray[j] == null && input1Digit.equals(input2Digit)) {
					indexArray[j] = input1Digit;
					break;
				}
			}
		}
		StringBuilder builder = new StringBuilder();
		for (int i = 0 ; i < indexArray.length ; i++) {
			builder.append(indexArray[i]);
		}
		return input1.equals(builder.toString()) ? true : false;
	}
}
0