Udemy: Master Coding Interview - Big O - #26

Run Settings
LanguageC#
Language Version
Run Command
using System; using System.Diagnostics; class MainClass { static string[] nemo = {"nemo"}; static string[] everyone = {"dory", "bruce", "marlin", "nemo", "gill", "bloat", "nigel", "squirt", "darla", "hank"}; static string[] large; static string[] larger; static string[] largest; static void Main() { large = new string[100]; Array.Fill(large, "nemo"); larger = new string[100000]; Array.Fill(larger, "nemo"); largest = new string[10000000]; Array.Fill(largest, "nemo"); MainClass.findNemo(nemo); MainClass.findNemo(everyone); MainClass.findNemo(large); MainClass.findNemo(larger); MainClass.findNemo(largest); } public static void findNemo(string[] array) { Stopwatch sw = new Stopwatch(); sw.Start(); for (int i = 0; i < array.Length; i++) { if (array[i] == "nemo") { //Console.WriteLine("Found NEMO!"); } } sw.Stop(); Console.WriteLine("Call to findNemo() took {0}", sw.Elapsed); } }
Editor Settings
Theme
Key bindings
Full width
Lines