コーディングに関する質問が必要です。私は答えを見つけることにいくつかのヒントを望んでいますが、答え自体はありません。整数は繰り返さないので、この3112非繰り返し整数を数える
サンプル出力が2であるよう
サンプル入力が見えます。
は、ここでは、コード
public static int lonelyInteger(int[] arr)
{
need to code this
}
public static void main(String[] args) throws IOException
{
Scanner in = new Scanner(System.in);
final String fileName = System.getenv("OUTPUT_PATH");
BufferedWriter bw = new BufferedWriter(new FileWriter(fileName));
int res;
int _arr_size = Integer.parseInt(in.nextLine());
int[] _arr = new int[_arr_size];
int _arr_item;
for(int _arr_i = 0; _arr_i < _arr_size; _arr_i++)
{
_arr_item = Integer.parseInt(in.nextLine());
_arr[_arr_i] = _arr_item;
}
res = loneyInteger(_arr);
bw.write(String.valueOf(res));
bw.newLine();
bw.close();
}
は、あなたがより多くのサンプルテストケースを与えることができますか?あなたが与えたものは私にとって意味をなさない。私はあなたが2を持っているかどうか分かりません。 – 4castle
@ 4castle自分自身(3と2)を繰り返さない2つの異なる整数があります。 – Gendarme
概要のみ:各桁まで繰り返します。各桁について、その番号内で再び発生するかどうかを確認します。そうでない場合は、インデックスカウンタに1を加えます。 – Dando18