Find Duplicate

Find the first duplicate element that appears in an array using a hash set for efficient lookup.

Code

Algorithms
echo "$arr" | jq 'group_by(.) | map(select(length > 1)) | .[0][0] // null'

Parameters

Array to check (JSON)

Server

More Bash Snippets