This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
int[] nums = new int[] {1,1,1,2,2,3}; | |
Dictionary<string,int> numCount = new Dictionary<string,int>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
We begin with a situation: | |
- We want code elsewhere to run when something occurs at a particular point in | |
our application. The class that contains this will be the publisher of the event. | |
Notice I am not using the word "event" to avoid confusion. | |
- In this case, it is the printing of a string, which we see occurs in the PrintString() method. For some reason, | |
we give a shit about this. | |
1. Declare a delegate. This is the contract between the publisher and subscriber(s). It's saying "Any and all methods- which we |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Find the only element in an array that only occurs once. | |
// create an object storing the keys as the numbers, and the values as the occurrence | |
// find the key that has a value of 1, and return that key | |
let list = [1,1,2,2,3,3,4,5,5,6,6]; | |
let uniqueNum = (nums) =>{ | |
let numObj = numCount(nums); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public delegate void SimpleDelegate(int a,int b); | |
class Class1 | |
{ | |
// two methods handlers with the same signature as the delegate | |
static void product(int i,int j) | |
{ | |
Console.WriteLine(i*j); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
/* | |
Declare the delegate. In this case, double is the return type that the handler | |
must also mirror. The name of the delegate, SimpleDelegate, will be used to | |
strongly type the variable that will hold the instance of the delegate. It will be of type SimpleDelegate, NOT double. | |
*/ | |
public delegate double SimpleDelegate(int a,int b); | |
class Class1 | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nodeNotVisited = (list,item) => { | |
if (list.indexOf(item) === -1) { | |
return true; | |
} | |
return false; | |
}; | |
A | |
/ \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node{ | |
constructor(value,children=[]){ | |
this.value = value; | |
this.children = children; | |
this.visited = false; | |
} | |
} | |
var node10 = new Node(10); | |
var node9 = new Node(9); | |
var node8 = new Node(8, [node9]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Queue { | |
constructor() { | |
this.items = []; | |
} | |
enq(obj) { | |
this.items.push(obj); | |
} | |
deq() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Queue { | |
constructor() { | |
this.items = []; | |
} | |
enq(obj) { | |
this.items.push(obj); | |
} | |
deq() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Queue { | |
constructor() { | |
this.items = []; | |
} | |
enq(obj) { | |
this.items.push(obj); | |
} |