開始使用免費開始

聯絡人管理的時間複雜度

在你剛於前一個練習實作的聯絡人管理應用程式中,findContact 方法的時間複雜度是什麼?

public Contact findContact(String name) {
  // Complete loop to search through contacts
  for (Contact contact : contacts) {
    if (contact.getName().equals(name)) {
      // Return the match
      return contact;
    }
  }
  return null;
}

本練習屬於課程

Java 程式碼最佳化

檢視課程

動手互動練習

將理論付諸實踐,立即體驗我們的互動練習

開始練習