- Two Sum ===========
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution.
// Input:
var ints = [5, 4, 3, 7, 1]
" Only open nerdtree if no file was specified on startup | |
function! StartUpNerdtree() | |
if 0 == argc() | |
NERDTree | |
end | |
endfunction | |
autocmd VimEnter * call StartUpNerdtree() |
<a data-toggle="modal" href="#myModal" class="btn btn-primary">Launch modal</a> | |
<div class="modal" id="myModal"> | |
<div class="modal-dialog"> | |
<div class="modal-content"> | |
<div class="modal-header"> | |
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> | |
<h4 class="modal-title">Login</h4> | |
</div> | |
<div class="modal-body"> |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-6 col-sm-4 col-md-3"> | |
<div id="wrap" class="text-center"> | |
<div class="thumbnail2"> | |
<div class="thumbnail"> | |
<a href="#myModal"> | |
<div class="caption"> | |
<!-- <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal"> --> | |
<!-- BEGIN MODAL HERE --> |
<?php | |
# Display errors in production mode | |
ini_set('display_errors', '0'); | |
error_reporting(E_ALL & E_ERROR); | |
ini_set('display_errors', 1); | |
?> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> ... |
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution.
// Input:
var ints = [5, 4, 3, 7, 1]
import React, { Component } from 'react' | |
import { connect } from 'react-redux' | |
import { getData, signup } from './actions' | |
@connect(state => ({ | |
user: state.user // <- this is an example of how you grab the global state in your components | |
}), dispatch => ({ | |
signup: (username, password) => dispatch(signup(username, password)) // <- you can either do it LIKE THIS |
function includesAll (string, ...values) { | |
return values.every(el => string.includes(el)) | |
} | |
function replaceAll (originalString, string2replace, replaceWith) { | |
return originalString.split(string2replace).join(replaceWith) | |
} |
String.fromCharCode(...Array(123).keys()).slice(97).split('') |
// Option 1: [0, ...., N] | |
var array = length => Array.from({ length }, (_, i) => i) | |
// Option 2: [0, ...., N] | |
var array = to => Array.from(Array(to), (_, i) => i) | |
// Option 3: [1, ....., N] | |
var array = length => Array.from({ length }, (_, i) => i + 1) |
var closest = (nums, goal) => nums.reduce((prv, cur) => ( | |
Math.abs(prv - goal) > Math.abs(cur - goal) ? cur : prv | |
)) | |
closest([-1, 2, 1, -4], 3) // should return 2 |