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.
Lothar Buchholz d5ad7082a1 | 4 years ago | |
---|---|---|
.idea | 5 years ago | |
gradle/wrapper | 5 years ago | |
src | 4 years ago | |
.gitignore | 4 years ago | |
README.md | 5 years ago | |
build.gradle | 5 years ago | |
gradlew | 5 years ago | |
gradlew.bat | 5 years ago | |
settings.gradle | 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
)