Skip to content

Instantly share code, notes, and snippets.

View antonio081014's full-sized avatar
💭
Learning SwiftUI

Yi antonio081014

💭
Learning SwiftUI
View GitHub Profile
@antonio081014
antonio081014 / GenericMergeSort.java
Last active December 19, 2015 00:59
This is the code implementing Merge Sort.
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
if (args.length == 0) {
System.out
.println("Proper Usage is: java main number1 number2 number3 ...");
System.exit(0);
}
@antonio081014
antonio081014 / AVLTree.java
Last active February 14, 2023 13:50
This is a Generic Implementation of AVL tree in java.
import java.util.LinkedList;
import java.util.Queue;
public class AVLTree<T extends Comparable<T>> {
Node<T> root;
public AVLTree() {
root = null;
}
@antonio081014
antonio081014 / BinaryTreeLevelTraversal.java
Created August 13, 2013 18:23
Yesterday(8/12/2013), I was asked to implement this problem Binary Tree Level-Order Traversal in a short time. For the first thought, it looks like an easy BFS problem, but quickly I realize a problem how can I track the level of the tree? Haha... At the end, I gave my solution, but the interviewee said my solution is most weird one he has ever …
/**
* This is a demo class in java <br />
* Implementing Binary Tree Traverse Level By Level with BFS and DFS. <br />
* All of the algorithm I implemented use O(N) time and space, N here represents the number of nodes in the tree.
*
*/
import java.util.LinkedList;
import java.util.Queue;
/**
@antonio081014
antonio081014 / UISwipeGestureRecognizerDemo.m
Created August 13, 2015 20:13
A Simple Demo of Using UISwipeGestureRecognizer
- (void)viewDidLoad
{
[super viewDidLoad];
UISwipeGestureRecognizer *leftGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe:)];
leftGesture.direction = UISwipeGestureRecognizerDirectionDown;
[self.tableView addGestureRecognizer:leftGesture];
UISwipeGestureRecognizer *rightGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe:)];
rightGesture.direction = UISwipeGestureRecognizerDirectionUp;
@antonio081014
antonio081014 / BitManipulation.m
Created December 1, 2015 01:25
This is an implementation of Basic Bit Manipulation Operation written in Objective-C.
- (BOOL)getBitforNumber:(NSInteger)num atIndex:(NSUInteger)i
{
return (num & (1 << i)) != 0;
}
- (NSInteger)setBitforNumber:(NSInteger)num atIndex:(NSUInteger)i
{
return num | (1 << i);
}
@antonio081014
antonio081014 / QuickSort.h
Last active December 2, 2015 01:48
This is the quicksort implementation written in Objective-C.
- (NSArray *)quicksort:(NSArray *)array
@antonio081014
antonio081014 / MergeSort.h
Last active December 2, 2015 19:42
This is the Merge-Sort implementation written in Objective-C.
/**
* Divide and Conque Algorithm.
*/
- (NSArray *)mergesort:(NSArray *)array
@antonio081014
antonio081014 / BinarySearch.h
Last active December 3, 2015 00:19
This is the Binary Search implementation written in Objective-C.
/**
* Standard Binary Search.
*/
- (BOOL)binarySearch:(NSInteger)number inArray:(NSArray *)array;
/**
* Find the very first element index in an ordered array that satisfy with crateria, then return the index.
* Otherwise, return -1.
* This algorithm implemented with binary search.
*/
@antonio081014
antonio081014 / BinaryTree.h
Last active December 3, 2015 06:53
Simple Task with Binary Tree written in Objective-C.
/**
* TreeNode:
* -val: NSNumber
* -left: TreeNode
* -right: TreeNode
*/
// Task: Build a Balanced Binary Search Tree from an Ordered Array.
- (TreeNode *)buildMinBSTFromArray:(NSArray *)array;
@antonio081014
antonio081014 / ViewController.m
Created June 5, 2016 20:53
Snippet of code on How to add Facebook Ads Banner to ViewController
//
// ViewController.m
//
// Created by Antonio081014 on 6/4/16.
// Copyright © 2016 Antonio081014.com. All rights reserved.
//
#import "ViewController.h"
@import FBAudienceNetwork;