Quantcast
Channel: User Karthik T - Stack Overflow
Viewing all articles
Browse latest Browse all 42

Answer by Karthik T for Write the definition of a function, isReverse

$
0
0

The return value is wrong because you are checking only 1 value from each array, not all of them. What you want to do is something like this.

for (i=0;i<size;i++){    if(!(array1[i] == array2[size-i-1]))        return 0;}return 1;

Basically you go through the array one by one, if any of the values are not the same as the appropriate value on the other array, it is not a reverse, so we return 0. If we get out of the for loop without going through the if, it means they are reverses so we return 1.


Viewing all articles
Browse latest Browse all 42

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>