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
import java.util.Hashtable; | |
import java.util.Stack; | |
class Data | |
{ | |
// Stores <key>-<value> pairs | |
Hashtable<String, String> data; | |
// Stores <value>-<value quantity> pairs | |
Hashtable<String, Integer> valCount; |
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
from email.MIMEMultipart import MIMEMultipart | |
from email.MIMEText import MIMEText | |
import smtplib | |
def sendEmail(fromAdd, toAdd, body): | |
server = smtplib.SMTP('smtp.gmail.com', 587) | |
server.set_debuglevel(True) | |
server.starttls() |
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
import java.io.*; | |
import java.util.*; | |
/* | |
+===+===+===+===+===+===+===+===+===+ | |
‖ : : ‖ : : ‖ : : ‖ | |
+---+---+---+---+---+---+---+---+---+ | |
‖ : 1 : 2 ‖ : : ‖ 3 : : ‖ | |
+---+---+---+---+---+---+---+---+---+ |
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
import java.util.*; | |
// Time complexity is the length of both arrays (linear) | |
class Intersection | |
{ | |
ArrayList<Integer> results; | |
public static void main (String [] args) | |
{ |
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
import java.io.*; | |
import java.util.*; | |
/* | |
* 1) O(1) memory usage | |
* 2) Numbers in range [0, 1000) | |
* 3) Definition of median: | |
* [1, 2, 3] = 2 | |
* [1, 2, 3, 4] = 2.5 | |
*/ |
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
import java.io.*; | |
import java.util.*; | |
class Node { | |
String val; | |
Node left; | |
Node right; | |
Node(String data) { |
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
/* | |
* http://en.wikipedia.org/wiki/Fizz_buzz | |
*/ | |
class FizzBuzz | |
{ | |
public static void main (String [] args) | |
{ | |
for(int i = 1; i <= 100; i++) { | |
if(i%3 == 0) { |
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
# http://en.wikipedia.org/wiki/Fizz_buzz | |
for i in range(1, 101): | |
if not i%3: | |
if not i%5: | |
print "FizzBuzz" | |
continue | |
print "Fizz" | |
elif not i%5: | |
print "Buzz" |
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
/* | |
1. Write Breadth-First Traversal on a Tree | |
1 | |
2 3 | |
4 5 6 | |
2 2 3 -- | |
1 2 3 4 5 6 |
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
import java.io.*; | |
import java.util.*; | |
/* | |
* To execute Java, please define "static void main" on a class | |
* named Solution. | |
* | |
* If you need more classes, simply define them inline. | |
*/ |