原创 leetcode001:Two Sum

題目描述 Given an array of integers, find two numbers such that they add up to a specific target number. The function t

原创 leetcode011:Container With Most Water

問題描述 Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical l

原创 leetcode037:Sudoku Solver

問題描述 Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by the character

原创 leetcode042:Trapping Rain Water

問題描述 Trapping Rain Water  Given n non-negative integers representing an elevation map where the width of each bar is

原创 leetcode002:Add Two Numbers

題目 You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and

原创 虛函數與虛繼承尋蹤

虛函數與虛繼承尋蹤 c++ 繼承 虛函數 這篇文章對於虛函數和虛繼承有比較深入的分析,重新排版後分享給大家學習。 封裝、繼承、多態是面嚮對象語言的三大特性,熟悉C++的人對此應該不會有太多異議。C語言提供的struct,頂多算得上對數據

原创 數據結構基礎筆記(三)【嚴蔚敏】

(一)內部排序 所有的記錄都能存放在內存中進行排序,稱爲內部排序; 對內部排序地而言,其基本操作有兩種: ◆ 比較兩個關鍵字的大小;<必不可少> ◆ 存儲位置的移動:從一個位置移到另一個位置。<不一定:鏈式存儲> 【1】插入排序

原创 KMP算法解決字符串匹配

該算法由D.E.Knuth ,J.H.Morris和 V.R.Pratt提出,用於解決字符串匹配問題。 思想: 設目標串(主串)爲s,模式串爲t ,並設i指針和j指針分別指示目標串和模式串中正待比較的字符,設i和j的初值均爲0。若有s[i

原创 數據結構基礎筆記(一)【嚴蔚敏】

廣義表 廣義表相關概念: ◆ a1(表中第一個元素)稱爲表頭; ◆ 其餘元素組成的子表稱爲表尾;(a2,a3,…,an) ◆ 廣義表中所包含的元素(包括原子和子表)的個數稱爲表的長度。 ◆ 廣義表中括號的最大層數稱爲表深 (度)

原创 最長公共子序列&最長公共子串

#include<iostream> #include<string> #include<algorithm> #include<vector> using namespace std; /***********************

原创 最長遞增子序列

#include<iostream> #include<string> #include<algorithm> using namespace std; /****************************************

原创 範圍最小值問題(Range Minimum Query,RMQ)

問題描述 給定一個n個元素的序列{A1,A2,……,An},在要求的區間Query(L,R)內找到最小值:min{AL,AL+1,……,AR}。hiho16 算法描述 在這裏介紹最常用的Tarjan的Sparse-Table算法,它的預處

原创 leetcode263_264:Ugly Number & Ugly Number II

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

原创 數據結構基礎筆記(二)【嚴蔚敏】

動態存儲管理:夥伴系統 分配內存算法思想: 當程序提出大小爲n的內存分配請求時,首先在可利用表中查找大小與n相匹配的子表. ◆ 若存在2^(k-1)< n ≤ 2^k-1的空閒子表結點:則將子表中的任意一個結點分配之; ◆ 若不存在

原创 2016校招華爲機試題目回憶1

題目一:根據指定的分隔符分隔字符串,並輸出指定的段 描述 根據指定的分隔符分隔字符串,並輸出指定的段。如果指定的段超過分隔的段數,輸出:NULL 舉例: AAA?BBB?CCC??2 字符串爲:AAA?BBB?CCC? 分隔符爲:?