原创 LeetCode329. Longest Increasing Path in a Matrix

題目: Given an integer matrix, find the length of the longest increasing path. From each cell, you can either move to

原创 HDOJ 1402. A * B Problem Plus (FFT快速傅里葉變換)

Problem Description Calculate A * B. Input Each line will contain two integers A and B. Process to end of file.

原创 LeetCode 327. Count of Range Sum

題目:Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive. Range sum S(

原创 LeetCode 11. Container With Most Water

題目:Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lin

原创 LeetCode144. Binary Tree Preorder Traversal

題目 Given a binary tree, return the preorder traversal of its nodes’ values. For example: Given binary tree {1,#,2,

原创 LeetCode 15. 3Sum

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

原创 LeetCode403. Frog Jump

題目: A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone

原创 LeetCode 199. Binary Tree Right Side View

題目:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can s

原创 LeetCode25. Reverse Nodes in k-Group

題目:對一個鏈表的長度爲k的塊進行reverse,要求常數空間。 Given a linked list, reverse the nodes of a linked list k at a time and return its m

原创 LeetCode 5 Longest Palindromic Substring

題目:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 10

原创 LeetCode 45. Jump Game II

題目 Given an array of non-negative integers, you are initially positioned at the first index of the array. Each elem

原创 LeetCode413. Arithmetic Slices

題目: A sequence of number is called arithmetic if it consists of at least three elements and if the difference between

原创 刷題總結

POJ 3253 Huffman樹 錯誤:結果超出了int的範圍,應該用long long;而且printf("%lld",ans),注意是lld POJ 2686 Traveling by Stagecoach(DAG,狀壓dp)

原创 Waiting List

SPOJ BIGSEQ 數位dp?

原创 Codeforces EC #36 C. Permute Digits

看上去不難,但一直在WA… 開始的算法是:從左往右構造結果res[i],在a沒被選擇的數字中,選擇<=b[i]的最大值,如果選擇的值< b[i],之後每一步都選擇剩餘數字中最大的。 問題在於:有可能選擇了某個數字,導致之後不可能再構