{"ScriptPreparationCode":null,"TestCases":[{"Name":"sort","Code":"const dupearray1 = [1,8,4,5,9,3,7,4,6,2];\r\n\r\nlet sortResult = 0;\r\nfunction sortMethod(array){\r\n let prev = 0;\r\n array\r\n .sort()\r\n .forEach(element =\u003E{\r\n if(element === prev) {\r\n sortResult = element;\r\n }\r\n if (element !== prev){\r\n prev = element;\r\n } \r\n });\r\n}\r\nsortMethod(dupearray1);","IsDeferred":false},{"Name":"Set","Code":"const dupearray2 = [1,8,4,5,9,3,7,4,6,2];\r\n\r\nlet setResult = 0;\r\nfunction setMethod(array){\r\n let seen = new Set();\r\n return array.forEach(element =\u003E {\r\n if(!seen.has(element)){\r\n seen.add(element);\r\n } else{\r\n setResult = element;\r\n return setResult;\r\n }\r\n });\r\n}\r\nsetMethod(dupearray2);","IsDeferred":false},{"Name":"floyd","Code":"const dupearray3 = [1,8,4,5,9,3,7,4,6,2];\r\n\r\nlet floydResult = 0;\r\n\r\nfunction floyd(array){\r\n\r\n let tortoise = array[0];\r\n let hare = array[array[0]];\r\n\r\n while(hare !== tortoise){\r\n tortoise = array[tortoise];\r\n hare = array[array[hare]];\r\n }\r\n hare = 0;\r\n while (tortoise !== hare){\r\n tortoise = array[tortoise];\r\n hare = array[hare];\r\n }\r\n floydResult = tortoise;\r\n return tortoise;\r\n}\r\n\r\nfloyd(dupearray3);","IsDeferred":false}]}