Skip to content

Instantly share code, notes, and snippets.

View Cee's full-sized avatar
🎀
ハネだ (<ゝω·)☆

Tianyu Wang Cee

🎀
ハネだ (<ゝω·)☆
View GitHub Profile
@Cee
Cee / product.json
Created April 23, 2014 02:39
Analyze Json
{
"ASIN": "",
"productInfo": [{
"productDetail": {
"UPC": "",
"bestSellerRank": ["#1 ['cate1','cate2',...]",""],
},
"name": "",
"img": "",
"productDescription": "",
@Cee
Cee / main.cpp
Created April 23, 2014 06:55
Zht‘s C++ Homework
//
// main.cpp
// Test
//
// Created by CirnoCee on 4/23/14.
// Copyright (c) 2014 CirnoCee. All rights reserved.
//
#include <iostream>
#include <string.h>
public class Solution {
public int[] plusOne(int[] digits) {
int length = digits.length;
int plus = 1;
for (int i = length - 1; i >= 0; i--){
digits[i] += plus;
if (digits[i] >= 10){
plus = 1;
digits[i] -= 10;
} else {
public class Solution {
public int searchInsert(int[] A, int target) {
int i = 0;
if (target < A[i]) return 0;
if (target > A[A.length - 1]) return A.length;
while ((target >= A[i]) || (i + 1 <= A.length)){
if (target == A[i]){
return i;
}
if ((target > A[i]) && (target < A[i + 1])){
public class Solution {
public ArrayList<ArrayList<Integer>> generate(int numRows) {
ArrayList<Integer> ret = new ArrayList<Integer>();
ArrayList<Integer> ret_temp = new ArrayList<Integer>();
ArrayList<ArrayList<Integer>> rn = new ArrayList<ArrayList<Integer>>();
if (numRows == 0) return rn;
ret_temp.add(1);
rn.add(ret_temp);
if (numRows == 1) return rn;
ret.add(1);
public class Solution {
public boolean searchMatrix(int[][] matrix, int target) {
int height = matrix.length;
int width = matrix[0].length;
int i = -1;
int j = -1;
while (i <= height - 1){
if (i == height - 1) break;
if (target < matrix[i + 1][0]) break;
i++;
public class Solution {
public int singleNumber(int[] A) {
int ret = 0;
for (int i = 0; i < A.length; i++){
ret = ret ^ A[i];
}
return ret;
}
}
/**
* Definition for binary tree
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
/**
* Definition for binary tree
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public class Solution {
public int firstMissingPositive(int[] A) {
if (A.length == 0) return 1;
for (int i = 0; i < A.length; i++) {
if (A[i] <= A.length && A[i] > 0 && A[i] != i+1) {
if (A[A[i]-1] != A[i]) {
int tmp = A[A[i]-1];
A[A[i]-1] = A[i];
A[i] = tmp;
i--;