原创 Add Two Numbers

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

原创 FZU 2039 Pets 二分圖匹配

Pets Accept: 278    Submit: 751 Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description Are you inte

原创 SGU 194 Reactor Cooling 無源匯帶上下界可行流

Reactor Cooling time limit per test: 0.5 sec. memory limit per test: 65536 KB input: standard output: standard The

原创 Median of Two Sorted Arrays

There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall

原创 Path Sum

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along

原创 Valid Parentheses

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid

原创 UVA 11324 The Largest Clique 強連通縮點+DP

Problem B: The Largest Clique Given a directed graph G, consider the following transformation. First, create a new g

原创 String to Integer (atoi)

Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a ch

原创 POJ 3177 & 3352 邊雙連通分支

兩題都是同樣的意思,給定一張無向圖G,問至少添加幾條邊才能使其變成雙連通圖 去掉橋,其餘的連通分支就是邊雙連通分支了。一個有橋的的連通圖要變成邊雙連通圖的話把雙連通子圖收縮爲 一個點,形成一顆樹。需要加的邊(leaf+1)/2 (leaf

原创 Climbing Stairs

You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In

原创 Remove Duplicates from Sorted Array II

Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? For example, Given sorted array A = 

原创 退役了。。。

兩場都有拿銀的機會,結果都沒把握好。。很遺憾。。。 都卡在傻逼題上了。。 兩場下來,感覺圖論都是金牌題。。 蒟蒻每次只能幫隊伍做水題。。。  感覺有好多的回憶。。人太懶。。以後寫吧。。

原创 Remove Duplicates from Sorted Array

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length

原创 Best Time to Buy and Sell Stock

Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to

原创 劍指offer 06:重建二叉樹

#include <cstdlib> #include <cctype> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> #includ