Problem 838. Check if number exists in vector
50.58% Correct | 49.42% Incorrect
Last Solution submitted on Jun 08, 2023
Show 4 older comments
Richard Zapor on 17 Jul 2012
Add test vector a = -12;
b = [1,3,4,5,6,7,8,-12,2]; and rescore.
Better is add a=-randi(16); b= [1 2 3 a];
These will eliminate answers like #6.
frank mcnally on 15 Aug 2019
Tests allow incorrect solution to pass:
function y = existsInVector(a,b)
for i = 1:numel(b);
Jyothsna Chintala on 21 Apr 2020
Nicholas Bitler on 26 Nov 2020
that was fun, took me a couple minutes
Qingyin Zhang on 29 Nov 2020
y = sum(b == a);
Colin McNicholas on 13 Dec 2021
Not too bad
Hung Van Le on 24 Feb 2022
Solution CommentsShow comments
Problem Recent Solvers9294
"Low : High - Low : High - Turn around " -- Create a subindices vector
Duplicate each element of a vector.
Matlab Basics - Absolute Value
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!