原创 二分查找法注意事項

二分查找法注意事項 midFind(int a[], int s, int e, int data); 1. 分爲遞歸和非遞歸,但應儘量避免遞歸。 2. 非遞歸中終止條件分爲while ( s < e )和while ( s

原创 北郵研究生2016年算法期末考試試題

計算遞歸方程: 兩路歸併排序 ,說明其算法原理,並用c語言實現,計算最壞情況下複雜度。 圖的最短路徑 ,圖G=< V,E >,說明使用的數據結構,並描述從起始點到其他點的最短路徑的算法。 分治法:描述快速傅里葉變換算法,並計

原创 leetcode-Ugly Number

Question: Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose pr

原创 leetcode- Sum of Left Leaves

Question: Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two

原创 leetcode-Generate Parentheses

Question: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For e

原创 manacher算法注意事項

manacher算法注意事項 manacher算法用來求解一個字符串中的最長迴文子串,類似12421,迴文最大長度爲5. /* *第一步:將字符串改寫爲奇數個數,簡化問題,不用考慮偶數的情況,坑點:必須額外添加的字符出現在首位,如:#1#

原创 二分查找法

二分查找法注意事項 midFind(int a[], int s, int e, int data); 1. 分爲遞歸和非遞歸,但應儘量避免遞歸。 2. 非遞歸中終止條件分爲while ( s < e )和while ( s <= e

原创 leetcode-Minimum Moves to Equal Array Elements

Question: Given a non-empty integer array of size n, find the minimum number of moves required to make all array elemen

原创 leetcode- Symmetric Tree

Question: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, t

原创 leetcode-Merge Two Sorted Lists

Question: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together

原创 leetcode-Decode Ways

Question: A message containing letters from A-Z is being encoded to numbers using the following mapping: ‘A’ -> 1 ‘B’

原创 leetcode-Remove Nth Node From End of List

Question: Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked

原创 leetcode-3sum(n^2)

Question: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique trip

原创 leetcode-Next Greater Element II

Question: Given a circular array (the next element of the last element is the first element of the array), print the

原创 leetcode-Evaluate Reverse Polish Notation

Question: Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Ea