The question goes like this:
Given two arrays, a & b (both with positive integers).
A special number is a number which a(i) == i (the value equals to the index).
How can you check if array b contains a value which is a special number of a.
For example: a = [9 9 3 9], b = [3 4 5]. Output will be 3. If b or a are empty, output is 0. If b contains several special number, only the smallest one will be shown.
This is what I have managed to do by far, can't progress from here..
a = input('Please enter the array a : ');
b = input('Please enter the array b : ');
indexedArray = 1:length(a);
c = a-indexedArray;
t = find(c==0);
p = find(t==b);
does not work.
BTW: Can only use these functions: . sort , isempty , all , any , find , sum , max , min , length. No loops or conditions! Allowed only to use an array. No matrix. Cannot use logical operators such as &, |
Thanks!
aandbvectors, or can they be higher-dimensional arrays (matrices, etc.?).