Skip to content

Instantly share code, notes, and snippets.

@gabrieledarrigo
Last active March 4, 2018 12:54
Show Gist options
  • Save gabrieledarrigo/7f94a6bd9728a7d795b9983b4e83a75f to your computer and use it in GitHub Desktop.
Save gabrieledarrigo/7f94a6bd9728a7d795b9983b4e83a75f to your computer and use it in GitHub Desktop.
Linear search exercises

Write a program that takes input of integers N and M, followed by N more integers and then M more integers. For each of the last M numbers, the program outputs true, if that number was present in the array of N numbers, output False otherwise

Constraints: 0 < N < 20,000

0<M<15,000

Your output lines should not have any trailing or leading whitespaces

Input 4 2 99 12 10 23 23 25

Output True False

Explanation: An input of size 4 is taken, followed by 2 lines. 23 outputs True, since 23 is present in above array, 25 outputs false because it was not in the array of N integers.

Executing For Testcase: 4 2 99 12 10 23 23 25 Expected Output: True False Output: 4 2 Outputs Don't Match! Executing For Testcase: 30 9 146 157 150 172 104 106 148 151 169 114 178 134 165 127 139 177 192 172 132 123 124 121 131 101 189 102 161 112 184 115 177 131 205 999 151 222 169 20 139 Expected Output: True True False False True False True False True Output: 30 9 Outputs Don't Match!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment