Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement the below contains and subsequence methods. The contains method should

ID: 3862564 • Letter: I

Question

Implement the below contains and subsequence methods. The contains method should return true if the integer c appears in the array a[] and false otherwise; and the subsequence method should return true if the array b[] is a subsequence of the array a[] and false otherwise, where b[] is a subsequence of a[] if b[] can be derived from a[] by deleting some numbers from a[] without changing the order of the remaining numbers. public static Boolean contains(int a[], int c) {//TODO} public static Boolean subsequence(int a[], int b[]) {//TODO}

Explanation / Answer

package net.sf.javaml.distance.fastdtw.util;

import java.util.ArrayList;
import java.util.Collection;

public class Arrays
{

public Arrays()
{
}

public static int[] toPrimitiveArray(Integer objArr[])
{
int primArr[] = new int[objArr.length];
for(int x = 0; x < objArr.length; x++)
primArr[x] = objArr[x].intValue();

return primArr;
}