原创 [leetcode] 404. Sum of Left Leaves 解題報告

題目鏈接:https://leetcode.com/problems/sum-of-left-leaves/ Find the sum of all left leaves in a given binary tree. Ex

原创 [leetcode] 402. Remove K Digits 解題報告

題目鏈接:https://leetcode.com/problems/remove-k-digits/ Given a non-negative integer num represented as a string, remove 

原创 [leetcode] 407. Trapping Rain Water II 解題報告

題目鏈接:https://leetcode.com/problems/trapping-rain-water-ii/ Given an m x n matrix of positive integers representing th

原创 [leetcode] 392. Is Subsequence 解題報告

題目鏈接:https://leetcode.com/problems/is-subsequence/ Given a string s and a string t, check if s is subsequence of t.

原创 [leetcode] 397. Integer Replacement 解題報告

題目鏈接:https://leetcode.com/problems/integer-replacement/ Given a positive integer n and you can do operations as follo

原创 [leetcode] 401. Binary Watch 解題報告

題目鏈接:https://leetcode.com/problems/binary-watch/ A binary watch has 4 LEDs on the top which represent the hours (0-11

原创 [leetcode] 422. Valid Word Square 解題報告

題目鏈接: https://leetcode.com/problems/valid-word-square/ Given a sequence of words, check whether it forms a valid word

原创 [leetcode] 412. Fizz Buzz 解題報告

題目鏈接: https://leetcode.com/problems/fizz-buzz/ Write a program that outputs the string representation of numbers from

原创 [leetcode] 438. Find All Anagrams in a String 解題報告

題目鏈接:https://leetcode.com/problems/find-all-anagrams-in-a-string/ Given a string s and a non-empty string p, find all

原创 [leetcode] 393. UTF-8 Validation 解題報告

題目鏈接:https://leetcode.com/problems/utf-8-validation/ A character in UTF8 can be from 1 to 4 bytes long, subjected to

原创 [leetcode] 409. Longest Palindrome 解題報告

題目鏈接:https://leetcode.com/problems/longest-palindrome/ Given a string which consists of lowercase or uppercase letter

原创 [leetcode] 399. Evaluate Division 解題報告

題目鏈接:https://leetcode.com/problems/evaluate-division/ Equations are given in the format A / B = k, where A and B are

原创 c++在用set和multiset時遇到的一個bug

今天在寫一個程序時用到了set和multiset,因爲我需要讓其中的元素對降序排列,所以寫了一個functor,爲圖省事,我只比較了pair中首個元素如下: struct cmp { bool operator()(pair<i

原创 [leetcode] 415. Add Strings 解題報告

題目鏈接:https://leetcode.com/problems/add-strings/ Given two non-negative numbers num1 and num2 represented as string,

原创 [leetcode] 396. Rotate Function 解題報告

題目鏈接:https://leetcode.com/problems/rotate-function/ Given an array of integers A and let n to be its length. Assume