Here you can find the source of longestCommonSubsequenceAlternate(int[] input)
Parameter | Description |
---|---|
input | a parameter |
public static int longestCommonSubsequenceAlternate(int[] input)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { /**// w ww. j a v a 2s .c om * * @param input * @return */ public static int longestCommonSubsequenceAlternate(int[] input) { Arrays.sort(input); int curCount = 1; int maxCount = 0; for (int i = 1; i < input.length; i++) { if (input[i] - input[i - 1] == 1) { curCount++; } else { curCount = 1; } if (curCount > maxCount) { maxCount = curCount; } } return maxCount; } }