This file contains 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
let sentence = "Hello World"; | |
function replaceChar(str,targetIndex,newChar){ | |
return str.substr(0,targetIndex) + newChar + str.substr(targetIndex + 1) | |
} | |
function stringReverser(str, startIndex, endIndex) { | |
if (!str || str.length < 2) { | |
return; | |
} |
This file contains 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
colors_needed = set(["blue", "yellow", "green", "orange", "purple", "white", "black", "pink"]) | |
boxes = {} | |
boxes["box_1"] = set(["orange", "purple", "white"]) | |
boxes["box_2"] = set(["yellow", "orange", "blue"]) | |
boxes["box_3"] = set(["green", "purple", "black"]) | |
boxes["box_4"] = set(["purple", "white"]) | |
boxes["box_5"] = set(["black", "pink"]) | |
final_boxes = set() |
This file contains 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
/* | |
Represent the following graph as an adjacency list. | |
write a dfs function that takes the adjacency list, a start node, and a target node. return true if it's in the graph, and false if it is not | |
A | |
/ \ | |
F B | |
/ / \ | |
G D C | |
/ | \ | |
This file contains 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
/* | |
1.Create an adjacency list to represent a graph of alphabetical letters as follows: | |
A | |
B C | |
D E H | |
F G | |
2. Write a function that takes a graph, a node (a letter) as a starting point, and lastly a node to search for. Return true if exists, and false if it does not | |
This file contains 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
// write a function that merges two unsorted arrays | |
function merge(leftArr,rightArr){ | |
let merged = []; | |
let i = 0; | |
let j = 0; | |
// while we are still inbounds for both arrays | |
while(i < leftArr.length && j < rightArr.length){ | |
if(leftArr[i] < rightArr[j]){ | |
merged.push(leftArr[i]); |
This file contains 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
# helpful logging statements | |
def binary_search(list,target): | |
lower_limit = 0; | |
upper_limit = len(list) - 1 | |
while(lower_limit <= upper_limit): | |
midpoint = (lower_limit + upper_limit) // 2 | |
midpoint_guess = list[midpoint] | |
print("Guess:", midpoint_guess,"\n") |
This file contains 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 TweetBox extends React.Component { | |
constructor(){ | |
super() | |
this.state = { | |
text: "", | |
photoAdded: false | |
}; | |
} | |
render() { |
This file contains 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
/* | |
If you know the four steps of delegate creation and usage, you know 90% of the steps | |
involved to create and call a multicast delegate. As a refresher, the four steps are: | |
1. Declare a delegate. | |
2. Instantiate the delegate. | |
3. Store an appropriate method in the delegate instance (anonymous method, named method, or lambda) | |
4. Call the delegate, passing the appropriate arguments. | |
A multi-cast delegate begins at step 2 above, and continues to steps 3 and 4 with two differences: | |
- Rather than storing a single method, you store a delegate. |
This file contains 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 numCount = (list) => { | |
return list.reduce((acc,current) =>{ | |
var numKey = current.toString(); | |
acc[numKey] === undefined ? acc[numKey] = 1 : acc[numKey] += 1; | |
return acc; | |
},{}); | |
}; |
NewerOlder