Longest Palindromic Substring[leetcode] O(n^2)的DP和O(n)的演算法,longestsubstring實現了兩種方法,一種是DP,用迴圈做的,遞迴的話更簡單。string longestPalindrome(string s) { int n = s.size(); bool dp[1001][1001]; int maxl = 1; int maxs = 0; for
HDU 4998 Rotate,hdu4998rotateRotateTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 210 Accepted Submission(s): 110Problem DescriptionNoting is more
Median of Two Sorted Arrays[leetcode] O(nlogn)的兩種思路,leetcodenlogn設兩個數組分別為A和B,size為as和bs。原問題可以轉化為兩個排序數組求第k大的問題。還是兩種思路:比較A[as/2]和B[bs/2],每次拋棄A或者B的一半代碼如下:double findMedianSortedArrays(int A[], int m, int B[], int n) { int total = m + n;
HDU-5014-Number Sequence,hdu-5014-numberProblem DescriptionThere is a special number sequence which has n+1 integers. For each number in sequence, we have two rules:● ai ∈ [0,n] ● ai ≠ aj( i ≠ j )For sequence a and sequence b, the
從listView1中選擇記錄到listView2中,listview1listview21.自訂Worker欄位類 public class SelectWorker { public int WorkerID; public string WkName; }2.定義全域變數 List<SelectWorker> wkList0 = new List<SelectWorker>();
Accelerated C++ 學習筆記及題解----第三章,accelerated題解本章主要內容1.類型定義typedef2.局部變數3.格式化輸出初涉4.向量vector及基本方法本章主要程式碼1.計算平均成績#include <iomanip>#include <iostream>#include <string>using namespace std;int main(){// ask for and read the student&