原创 將整數翻轉輸出

Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 click to show spoilers.

原创 判斷二叉數是否是平衡樹

Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined a

原创 用fork創建進程樹

創建一個如下圖所示的進程樹。用getpid()和getppid()梳理其關係。 要注意的是fork之後的子進程和父進程共享代碼段,並且如果有寫的情況下會有各自的數據段。 #include<stdio.h> #include<unistd

原创 不用額外空間判斷一個數是否是迴文形式

Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Could

原创 求一個數的階乘後面有多少個0

Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time com

原创 求數組中出現次數查過n/2的元素

前提:此數組不爲空,且這樣的元素存在 solutions: 分析:可以將數組排序,出現在n/2+1位置的一定是所求。故排序的話也可以只排前n/2+1個。 class Solution { public: void quikSort(

原创 Longest Valid Parentheses

Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parenth

原创 Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. For example, the longest substri

原创 實現字典樹Trie的基本操作

字典樹:根節點不包含字符,除根節點外每一個節點都只包含一個字符; 從根節點到某一節點,路徑上經過的字符連接起來,爲該節點對應的字符串; 每個節點的所有子節點包含的字符都不相同。 實現字典樹的插入insert(),查找search(stri

原创 Repeated DNA Sequences(統計字符串出現次數)

All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studyi

原创 Excel Sheet Column Title(1->A, 2->B, 28->AB )

Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -> A

原创 [LeetCode]Add Two Numbers

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each

原创 二叉樹層序遍歷應用之Binary Tree Right Side View

Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ord

原创 ZigZag Conversion(Z形排列的字符/數,求其橫向觀察結果)

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to disp

原创 HouseRobber(即求一串數中不連續的數之和中最大的)

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed,