原创 LeetCode Sum Root to Leaf Numbers

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is

原创 LeetCode Single Number

Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm sh

原创 URAL 1022 Genealogical Tree

拓撲排序 #include <iostream> using namespace std; #include <vector> #include <memory.h> int n; int topology[120][120]; vect

原创 UVA 108 Maximum Sum

最大子矩陣和,轉化爲一維最大字串和解決 #include <stdio.h> #include <memory.h> int n; int data[120][120]; int column_sum[120]; int max_sum[

原创 uva 270 Lining Up

給出一系列二維座標上的點,統計最多有多少個點在同一條直線上,暴力枚舉n^3 #include <stdio.h> #include <math.h> struct Line { int no_slope; double k; do

原创 UVA 111 History Grading

最長公共子序列 #include <stdio.h> #include <memory.h> int correct[30]; int stu[30]; int dp[30][30]; int get_max(int a, int b

原创 LeetCode Sort List

Sort a linked list in O(n log n) time using constant space complexity. 對鏈表進行排序,要求時間複雜度爲O(n log n),並且空間複雜度爲常量。 運用歸併排序的思

原创 uva 147 Dollars

完全揹包問題,輸出爲方案總數。 #include <stdio.h> #include <memory.h> const int SIZE=11; int items[SIZE]={2000,1000,400,200,100,40,20,

原创 uva 122 Trees on the level

題目要求按層次輸出數的各個節點,其實只要對輸入的數據做個排序就可以了。 #include <iostream> using namespace std; #include <string> #include <set> #include