You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Christoph Prybila d6c639a323 Added description and testdata 5 years ago
.idea Initial commit 5 years ago
gradle/wrapper Initial commit 5 years ago
src Added description and testdata 5 years ago
.gitignore Initial commit 5 years ago
README.md Added description and testdata 5 years ago
build.gradle Initial commit 5 years ago
gradlew Initial commit 5 years ago
gradlew.bat Initial commit 5 years ago
settings.gradle Added description and testdata 5 years ago

README.md

Find Longest Distinct Sub-Arrray

Goal

Given an array, find and return the length of the longest sub-array with the property that all its elements are distinct.

Hint: simple solutions may perform in time complexity O(n^3) or O(n^2) but solutions in O(n) are possible.

Input

A blank-separated array arbitrary symbols.

Output

The length of the longest distinct sub-array

Constraints

  • 1 <= array-length <= 50

Example

Input: f s f e t w e n w e

Output: 5

(the longest distinct sub-array is s f e t w)