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
case class ListNode[+T](data: T, next: Option[ListNode[T]]) object List { | |
def newList[T](data: T) = newListFromNode(new ListNode(data, None)) | |
def newListFromNode[T](node: ListNode[T]) = new List(node) | |
private def travse_iter[A](head:Option[ListNode[A]], fn: (ListNode[A]) => Unit): Unit = { | |
head match { | |
case Some(node) => { | |
fn(node) | |
List.travse_iter(node.next, fn) |
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
#include <iostream> | |
#include <time.h> | |
#include <sys/types.h> | |
#include <sys/time.h> | |
#include <unistd.h> | |
#define SIZE (40 * 1024 * 1024 * 1024L) | |
static inline double get_time_diff_double(struct timeval end, struct timeval start) | |
{ |
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
#!/bin/bash | |
while : | |
do | |
git add . | |
sleep 1 | |
done |
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
(defn qsort [l] | |
(if (empty? l) '() | |
(let [f (first l) | |
smaller (filter #(<= % f) (rest l)) | |
bigger (filter #(> % f) (rest l))] | |
(concat (qsort smaller) [f] (qsort bigger))))) |
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
/* | |
时间限制:10000ms | |
单点时限:1000ms | |
内存限制:256MB | |
描述 | |
Given a sequence {an}, how many non-empty sub-sequence of it is a prefix of fibonacci sequence. | |
A sub-sequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. | |
The fibonacci sequence is defined as below: |
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
#!/usr/bin/env python | |
class TreeNode: | |
def __init__(self, val): | |
self.val = val | |
self.left = None | |
self.right = None | |
def printTreeWithDistance(root, k): | |
def impl(root, path): |
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
struct ListNode<'a, T> where T: PartialOrd + 'a { | |
val: &'a T, | |
next: Option<Box<ListNode<'a, T>>>, | |
} | |
fn reverse_list<'a, T>(head: Option<Box<ListNode<'a, T>>>) -> Option<Box<ListNode<'a, T>>> | |
where T: 'a + PartialOrd { | |
if let Some(mut p) = head { | |
let mut tail = None; | |
loop { |
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
pub struct Tree<T> { | |
root: Link<T>, | |
size: usize, | |
} | |
type Link<T> = Option<Box<Node<T>>>; | |
struct Node<T> { | |
elem: T, | |
left: Link<T>, |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import os | |
import sys | |
import traceback | |
import sqlite3 | |
import logging | |
from Queue import Queue | |
from Queue import Empty |
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
/** | |
* Copyright (c) Rich Hickey. All rights reserved. | |
* The use and distribution terms for this software are covered by the | |
* Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) | |
* which can be found in the file epl-v10.html at the root of this distribution. | |
* By using this software in any fashion, you are agreeing to be bound by | |
* the terms of this license. | |
* You must not remove this notice, or any other, from this software. | |
**/ |