- Just convert input array into a dictionary of elements.
- For each element in the dictionary, check if the next element exists, for ex: if dict contains key '2', check if there is a '3' in there

If yes, then find the length of that subsequence using sum of no of elements of each type

If not, proceed to next element - Return the max

Previously I had used Counter, this resulted in more time,

```
class Solution(object):
def findLHS(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
mp={}
for i in nums:
if i not in mp:
mp[i]=1
else: mp[i]+=1
ln=0;
for i in mp:
if mp.get(i+1):
ln=max(ln,mp[i]+mp[i+1])
return ln
```