Sequential search in an array P11725


Statement
 

pdf   zip   main.cc   main.c   main.java   main.py

html

Write a function that tells if the integer number x is present in the vector of integer numbers v.

In order to compare the efficiency of your solution against the efficiency of the solution of the Judge, start searching for x from the lowest positions.

Interface

C++
bool exists(int x, const vector<int>& v);
C
int exists(int x, const int v[], int vsize);
Java
public static boolean exists(int x, int[] v);
Python
exists(x, v) # returns bool
 
exists(x: int, v: list) -> bool

Observation You only need to submit the required procedure; your main program will be ignored.

Information
Author
Salvador Roura
Language
English
Translator
Carlos Molina
Original language
Catalan
Other languages
Catalan
Official solutions
C C++ Java Python
User solutions
C C++ Java Python