原创 【LeetCode】290. Word Pattern

題目 Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such tha

原创 [Leetcode]287. Find the Duplicate Number簡單解法及解釋 雙指針複雜度O(n)

題目鏈接:Find the Duplicate Number Given an array nums containing n + 1 integers where each integer is between 1 and n

原创 OpenCV 數字驗證碼識別

更新後代碼下載鏈接在此!!! 點我下載 本文針對OpenCv入門人士,因爲我也不是專門做圖像的,只是爲了完成一次模式識別的小作業。 主要完成的功能就是自動識別圖片中的數字,圖片包括正常圖片,有劃痕圖像和有噪點圖像。分別如下

原创 【LeetCode】triangle求最小和路徑

今天閒來無事,做了三道leetcode水題,怒更兩發博客,也挺不錯。今天更新的兩篇都是dp解法的簡單題。 題目要求如下。 Given a triangle, find the minimum path sum from to

原创 Linux vi/vim 多行註釋

多行註釋: 進入命令行模式,按ctrl + v進入 visual block模式,然後按j, 或者k選中多行,把需要註釋的行標記起來 按大寫字母I,再插入註釋符,例如// 按esc鍵就會全部註釋了 取消多行註釋: 進入命令

原创 【LeetCode】95. Unique Binary Search Trees II

題目 Given n, generate all structurally unique BST’s (binary search trees) that store values 1…n. For example, Given

原创 【LeetCode】Best Time to Buy and Sell Stock IV 動態規劃dp解法(C++)

乍看此題有難度,實則解法有規律。 依然是動規來做,仔細分析後,我自然而然地聯想到了求最大連續數之和的問題。最大連續數之和題意是給你一個無序數組,正數負數都有,讓求出連續數字之和最大是多少。當然有很多種方法,複雜度比較低的還是dp

原创 【LeetCode】234. Palindrome Linked List

題目 Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time and O(1) s

原创 【LeetCode】72. Edit Distance

題目 Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each oper

原创 【LeetCode】115. Distinct Subsequences

題目 Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string

原创 【LeetCode】330. Patching Array

題目 Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any numbe

原创 【LeetCode】55. Jump Game

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

原创 【LeetCode】16. 3Sum Closest

題目 Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target.

原创 【LeetCode】264. Ugly Number II

題目 Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include

原创 getline和cin.getline

C++中有兩個getline函數,這兩個函數分別定義在不同的頭文件中。 1.getline()是定義在中的一個行數,用於輸入一行string,以enter結束。 函數原型:getline(cin,str); cin:istre