Skip to content

Instantly share code, notes, and snippets.

@wangdu1005
wangdu1005 / Is_Palindrome.swift
Created June 12, 2019 07:58
We divided the input by 10 for every iteration, so the time complexity is O(log10(n)) Space complexity : O(1).
class Solution {
func isPalindrome(_ x: Int) -> Bool {
return self.reverseWay(x)
}
// Recommanded
func reverseWay(_ x: Int) -> Bool {
class Solution {
func fib(_ N: Int) -> Int {
return self.recursiveWay(N)
}
func recursiveWay(_ N: Int) -> Int {
if N == 0 { return 0 }
@wangdu1005
wangdu1005 / KeyboardHandler.swift
Last active September 27, 2018 04:59
KeyboardHandler
import UIKit
enum KeyboardDirection {
case none
case up
case down
}
struct KeyboardFrameDelta {
@wangdu1005
wangdu1005 / README.md
Created September 6, 2018 08:04 — forked from CodingDoug/README.md
Realtime Database triggers with Cloud Functions for Firebase - source

Realtime Database triggers with Cloud Functions for Firebase - source

This gist contains the source code in my video series about Realtime Database triggers. You can watch the three parts here:

  1. Part 1 (intro, onCreate)
  2. Part 2 (onUpdate, infinite loops)
  3. Part 3 (onDelete, transactions)

index.ts contains the Cloud Functions code, and dialog.ts contains the script to run

@wangdu1005
wangdu1005 / subsets.py
Last active January 13, 2018 08:13
[Algorithm] 78.Subsets & 90.Subsets II, non-dfs recursive solution
import copy
class Solution:
def subsets(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
numsCount = dict()
numsCount[nums[0]] = 1
//
// TableViewController.m
// testProject
//
// Created by WZ on 03/10/2017.
// Copyright © 2017 zeus. All rights reserved.
//
#import "DeviceInfoTableViewController.h"
#import "XXRootViewController.h"
@implementation XXRootViewController {
NSMutableArray *_objects;
}
- (void)loadView {
[super loadView];
_objects = [[NSMutableArray alloc] init];
@wangdu1005
wangdu1005 / gist:1f42c101d1a54baa8d5ed67ab15c53ae
Created October 3, 2017 09:20
theos original table view application code
#import "XXRootViewController.h"
@implementation XXRootViewController {
NSMutableArray *_objects;
}
- (void)loadView {
[super loadView];
_objects = [[NSMutableArray alloc] init];
@wangdu1005
wangdu1005 / 0_reuse_code.js
Created June 15, 2017 05:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@wangdu1005
wangdu1005 / testTableView
Created November 4, 2016 07:28
the error of "failed to obtain a cell from its dataSource "
import UIKit
import Alamofire
class OrderListTableViewController: UITableViewController {
var orderNameList = ["jack", "ken", "howard"]
var orderLandlordNameList = ["ord1", "ord2", "ord3"]
var orderDurationList = ["1~2", "3~4", "5~6"]
var orderStatusList = ["new", "old", "change"]
var result = " "