Skip to content

Instantly share code, notes, and snippets.

View webpack.config.js
var path = require('path');
var webpack = require('webpack');
var BundleTracker = require('webpack-bundle-tracker');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
entry: [
'./app/index.js'
],
View webpack.config.js
var path = require('path');
var webpack = require('webpack');
var BundleTracker = require('webpack-bundle-tracker');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
entry: [
'./app/index.js'
],
View gist:15749b6ca734abafaf030f6794d27eff
def single_number1(arr):
if arr and type(arr) == 'list':
vals = {}
for i in arr:
if i in vals:
vals[i] += 1
else:
vals[i] = 1
for i in arr:
if arr[i] == 1:
View a.py
def single_number2(arr):
return reduce(lambda x,y: x ^ y, arr)
View longest_increasing_subsequence.py
def longest_increasing subsequece(arr):
if arr:
if len(arr) == 1:
return 1
else:
# memoization
p = [1 for i in range(len(arr))]
for i in range(1, len(arr)):
for j in range(i):
if arr[j] < arr[i]:
View binary_tree_inorder.py
def binary_tree_inorder(root):
res = []
if root:
helper(root, res)
return res
def helper(root, res):
if root:
helper(root.left, res)
res.appned(root.val)
View binary_tree_inorder_iterative.py
def binary_tree_inorder_iterative(root):
res = []
stack = []
while root or stack:
if root:
stack.append(root)
root = root.left
else:
node = stack.pop()
res.append(node.val)
View sorted_array_to_bst.py
def sortedArrayToBST(nums):
if nums:
mid = len(nums) / 2
node = TreeNode(nums[mid])
node.left = sortedArrayToBST(nums[:mid])
node.right = sortedArrayToBST(nums[mid + 1:])
return node