#include<stdio.h>
int scrambled( unsigned int a[], unsigned int b[], unsigned int len )
{
int arr[100], n=100;
int same = 1;
// changes all values in arr to 0
for(int i=0; i<n; i++){
arr[i] = 0;
}
// records the frequency of numbers in arr
for(int i=0; i<len; i++){
arr[a[i]]++;
}
// runs b over arr
for(int i=0; i<len; i++){
arr[b[i]]--;
}
//checks array over for -1 values
for(int i=0; i<n; i++){
if(arr[i] <= -1){
same = 0;
}
}
return same;
}
No comments:
Post a Comment