Quick actions

cmd+k|ctrl+k

Navigation

Languages

Udemy: Master Coding Interview - Big O - #28

Snippet info

Language

Csharp

Visibility

public

Author

jcurrie33

Created

2020-07-31T23:59:06Z

Updated

2020-08-01T00:07:27Z

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 int[] boxes = {0, 1, 2, 3, 4, 5};
    
    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); // O(n) --> Linear Time
        // MainClass.findNemo(everyone);
        // MainClass.findNemo(large);
        // MainClass.findNemo(larger);
        // MainClass.findNemo(largest);
        
        logFirstTwoBoxes(boxes); // O(2)
    }
    
    // public static void findNemo(string[] array) {

    //     for (int i = 0; i < array.Length; i++) {
    //         if (array[i] == "nemo") {
    //             Console.WriteLine("Found NEMO!");
    //         }
    //     }
    // }
    
    public static void logFirstTwoBoxes(int[] boxes) {
        Console.WriteLine(boxes[0]); // O(1)
        Console.WriteLine(boxes[1]); // O(1)
    }
}
INFO