This file contains 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
We can solve this in O(n2) time by sorting the array first. | |
1) Do square of every element in input array. This step takes O(n) time. | |
2) Sort the squared array in increasing order. This step takes O(nLogn) time. | |
3) To find a triplet (a, b, c) such that a = b + c, do following. | |
Fix ‘a’ as last element of sorted array. | |
Now search for pair (b, c) in subarray between first element and ‘a’. A pair (b, c) with given sum can be found in O(n) time using meet in middle algorithm discussed in method 1 of this post. |
This file contains 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
package com.interview.graph; | |
import java.util.HashSet; | |
import java.util.Set; | |
/** | |
* http://www.careercup.com/question?id=14942063 | |
*/ | |
public class Boggle { |
This file contains 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
package com.interview.algorithms.tree; | |
import java.io.BufferedReader; | |
import java.io.FileNotFoundException; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.util.ArrayList; | |
import java.util.HashSet; | |
import java.util.List; | |
import java.util.Set; |
This file contains 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 fs = require('fs'); | |
var csv = require("fast-csv"); | |
var stream = fs.createReadStream("data.csv"); | |
var csvStream = csv() | |
.on("data", function(data){ | |
console.log(data); | |
}) | |
.on("end", function(){ | |
console.log("done"); |
This file contains 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
nvm ls | |
nvm install 0.10.13 | |
nvm use 0.10.13 |
This file contains 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
pio template get whhone/template-sentiment-analysis senti | |
pio app new MyApp1 |
This file contains 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 Singleton = (function () { | |
var instance; | |
function createInstance() { | |
var object = new Object("I am the instance"); | |
return object; | |
} | |
return { | |
getInstance: function () { |
This file contains 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 pubnub = require("pubnub").init({ publish_key: "demo", subscribe_key: "demo" }); | |
var tessel = require("tessel"); | |
pubnub.subscribe({ channel: "tessel-light", message: function(m) { | |
tessel.led[1].toggle(); | |
}}); |
This file contains 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 seriesData = [ [{ x: 0, y: 40 }, { x: 1, y: 49 }, { x: 2, y: 17 }, { x: 3, y: 42 }] ]; | |
var graph = new Rickshaw.Graph( { | |
element: document.getElementById("chart"), | |
width: 940, | |
height: 250, | |
renderer: 'area', | |
stroke: true, | |
series: [ | |
{ | |
color: 'steelblue', |
This file contains 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
https://code.google.com/p/elements-of-programming-interviews/wiki/Programs |