Skip to content

Instantly share code, notes, and snippets.

void AddOrUpdateQuote(IQuote quote)
{
if(quote?.Id != null && quoteMap.containsKey(quote.Id) && !quote.equals(quoteMap[quote.Id]))
{
existingquote = quoteMap[quote.Id];
existingquote.Price = quote.Price;
existingquote.AvailableVolume = quote.AvailableVolume;
...
this.BookLookupTable[quote.Symbol].sort()
@Onaiplee
Onaiplee / comparator
Created April 27, 2017 21:40
oracle phone
class IntervalComparator implements Comparator<Interval> {
@Override
public int compare(Interval i1, Interval i2) {
return i1.start == i2.start ? Long.compare(i1.end, i2.end) : Long.compare(i1.start, i2.start);
}
}
@Onaiplee
Onaiplee / freelist.java
Last active April 27, 2017 21:40
Oracle phone
ArrayList<Interval> getFreeList(long start, long end, ArrayList<ArrayList<Interval>> busyLists) {
ArrayList<Interval> result = new ArrayList<>();
if (start >= end) return result;
if (busyLists.size() == 0) {
result.add(new Interval(start, end));
return result;
}
ArrayList<Interval> globalList = new ArrayList<>();
@Onaiplee
Onaiplee / gist:0a9ba86bd108b830be68
Created May 3, 2015 20:09
Rust & Murderer - Java
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static int INF = Integer.MAX_VALUE >> 2;
public static void main(String[] args) {
@Onaiplee
Onaiplee / gist:ed9841421070bd65054f
Created May 3, 2015 20:05
Rust & Murderer - Java - Hash
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static int INF = Integer.MAX_VALUE >> 2;
public static void main(String[] args) {
@Onaiplee
Onaiplee / gist:d82a50a52333cd8f782d
Created May 3, 2015 20:03
Rust & Murderer - Java - slow
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static int INF = Integer.MAX_VALUE >> 2;
public static void main(String[] args) {
@Onaiplee
Onaiplee / rust.java
Created May 3, 2015 20:02
Rust & Murderer - Java - alternative
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static int INF = Integer.MAX_VALUE >> 2;
public static int int_hash(int key) {
@Onaiplee
Onaiplee / rust.cc
Created May 3, 2015 19:59
Rust & Murderer - C++
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <climits>
#include <unordered_set>
#include <list>
#include <queue>
using namespace std;
class Solution {
public:
bool isMatch(const char *s, const char *p) {
int s_size = strlen(s);
int p_size = strlen(p);
vector<vector<int>> dict(s_size + 1, vector<int>(p_size + 1, -1));
is_match(s, p, 0, 0, dict);
return dict[0][0] ? true : false;
}
class Solution {
public:
int search(int A[], int n, int target) {
return bsearch(A, 0, n - 1, target);
}
int bsearch(int A[], int l, int u, int target) {
if (l > u) {
return -1;
}