Skip to content

Instantly share code, notes, and snippets.

View Kelvinson's full-sized avatar
💭
This cat is googling and stackoverflowing~

Dong W Kelvinson

💭
This cat is googling and stackoverflowing~
  • Somewhere
View GitHub Profile
@Kelvinson
Kelvinson / min-char-rnn.py
Created March 17, 2018 22:07 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@Kelvinson
Kelvinson / graph_search.cpp
Created January 10, 2018 07:58 — forked from douglas-vaz/graph_search.cpp
Breadth First Search and Depth First Search in C++
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
class Node{
@Kelvinson
Kelvinson / isPalindrome.java
Created July 12, 2017 08:49
check a single node list is Palindrome, use fast and slow runner to find the middle element and store the second half list to compare with the first half of the original list
/**
* This solution does not to store the whole link of nodes
* only the first half is needed to be stored so it is friendly
* for space complexity. It use fast runner and slow runner to
* find the middle point of the list of node.
* @param list
* @return
*/
// Note: When I implemented this method I made two mistakes:
@Kelvinson
Kelvinson / cloneAndReverse.java
Created July 12, 2017 06:51
LinkList reverse and normal order construction
public static Node reverseAndClone(Node list) {
Node head = null;
while (list != null) {
Node n = new Node(list.val);
n.next = head;
head = n;
list = list.next;
}
return head;
}