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
| Assumptions: | |
| - Sublime has been installed under Applications/ and that the application subl exists at /Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl | |
| - /usr/loca/bin is in your PATH. You can verify this by viewing the contents of your path by running 'cat /etc/paths' | |
| Run 'sudo ln -s "/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl' | |
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
| /** | |
| * Created by daniel robertson on 9/6/15. | |
| */ | |
| import java.io.*; | |
| import java.util.*; | |
| import java.lang.StringBuffer; | |
| public class NumberOfPalindromicSubstrings { | |
| static int palindrome(String str) { | |
| int result = 0; |
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
| boolean isPalindrome(String s) { | |
| for(int front = 0, end = s.length() - 1; front <= end; front++, end--) { | |
| if(s.charAt(front) != s.charAt(end)) { | |
| return false; | |
| } | |
| } | |
| return true; | |
| } |
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
| /** | |
| * Definition for a binary tree node. | |
| * public class TreeNode { | |
| * int val; | |
| * TreeNode left; | |
| * TreeNode right; | |
| * TreeNode(int x) { val = x; } | |
| * } | |
| */ | |
| public int maxDepth(TreeNode root) { |
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 isRotation = function(s1, s2) { | |
| return (s1.length === s2.length) && ((s1 + s1).indexOf(s2) !== -1); | |
| }; | |
| s1 = "stackoverflow" | |
| s2 = "tackoverflows" | |
| s3 = "ackoverflowst" | |
| s4 = "overflowstack" | |
| s5 = "ovegflgwsgacg" |
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
| int getEditDistance(String a, String b) { | |
| int[][] distances = new int[a.length()][b.length()]; | |
| for(int i = 0; i < distances.length; i++) { | |
| distances[i][0] = i; | |
| } | |
| for(int j = 0; j < distances[0].length; j++) { | |
| distances[0][j] = j; | |
| } |
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 http = require('http'); | |
| var url = process.argv[2]; | |
| http.get(url, function (response) { | |
| response.setEncoding('utf8'); | |
| response.on('error', console.error); | |
| var allCharacters = ''; | |
| response.on('data', function (data) { | |
| allCharacters += data; |
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 net = require('net'); | |
| var port = process.argv[2]; | |
| var strftime = require('strftime'); | |
| var server = net.createServer(function (socket) { | |
| var timestamp = strftime('%F %H:%M', new Date()); | |
| console.log(timestamp); | |
| socket.write(timestamp); | |
| socket.end(); | |
| }); |
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 http = require('http'); | |
| var map = require('through2-map'); | |
| var port = process.argv[2]; | |
| var server = http.createServer(function (request, response) { | |
| if (request.method = 'POST') { | |
| request.pipe(map(function (chunk) { | |
| return chunk.toString().toUpperCase(); | |
| })).pipe(response); | |
| } |
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 http = require('http'); | |
| var url = require('url'); | |
| var port = process.argv[2]; | |
| http.createServer(function (request, response) { | |
| urlInfo = url.parse(request.url, true); | |
| iso = urlInfo.query['iso']; | |
| response.writeHead(200, {'Content-Type': 'application/json'}); | |
| if (urlInfo.pathname === '/api/parsetime') { |