I have a json array that has multiple missing numbers and is out of sequence. What is the best way to find which numbers are missing?
My First thought was to iterate through and construct a new temporary array in order (so if the first key is 50, it goes to arr[50]) and then find out which do not have a key. Unfortunately this seems extremely inefficient.
Update: Here's a bit of my json:
"groups": [
{
"group_id": "1",
"group_name": "AABYODAADAAAW6KAAA",
},
{
"group_id": "5",
"group_name": "AABYODAADAAAW6KAAB",
},
{
"group_id": "2",
"group_name": "AABYODAADAAAW6KAAC",
},
{
"group_id": "3",
"group_name": "AABYODAADAAAW6KAAAD",
},
{
"group_id": "6",
"group_name": "AABYODAADAAAW6KAAAE",
}
]
and I'm sorting group_id, but the array length is over 2,000.