Driver Code
public static void main ( String [ ] args ) { int [ ] arr = { 2 , - 1 , 1 , 2 , 2 } ; int n = arr . length ; if ( isCycle ( arr , n ) == true ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }