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
# Given an arbitrary text document written in English, write a program that will | |
# generate a concordance, i.e. an alphabetical list of all word occurrences, | |
# labeled with word frequencies. | |
# | |
# Bonus: label each word with the sentence numbers in which each occurrence appeared. | |
from nltk.tokenize import word_tokenize | |
import fileinput | |
import nltk |
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
// Given a list of strings (int, string) where int is the number of hits and the string is a domain name, | |
// tally a domain and each of its subdomains' total hits. | |
hit_list = ["100,yahoo.com", | |
"20,mail.yahoo.com"] | |
def calculate_domain_hits(): | |
domain_counts = {} | |
for entry in hit_list: | |
# Parse each input entry |
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
def find_len_substr(string): | |
start = 0 | |
cur = start | |
cur_max = 0 | |
seen = {} | |
while start < len(string): | |
deja_vu = False | |
for x in range(start, len(string)): |
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
// Given digits, | |
public void calculateNumberSystem(int[] bases) { | |
int[] num = new int[bases.length]; | |
HashSet<String> nums = new HashSet<String>(); | |
for(int i = bases.length-1; i >= 0; i--) { | |
// Add result to set | |
nums.add(Arrays.toString(num)); |
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.*; | |
* import java.io.*; | |
* | |
* public List<String> getDirectFriendsForUser(String user) | |
* | |
* public List<String> getAttendedCoursesForUser(String user) | |
* | |
* Please complete the method below |
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 StockAnalysis { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
int n = sc.nextInt(); | |
int[] nums = new int[n]; | |
for(int i = 0; i < n; i++) { |
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
/* | |
Given a text with N words (a_1 ... a_N), and a very large textual screen of | |
width C chars and height L lines (C & L may be much larger than N). | |
How many times would the text fully fit on the screen if words cannot be broken? | |
Text = "this is an example" | |
C = 15 | |
L = 5 | |
textOnScreen(text, c, l) = 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
/* | |
Given a set of intervals, determine whether a number lies in any of those | |
ranges. | |
[1, 5], [7, 10] | |
Example: | |
5: True | |
11: False | |
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
/* | |
Given a multiple sorted lists, determine the unique elements (symmetric difference). | |
https://en.wikipedia.org/wiki/Symmetric_difference | |
*/ | |
import java.util.*; | |
class DoubleList | |
{ | |
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
class Multiply | |
{ | |
public static void main (String [] args) | |
{ | |
int base = 12; | |
// List style | |
for(int i = 1; i <= base; i++) { | |
for(int j = 1; j <= base; j++) { | |
System.out.println(i + " x " + j + ": " + i*j); |