See how a minor change to your commit message style can make you a better programmer.
Format: <type>(<scope>): <subject>
<scope>
is optional
function maxStockProfit(pricesArr) {
const Price = {
'buy': 0,
'sell': 0,
'change': true
};
Array.range = (start, stop, step=1) => {
let A = [start];
while(start+step <= stop){
A = [...A, start+=step];
}
return A;
}
function LinkedList(head = null, tail= null) {
this.head = head;
this.tail = (tail)? tail: head;
}
function ListNode(val, next=null, previous=null) {
this.val = val;
this.next = next;
this.previous = previous;
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
You may assume the two numbers do not contain any leading zero, except the number 0 itself.
/**
* Definition for singly-linked list.
* function ListNode(val) {
function twoSum(arr, target) {
return arr.reduce((pairs, val, indx, srcArr) => {
let remainder = target - val;
let indx2 = srcArr.indexOf(remainder);
return indx2 !== -1 ? [...pairs, [val, remainder]] : pairs;
}, []);
}
const numArray = [1, 6, 4, 5, 3, 3];
function caesarCipher(str, num) {
[...arr] = str.toLowerCase();
return arr.map((val,indx,input)=> {
if (val.match(/[^a-z]/gi)) return val.charCodeAt(0);
let code = input.join('').charCodeAt(indx) + num;
return ( 96 < code && code < 123) ? code :
(code >= 123) ? code - 26 : code + 26;
});
You are given an array of characters arr that consists of sequences of characters separated by space characters. Each space-delimited sequence of characters defines a word.
Implement a function reverseWords that reverses the order of the words in the array in the most efficient manner.
Explain your solution and analyze its time and space complexities.
/********************
** Write some code, that will flatten an array
** of arbitrarily nested arrays of integers
** into a flat array of integers.
** e.g. [[1,2,[3]],4] -> [1,2,3,4]
************************/
var answer = [];
[cparrish@localhost ~]$ homestead up | |
Bringing machine 'default' up with 'virtualbox' provider... | |
==> default: Checking if box 'laravel/homestead' is up to date... | |
==> default: Clearing any previously set forwarded ports... | |
==> default: Clearing any previously set network interfaces... | |
==> default: Preparing network interfaces based on configuration... | |
default: Adapter 1: nat | |
default: Adapter 2: hostonly | |
==> default: Forwarding ports... | |
default: 80 => 8000 (adapter 1) |