Search Indexes in Array


Submit solution

Points: 20 (partial)
Time limit: 1.0s
Memory limit: 64M

Authors:
Problem type
Allowed languages
Java 19, Java 8

輸入一個數字 n 代表陣列長度,接著輸入 n 個正整數,分別存入陣列中。

接著再輸入一個整數 X,請輸出 X 在陣列中所有出現的位置(索引)。

若 X 不存在陣列中,則輸出 -1

輸入

第一行輸入一個整數 n,和 n 個以空白分隔的正整數。 第二行輸入一個整數 X。

輸出

輸出整數 X 在陣列中所有出現的索引位置(以空白分隔)。 若沒有找到,輸出 -1。

sample input1

5 3 7 2 3 9
3

sample output1

0 3

sample input2

6 2 4 6 3 2 4
1

sample output2

-1

Comments

There are no comments at the moment.