BaşlayınÜcretsiz Başlayın

Time complexity in contact management

In the contact management application you just implemented in the previous exercise, what was the time complexity of the findContact method?

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;
}

Bu egzersiz

Optimizing Code in Java

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

İnteraktif egzersizlerimizden biriyle teoriyi pratiğe dökün

Egzersizi başlat