3 added 17 characters in body
source | link

Jelly, 4 bytes

ĠITL

Try it online!

...Or ĠIƇL

How?

ĠITL - Link: list of integers   e.g. [234, 2, 12, 234, 5, 10, 1000, 2, 99, 234]
Ġ    - group indices by value        [[2,8],5,6,3,9,[1,4,10],7]
 I   - incremental differences       [[6],[],[],[],[],[3,6],[]]
  T  - truthy indices                [1,6]
   L - length                        2

would filter to keep only truthy results of I ([[6],[3,6]]) which also has the desired length.

Jelly, 4 bytes

ĠITL

Try it online!

...Or ĠIƇL

Jelly, 4 bytes

ĠITL

Try it online!

...Or ĠIƇL

How?

ĠITL - Link: list of integers   e.g. [234, 2, 12, 234, 5, 10, 1000, 2, 99, 234]
Ġ    - group indices by value        [[2,8],5,6,3,9,[1,4,10],7]
 I   - incremental differences       [[6],[],[],[],[],[3,6],[]]
  T  - truthy indices                [1,6]
   L - length                        2

would filter to keep only truthy results of I ([[6],[3,6]]) which also has the desired length.

2 added 17 characters in body
source | link
1
source | link