Duplicate Numbers The following program can find out if an integer array contains duplicate numbers. Give the best-case and worst-case runtime complexity using Big-O notation.  public static boolean containsDuplicates (int[] array, int number) { int n = array.length; for (int i = 0; i < n; i++) {   for (int j = 0; j < n; j++) {     if (i !== j && array[i] === array[j]) {       return true;     }   } } return false; } public static void main ( String[] args ) { int[] randomNumbers = { 10, 2, 9, 15, 22 }; containsDuplicates(randomNumbers, 27); } 1: Best Case 2: Worst Case匹配题

A

O(n log n)

B

O(n^2)

C

O(1)

D

O(n)

登录即可查看完整答案

我们收录了全球超50000道真实原题与详细解析,现在登录,立即获得答案。

类似问题

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!