Previous Next
0 / 15
Module DEMO-33-67DEMO-OOP-33

Linear Search Position

DEMO-OOP-33 โ€ข Object Oriented Programming

Browser-only practice

Problem Statement

Read five integers and a target value, then print the first index where the target appears, or -1 if it does not appear.

Input Format

Input is given as whitespace-separated tokens in this order:

  1. first value
  2. second value
  3. third value
  4. fourth value
  5. fifth value
  6. target value

Output Format

Print the exact report in this order:

  1. Index

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
3
8
2
9
1
9
Index: 3
Input: first value = 3, second value = 8, third value = 2, fourth value = 9, fifth value = 1, target value = 9.
Key calculation(s): values = {3, 8, 2, 9, 1} | index = -1 | "Index: " + index = "Index: 3".
Output:
Index: 3
Sample #2
Public sample
4
5
6
7
8
4
Index: 0
Input: first value = 4, second value = 5, third value = 6, fourth value = 7, fifth value = 8, target value = 4.
Key calculation(s): values = {4, 5, 6, 7, 8} | index = -1 | "Index: " + index = "Index: 0".
Output:
Index: 0

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings