async.each(arr, function(item,callback) {
},
function(err) {
//function code that is to be done after the 2nd
//argument of async.each is called on each element
### Core Features ### | |
- Log in | |
- Screen cast of what you can do (demo) for about page | |
- Live feed of open "battles" (___ & ___ are battling on ___ challenge). | |
- Panel? Github sign in, Google plus, twitter, other ?? | |
- Profile page | |
- Random challenge plus challenge specific user | |
- Can pick any challenge (grouped by easy, medium, hard) | |
- Leader board on challenge page of "top scores" (?) from users who have done the challenge | |
- Let users comment/rate other peoples code (maybe) |
Note: This example is for a binary tree but for graphs, you do a similar thing but need to keep track of which nodes you have visited (until you visit all of them) and also add all children to the queue, not just the left and right child. | |
Tree: | |
5 | |
/ \ | |
2 6 | |
/ \ / \ | |
1 3 4 7 | |
Add the root to the BFSArray (the results). Add its children to the queue. |
Level 1
Create a function called removeVowels() to remove all the vowels in a given string. Both uppercase and lowercase vowels should be removed. Your input will be a string and you should return the string without any vowels.
Level 2
Write a function that takes in a 2-D array that represents a square matrix and returns the product of the diagonal of the matrix. For example
[ [ 2, 3],
[ 4, 5] ]
will return 10 (2x5).
Level 3
The first approach that jumps to mind for most people is using a greedy algoirthm- picking the biggest coin possible and continuing to do this until you have the amount you are looking for.
This looks something like this:
function minCoins(coinArr, amt) {
var numCoins = 0;
while (amt !== 0) {
var eligibleCoins = coinArr.filter(function(coin) {
return coin <= amt;
});
Before you started coding, you should have tried to think about this problem visually. It would probably help to actually make a stack and then an empty helper stack and think about how you can move elements around until one of the stacks contains all the elements in sorted order.
Here is an explanation of how the solution works– this is just an explanation of the algorithm and contains no code (at one point the video says that 8 is smaller than 2 instead of 8 is bigger than 2 but the solution is still correct):
(click on the image to be taken to the video)
The general idea is that you always pop the top element of the stack which you are sorting. You want to add this to the helper stack but first need to make sure that doing so won't make the helper stack unsorted.
When all elements from the original stack are in the helper stack (i.e. the original stack is empty), you n
A dynamic programming approach to this problem is described below. This approach takes O(n*n) time since we are comparing the letters of a string using an n*n matrix (where n is the length of the longer string since empty characters are added to the shorter string).
A dynamic programming approach to this problem is described below. This approach takes O(n*n) time since we are comparing the letters of a string using an n*n matrix (where n is the length of the longer string since empty characters are added to the shorter string).
(click on the image to be taken to the video)
Now that we know how to think about this programming from a dynamic programming perspective, we can write some code to solve the problem. There are a few different approaches to this but generally they all have some things in common:
- you will have a 2-d array that represents the matrix which compares
One way of solving this problem is to do so recursively: -you can always pick a left parentheses as long as you haven't used up all of your left parentheses (i.e. if the # of left parentheses is less than n)
- you can pick a right parentheses if it does not make the combination invalid
- it will be invalid if there are more right parentheses than left
- if you keep track of how many left parentheses you currently have added, then you can determine whether or not you can add a right parentheses to the current combination
- when you have added n left parentheses and n right parentheses, you have a valid result and can add it to your results set
You can use the following recursive calls to mimic this.
First you call a function getCombinations(left,right,curr) with left = n, right =0, and curr='' because you have n left parentheses to add but can't add any right yet (it would make the combination invalid since right parentheses must come after a left) and your initial result is an empty stri
/* | |
This is a custom attribute directive I wrote. It was used for form validation to ensure that the name | |
entered in a form was not already in the database. It is an async custom validator. | |
*/ | |
'use strict'; | |
app.directive('sandwichnamevalidator', function(SandwichesFactory, $q){ | |
return { | |
require: 'ngModel', | |
restrict: '', |
// This is a state and the controller that corresponds to the state | |
'use strict'; | |
angular.module('learndotApp') | |
.config(function ($stateProvider) { | |
$stateProvider | |
.state('calendar', { | |
url: '/calendar', | |
controller: 'CalendarCtrl', |