原创 Median of Two Sorted Arrays(Need edition)

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

原创 1053. Path of Equal Weight

題目鏈接:http://pat.zju.edu.cn/contests/pat-a-practise/1053 同一類型:路徑長度、保存與給定值相同的路徑長度、記錄一定深度的路徑、記錄節點號/值。 // 採用鄰接表表示樹 // 用vect

原创 Evaluate Reverse Polish Notation

題目 Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each

原创 1064. Complete Binary Search Tree

題目鏈接:http://pat.zju.edu.cn/contests/pat-a-practise/1064 按正常思路,重點仍在建樹,需要結合完全二叉樹與二叉搜索樹的性質,確定跟節點的位置。 另外,其他思路見代碼註釋。 /* *

原创 1059. Prime Factors

題目鏈接:http://pat.zju.edu.cn/contests/pat-a-practise/1059 // 注意輸入數據爲1時特殊處理 // 採取常規方法,先求出“所有”素數,再一次遍歷。 // 符合條件者入vector,最後輸

原创 Two Sum

題目 Given an array of integers, find two numbers such that they add up to a specific target number. The function twoS

原创 1066. Root of AVL Tree

題目鏈接:http://pat.zju.edu.cn/contests/pat-a-practise/1066 考察AVL樹的操作,大家從理論上都懂得過程,但實現起來。。。不知道怎麼下手啊 /* * 參考:http://biaobia

原创 1062. Talent and Virtue

題目鏈接:http://pat.zju.edu.cn/contests/pat-a-practise/1062 德才論:按給定分類,然後進行排序。 // 典型分類排序題 #include <stdio.h> #include <stdl

原创 Reverse Words in a String(Need edition)

題目 Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is

原创 1060. Are They Equal

題目鏈接:http://pat.zju.edu.cn/contests/pat-a-practise/1060 轉爲科學計數法:輸入沒有固定格式,適合用char,讀取一個字符,處理一個。 string適合輸入格式固定,比如1073,科學計

原创 1051. Pop Sequence

題目鏈接:http://pat.zju.edu.cn/contests/pat-a-practise/1051 棧的操作的檢驗。當入棧元素不同於出棧元素時,持續向站內壓入,直到相等或棧滿後違法壓入。 // 孫佰貴 #include

原创 指針和指針的引用及雙指針

原文鏈接: http://blog.csdn.net/ztz0223/article/details/1628669 原文(附標註) 我一下討論的都是在不用return把值進行返回的情況, 也就是說用指針的情況。 很簡單就是指針

原创 Max Points on a Line

題目 Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 分析 1、首先的想法是根據兩點

原创 模板

題目 分析 時間複雜度 輸入 結論 CODE

原创 ACM小技巧

http://www.cnblogs.com/lifeathappiness/p/3530344.html