Skip to content

Instantly share code, notes, and snippets.

Lee Zhen Yong bruceoutdoors

Block or report user

Report or block bruceoutdoors

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View course-schedule-ii.cs
public class Solution {
private IList<IList<int>> graph;
private bool[] marked;
private bool[] onStack;
private bool hasCycle;
private Stack<int> s;
public int[] FindOrder(int numCourses, int[,] prerequisites) {
graph = new List<IList<int>>();
marked = new bool[numCourses];
View course-schedule.cs
public class Solution {
private IList<IList<int>> graph;
private bool[] marked;
private bool[] onStack;
private bool hasCycle;
public bool CanFinish(int numCourses, int[,] prerequisites) {
graph = new List<IList<int>>();
marked = new bool[numCourses];
onStack = new bool[numCourses];
View keys-and-rooms.cs
public class Solution {
IList<IList<int>> graph;
bool[] marked;
public bool CanVisitAllRooms(IList<IList<int>> rooms) {
graph = rooms;
marked = new bool[rooms.Count];
dfs(0);
View DisjointSet.cpp
/******************************************************************************
* Execution: ./DisjointSet < input.txt
* Data files: http://algs4.cs.princeton.edu/15uf/tinyUF.txt
* http://algs4.cs.princeton.edu/15uf/mediumUF.txt
* http://algs4.cs.princeton.edu/15uf/largeUF.txt
*
* Weighted quick-union by rank with path compression.
*
* % ./DisjointSet < tinyUF.txt
* 4 3
View disjoint_set.py
# Python3 port of http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/UF.java.html
class DisjointSet:
"""
Execution: python disjoint_set.py < input.txt
Data files: http://algs4.cs.princeton.edu/15uf/tinyUF.txt
http://algs4.cs.princeton.edu/15uf/mediumUF.txt
http://algs4.cs.princeton.edu/15uf/largeUF.txt
Weighted quick-union by rank with path compression.
@bruceoutdoors
bruceoutdoors / charcast.cpp
Created May 18, 2017
from int cast to byte, from byte extract hex values.
View charcast.cpp
#include <iostream>
using namespace std;
struct Byte {
void to4Bits(char c)
{
lo = c >> 4;
hi = c & 0x0F;
}
View fft-convolution-inplace.cpp
#include <iostream>
#include <complex>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
using namespace std;
View fft-convolution-precompute-omega.cpp
#include <iostream>
#include <complex>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
using namespace std;
View fft-convolution.cpp
#include <iostream>
#include <complex>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
typedef complex<double> xd;
View vector-convolution.cpp
#include <iostream>
#include <complex>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
double PI = acos(0) * 2;
You can’t perform that action at this time.