In the sorted array by comparing adjacent elements we can easily get the non-repeating elements. First calculate the XOR of all the array elements. これは、詳細で元の投稿訪問用の Sunny Bahree How To Get Unique Items Or Values From Multidimensional Array Or An Object Jquery のスニペット画像です。 ここに But if n is much smaller than range then first approach is better as it doesnt require extra space for hashing. Find distinct elements in array jquery . If the given array has almost elements of range ie n is close to value of high-low1 then second and third approaches are definitely better as there is no Log n factor. Time complexity of this method is OnLogn Method 2Use XOR Let x and y be the non-repeating elements we are looking for and arr be the input array. First sort all the elements. We can also modify first approach to print adjacent missing elements as range to save time.