Skip to content

Instantly share code, notes, and snippets.

@Titory0
Last active January 16, 2023 16:42
Show Gist options
  • Select an option

  • Save Titory0/e52a5f7b7066bc05f1555f8e43e5c860 to your computer and use it in GitHub Desktop.

Select an option

Save Titory0/e52a5f7b7066bc05f1555f8e43e5c860 to your computer and use it in GitHub Desktop.
public static int prototype(int[] list)
{
int indexsec=list.Length+1;
for(int i=0;i<list.Length;i++ )
{
for(int y=i;y<list.Length;y++ )
{
if(list[i] == list[y] && i!=y)
{
if(y<indexsec)
{
indexsec=y;
}
}
}
}
if (indexsec!=list.Length+1)
{
return list[indexsec];
}
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment