Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <algorithm> // std::count
- #include <vector> // std::vector
- using namespace std;
- string ltrim(const string & );
- string rtrim(const string & );
- /*
- * Complete the 'findNumber' function below.
- *
- * The function is expected to return a STRING.
- * The function accepts following parameters:
- * 1. INTEGER_ARRAY arr
- * 2. INTEGER k
- */
- string findNumber(vector < int > arr, int k) {
- if (std::find(arr.begin(), arr.end(), k) != arr.end()) {
- cout << "YES " << endl;
- } else {
- cout << "NO " << endl;
- }
- }
- int main() {
- vector < int > inputArr;
- int n = 0;
- cin >> n;
- // n--;
- cin.ignore();
- while (n--) {
- int x;
- cin >> x;
- inputArr.push_back(x);
- }
- int k;
- cin >> k;
- findNumber(inputArr, k);
- return 0;
- }
- string ltrim(const string & str) {
- string s(str);
- s.erase(
- s.begin(),
- find_if(s.begin(), s.end(), not1(ptr_fun < int, int > (isspace)))
- );
- return s;
- }
- string rtrim(const string & str) {
- string s(str);
- s.erase(
- find_if(s.rbegin(), s.rend(), not1(ptr_fun < int, int > (isspace))).base(),
- s.end()
- );
- return s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement