This file contains hidden or 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 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' | |
], |
This file contains hidden or 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 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' | |
], |
This file contains hidden or 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
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: |
This file contains hidden or 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
def single_number2(arr): | |
return reduce(lambda x,y: x ^ y, arr) |
This file contains hidden or 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
def single_number2(arr): | |
return reduce(lambda x,y: x ^ y, arr) |
This file contains hidden or 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
def reverse_string(string): | |
return string[::-1] |
This file contains hidden or 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
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]: |
This file contains hidden or 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
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) |
This file contains hidden or 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
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) |
This file contains hidden or 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
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 | |