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
# Question | |
# | |
# We have many applications running that store temporary files in /var/tmp, which fills up over time. | |
# | |
# Write a function that cleans out files older than a user specified number of days and | |
# removes empty directories recursively. | |
# | |
import os | |
import sys |
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
/* Question | |
* | |
* Given a binary search tree (BST), write the following two methods: | |
* | |
* 1. Given a pointer to a node in the tree, find the smallest element. | |
* 2. Given a pointer to a node in the tree, find the next highest element in key value. | |
* 3. Do an in-order traversal of the tree | |
* */ | |
struct Node { |
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 fileinput | |
endOfSentence = ['.', '!', '?'] | |
def charInWord(word): | |
for char in endOfSentence: | |
if char in word: | |
return True | |
return 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
import java.util.*; | |
class Sort { | |
// Bubble Sort algorithm | |
void bubblesort(int[] arr) { | |
for(int i = arr.length - 1; i >= 0; i--) { | |
boolean noSwaps = true; | |
for(int j = 0; j < i; j++) { |
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.*; | |
class Bit { | |
public static void main(String[] args) { | |
Scanner in = new Scanner(System.in); | |
int num = in.nextInt(); | |
System.out.println("Bit representation: " + printBits(num)); | |
System.out.println("Number of 1s: " + countBits(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
inp = raw_input('Input: ') | |
print inp.replace(" ", "") |
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
/* | |
String s = add("1234","567"); | |
1234 | |
567 | |
---- | |
1801 | |
=> "1801" | |
*/ |
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
/* | |
Write a function (in a non-scripting language) to give the absolute path | |
given the current working directory and a path. e.g. | |
CWD: “/home/h2rashee/downloads/” | |
path: “../../hello.c” | |
result: “/home/hello.c” | |
CWD: “” | |
path: “../hello.c” | |
result: “../hello.c” |
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
/* | |
Phone numbers are assigned to all the customers (in Canada, where | |
the phone number format is xxx xxx xxxx). We have three functions to do: | |
* isTaken? : is this number taken? | |
* iGaveOut : takes a number and marks it as taken. | |
* giveMeNumber : takes no arguments and returns a random number not taken. | |
Describe a data structure that can accomplish these functions | |
in the fastest possible time. |
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 LinkedLists | |
{ | |
public static void main(String[] args) { | |
LinkedList llist = new LinkedList(); | |
// Use LinkedLIst class API here | |
} | |
} | |
class LinkedList |