Skip to content

Instantly share code, notes, and snippets.

@StephanieMak
StephanieMak / CareerCup1.2.cpp
Last active August 29, 2015 14:27 — forked from ThunderXu/CareerCup1.2.cpp
Implement a function void reverse(char* str) in C or C++ which reverses a null-terminated string.
#include "stdafx.h"
#include <string>
#include <iostream>
void reverse(char*);
int main()
{
using namespace std;
char str[] = "This is a test";
@StephanieMak
StephanieMak / ReverseAString.java
Last active August 29, 2015 14:27 — forked from XiaoxiaoLi/ReverseAString.java
#CC150 #CC150-chap1 1.2 Implement a function void reverse(char* str) in C or C++ which reverses a null-terminated string.
//1.2 Implement a function void reverse(char* str) in C or C++ which reverses a null-terminated string.
public class ReverseAString{
/** Time: O(n), Space O(n)
* Find the middle point of the array, swap each pair of char that is before
* and after the middle point with the same distance
*/
public static String reverseStr(String str) {
if (str == null || str.isEmpty()) {
@StephanieMak
StephanieMak / C2P1.java
Last active August 29, 2015 14:27 — forked from spininertia/C2P1.java
Career Cup 2.1 Write code to remove duplicates from an unsorted linked list. FOLLOW UP How would you solve this problem if a temporary buffer is not allowed?
package chapter2;
import java.util.HashSet;
/*
* Career Cup 2.1
* Write code to remove duplicates from an unsorted linked list.
* FOLLOW UP
* How would you solve this problem if a temporary buffer is not allowed?
*/
@StephanieMak
StephanieMak / gist:c1fbaa95b063b5edcd74
Last active August 29, 2015 14:27 — forked from mogutou1214/gist:6408080
Careercup 2.1 - Write code to remove duplicates from an unsorted linked list. FOLLOW UP How would you solve this problem if a temporary buffer is not allowed? Note: 1. pay special attention to deleting a node 2. learn to use "map" in C++ STL as a hash table
/*Remove duplicates from an unsorted linked list - cc2.1*/
void removeDuplicate1(node *head){
map<int,bool> table;
node *curr = head;
node *pre = NULL;
while(curr!=NULL){
/*delete the node if it already exists in the map*/
if(table[curr->data]){
pre->next = curr->next;
delete curr;
@StephanieMak
StephanieMak / README.md
Last active September 8, 2015 23:12 — forked from akdh/README.md
Validation testing instructions for suggestion services.

Test your service

See https://github.com/akdh/cst-tools for JSON schemas.

Assuming your service callback URL is http://127.0.0.1:5002/suggestions, you can make a request to your service and ensure that it is valid using the following commands:

curl -H "Content-Type: application/json" --data @request.json -XPOST http://127.0.0.1:5002/suggestions > response.json
python validate.py data.json 192

No errors should be produced.

@StephanieMak
StephanieMak / WordCount2.java
Last active September 10, 2015 13:50 — forked from aajisaka/WordCount2.java
WordCount v2.0 for MapReduce Tutorial
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
@StephanieMak
StephanieMak / WordCount.java
Last active September 10, 2015 13:50 — forked from aajisaka/WordCount.java
WordCount v1.0 for MapReduce Tutorial
import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
@StephanieMak
StephanieMak / gist:a729839cfd1ef8352c55
Last active September 17, 2015 00:31 — forked from evanp/gist:6456479
This is an example of using the JavaScript .dropdown("toggle") method in Bootstrap Because Bootstrap doesn't clear the "open" class on the dropdown parent, it stays open.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test dropdown toggle</title>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css">
</head>
<body>
<div class="dropdown">
package net.fehmicansaglam.minheap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@SuppressWarnings("unused")
public class MinHeap<K, V extends Comparable<V>, T extends MinHeap.Item<K, V>> {
@StephanieMak
StephanieMak / BinaryHeap.java
Last active September 29, 2015 13:28 — forked from johntbates/BinaryHeap.java
Binary heaps - part two
package heap;
import java.util.ArrayList;
import java.util.Collection;
public abstract class BinaryHeap<T extends Comparable<T>> {
private ArrayList<T> theHeap;
private final int sign;