Skip to content

Instantly share code, notes, and snippets.

View shaobos's full-sized avatar

Shaobo Sun shaobos

  • Sunnyvale, California, US
View GitHub Profile
@shaobos
shaobos / reverse.cpp
Created March 5, 2023 23:18
Reverse Linked List - C++
#include <iostream>
using namespace std;
struct Node {
int data;
Node* next;
};
class LinkedList {
private:
@shaobos
shaobos / reverse.js
Last active March 5, 2023 05:29
Reverse linked list - Javascript
class Node {
constructor(val) {
this.val = val;
this.next = null;
}
}
class LinkedList {
constructor() {
this.head = null;
@shaobos
shaobos / reverse.py
Created March 5, 2023 05:26
Reverse linked list - Python
class Node:
def __init__(self, val):
self.val = val
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def add(self, val):
@shaobos
shaobos / reverse.java
Created March 5, 2023 05:24
Reverse linked list - Java
public class Node {
int val;
Node next;
public Node(int val) {
this.val = val;
this.next = null;
}
}

Keybase proof

I hereby claim:

  • I am shaobos on github.
  • I am shaobo_sun (https://keybase.io/shaobo_sun) on keybase.
  • I have a public key ASC36LX-l382tAh0_2qm2ftac-h-VuF2bHT8UWOE7a99rAo

To claim this, I am signing this object:

"{
\"1\": {
\"id\": \"1\",
\"name\": \"5M: 5th and Minna\",
\"latitude\": \"37.782116\",
\"longitude\": \"-122.406235\",
\"market_type\": \"market\",
\"distance\": \"5837.980323978116\",
\"region\": \"San Francisco\",
\"truck_count\": \"6\",
@shaobos
shaobos / gist:fe4df4a64fabadad3fe3
Created May 5, 2015 05:13
off the grid script
/**
* Copyright (c) 2007-2013 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com
* Dual licensed under MIT and GPL.
* @author Ariel Flesler
* @version 1.4.6
*/
;(function($){var h=$.scrollTo=function(a,b,c){$(window).scrollTo(a,b,c)};h.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1,limit:true};h.window=function(a){return $(window)._scrollable()};$.fn._scrollable=function(){return this.map(function(){var a=this,isWin=!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)return a;var b=(a.contentWindow||a).document||a.ownerDocument||a;return/webkit/i.test(navigator.userAgent)||b.compatMode=='BackCompat'?b.body:b.documentElement})};$.fn.scrollTo=function(e,f,g){if(typeof f=='object'){g=f;f=0}if(typeof g=='function')g={onAfter:g};if(e=='max')e=9e9;g=$.extend({},h.defaults,g);f=f||g.duration;g.queue=g.queue&&g.axis.length>1;if(g.queue)f/=2;g.offset=both(g.offset);g.over=both(g.over);return this._scrollable().each(function(){if(e==n
<div class="otg-market-data">
<div class="otg-market-data-inner">
<div class="otg-market-data-main">
<div class="otg-market-data-na-container">
<a class="otg-market-data-close-link" href="#">&times;</a>
<div class="otg-market-data-name">5M: 5th and Minna</div>
<div class="otg-market-data-address">
<a href="https://maps.google.com?q=410+Minna+St%2C+San+Francisco" target="_blank">410 Minna St, San Francisco</a>
</div>
</div>
var trs = document.getElementsByTagName("tr")
var length = trs.length
var failed_projects = ["failed projects:"]
var failed_projects_without_link = ["these failed projects don't have a link to failure:"]
for (var i = 0; i<length; i++) {
var product_name = null
var is_failed = false
var link
var tds = trs[i].getElementsByTagName("td")
// https://oj.leetcode.com/problems/distinct-subsequences/
// is my solution correct by any means?
class Solution {
public:
int numDistinct(string S, string T) {
int result = 0;
int length_S = S.size();
int length_T = T.size();
is_distinct(0, 0, S, T, result, length_S, length_T);