rach rach - 1 month ago 17
Android Question

compare arrays of two different lengths

I am developing a program on Android that will compare the similarity of Gestures using Gesture Points. I have two arrays like this:

gest_1 = [120,333,453,564,234,531]
gest_2 = [222,432,11,234,223,344,534,523,432,234]


I know there is no way to dynamically resize either one of the arrays, so is there any way for me to compare both these gestures using these arrays and return the similarity?

Note that the data in the arrays are just randomly typed out.

Answer

You could try something like this:

  List similarities = new ArrayList();
  for(int i = 0; i < Math.max(gest_1.length, gest_2.length); i++){
    if (gest_1[i] == gest_2[i])
       similarities.add(gest_1[i];
  }
Comments