Added description and testdata

master
Christoph Prybila 5 years ago
parent 29d6e92a10
commit d6c639a323

@ -0,0 +1,26 @@
# 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`)

@ -1 +1 @@
rootProject.name = 'template'
rootProject.name = 'find-longest-distinct-subarray'

@ -0,0 +1,16 @@
a, 1
a b, 2
a a, 1
f s f e t w e n w e, 5
k i u w y x f l e c g, 11
b u e v l w u d t r a b q x a h x b y s y w w s k, 12
z d k g x p a f h b c p y r y o r y k k o n u t h, 11
m y b o m s d v i h s w f g a l o l a r n e e m f, 11
0 8 7 8 1 7 9 4 3 3 6 7 7 2 4 9 3 9 6 9 5 1 3 2 6, 6
2 6 2 1 3 2 5 5 5 2 5 6 0 7 8 8 4 9 6 9 2 4 3 2 1, 6
a o y u t a v u q s w y l y b u u n x x w d v r a x s q d n p b u c z w v z n u l r z p k c r d t z, 14
t n m t e l y v n p t p g n q i e y m b l j z g x j h t d n t d j m h w z l r n y d z v r w d u i s, 13
z c x z g g s d a a w p v c f e z o r k i x c c q u z s g y m x d p r q c r l u e b y s o v x r t g, 13
4 1 7 8 6 1 0 7 2 5 6 0 7 9 7 4 2 4 8 0 6 4 6 4 4 1 1 8 4 8 6 8 4 9 4 4 2 8 4 8 9 7 9 9 0 8 2 2 7 9, 7
1 9 6 7 9 2 6 0 5 5 5 9 2 0 1 2 0 6 6 4 5 8 7 8 4 1 5 8 3 9 4 9 9 1 9 1 4 6 0 5 8 2 5 5 1 1 8 2 8 9, 8
1 7 8 0 3 4 7 7 3 9 2 3 5 0 7 6 5 6 9 4 3 8 9 4 7 2 0 8 2 6 7 0 5 4 6 1 1 0 1 6 3 0 0 6 3 9 4 2 3 4, 7
1 a 1
1 a 1
2 a b 2
3 a a 1
4 f s f e t w e n w e 5
5 k i u w y x f l e c g 11
6 b u e v l w u d t r a b q x a h x b y s y w w s k 12
7 z d k g x p a f h b c p y r y o r y k k o n u t h 11
8 m y b o m s d v i h s w f g a l o l a r n e e m f 11
9 0 8 7 8 1 7 9 4 3 3 6 7 7 2 4 9 3 9 6 9 5 1 3 2 6 6
10 2 6 2 1 3 2 5 5 5 2 5 6 0 7 8 8 4 9 6 9 2 4 3 2 1 6
11 a o y u t a v u q s w y l y b u u n x x w d v r a x s q d n p b u c z w v z n u l r z p k c r d t z 14
12 t n m t e l y v n p t p g n q i e y m b l j z g x j h t d n t d j m h w z l r n y d z v r w d u i s 13
13 z c x z g g s d a a w p v c f e z o r k i x c c q u z s g y m x d p r q c r l u e b y s o v x r t g 13
14 4 1 7 8 6 1 0 7 2 5 6 0 7 9 7 4 2 4 8 0 6 4 6 4 4 1 1 8 4 8 6 8 4 9 4 4 2 8 4 8 9 7 9 9 0 8 2 2 7 9 7
15 1 9 6 7 9 2 6 0 5 5 5 9 2 0 1 2 0 6 6 4 5 8 7 8 4 1 5 8 3 9 4 9 9 1 9 1 4 6 0 5 8 2 5 5 1 1 8 2 8 9 8
16 1 7 8 0 3 4 7 7 3 9 2 3 5 0 7 6 5 6 9 4 3 8 9 4 7 2 0 8 2 6 7 0 5 4 6 1 1 0 1 6 3 0 0 6 3 9 4 2 3 4 7
Loading…
Cancel
Save