- 博客(125)
- 资源 (22)
- 收藏
- 关注
原创 5.4.7—二叉树的递归—Populating Next Right Pointers in Ea Node
描述Given a binary treestruct TreeLinkNode {int val;TreeLinkNode *left, *right, *next;TreeLinkNode(int x) : val(x), left(NULL), right(NULL), next(NULL) {}};Populate each next pointer to po
2017-08-16 23:22:45 290
原创 15.6—细节实现题—Multiply Strings
描述Given two numbers represented as strings, return multiplication of the numbers as a string.Note: e numbers can be arbitrarily large and are non-negative.#include#includeusing namespace st
2017-08-12 12:55:34 284
原创 15.5—细节实现题—Minimum Window Substring
描述Given a string S and a string T , find the minimum window in S which will contain all the charactersin T in complexity O(n).For example, S = ”ADOBECODEBANC”, T = ”ABC”Minimum window is ”BANC
2017-08-12 12:55:17 274
原创 15.4—细节实现题—Merge Intervals
描述Given a collection of intervals, merge all overlapping intervals.For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18]#include#include#includeusing namespace std;vec
2017-08-12 12:54:40 267
原创 15.3—细节实现题—Insert Interval
描述Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.E
2017-08-12 12:54:16 293
原创 15.2—细节实现题—Palindrome Number
描述Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integer to string,
2017-08-12 12:53:55 229
原创 15.1—细节实现题—Reverse Integer
描述Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321Have you thought about this?Here are some good questions to ask before coding. Bonus points for you
2017-08-12 12:53:40 276
原创 13.12—动态规划—Word Break
描述Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separatedsequence of one or more dictionary words.For example, givens = "leetcode",dict = ["le
2017-08-12 12:53:21 298
原创 13.11—动态规划—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 is a new string which is formed from the original string by deleting some(can be
2017-08-12 12:53:09 251
原创 13.10—动态规划—Decode Ways
描述A message containing leers from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total n
2017-08-12 12:52:20 249
原创 15.12—细节实现题—ZigZag Conversion
描述e string ”PAYPALISHIRING” is wrien in a zigzag paern on a given number of rows like this: (youmay want to display this paern in a fixed font for beer legibility)P A H NA P L S I I
2017-08-12 12:14:43 220
原创 13.9—动态规划—Edit Distance
描述Given two words word1 and word2, find the minimum number of steps required to convert word1 toword2. (each operation is counted as 1 step.)You have the following 3 operations permied on a wor
2017-08-11 23:48:04 215
原创 13.8—动态规划—Minimum Path Sum
描述Given a m × n grid filled with non-negative numbers, find a path from top le to boom right whichminimizes the sum of all numbers along its path.Note: You can only move either down or right a
2017-08-11 23:47:34 286
原创 13.6—动态规划—Interleaving String
描述Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example, Given: s1 = ”aabcc”, s2 = ”dbbca”,When s3 = ”aadbbcbcac”, return true.When s3 = ”aadbbbaccc”, return
2017-08-11 23:46:53 270
原创 13.5—动态规划—Best Time to Buy and Sell Sto III
描述Say you have an array for which the i-th element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note: You may
2017-08-11 23:46:42 345
原创 13.4—动态规划—Maximal Rectangle
描述Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing all ones andreturn its area.#include#include#includeusing namespace std;int mymax(int a, int b){
2017-08-11 23:46:26 472
原创 13.2—动态规划—Maximum Subarray
描述Find the contiguous subarray within an array (containing at least one number) which has the largest sum.#includeusing namespace std;bool flag = true;int MAxmumSubarray(int a[], int n){
2017-08-11 23:46:12 216
原创 13.1—动态规划—Triangle
描述Given a triangle, find the minimum path sum from top to boom. Each step you may move to adjacentnumbers on the row below.For example, given the following triangle[[2],[3,4],[6,5,7],
2017-08-11 23:45:57 286
原创 12.6—贪心法—Container With Most Water
描述Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). nvertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i,0). Find
2017-08-11 23:45:40 278
原创 12.5—贪心法—Longest Substring Without Repeating Characters
描述Given a string, find the length of the longest substring without repeating characters. For example, thelongest substring without repeating leers for ”abcabcbb” is ”abc”, which the length is 3.
2017-08-11 23:45:25 229
原创 12.4—贪心法—Best Time to Buy and Sell Sto II
描述Say you have an array for which the i-th element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like(ie, bu
2017-08-11 23:45:10 679
原创 12.3—贪心法—Best Time to Buy and Sell Sto
描述Say you have an array for which the i-th element is the price of a given stock on day i.If you were only permied to complete at most one transaction (ie, buy one and sell one share of thestoc
2017-08-10 12:20:16 304
原创 12.2—贪心法—Jump Game II
描述Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal i
2017-08-10 12:20:02 194
原创 12.1—贪心法—Jump Game
描述Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine i
2017-08-10 12:19:38 222
原创 11.2—分治法—Sqrt(x)
描述Implement int sqrt(int x).Compute and return the square root of x.#include#include#include#define eps 0.000001using namespace std;bool flag = true;vector Sqrt(double a){ if (a < -eps
2017-08-10 12:19:21 180
原创 11.1—分治法—Pow(x,n)
描述Implement pow(x, n).#include#includeusing namespace std;#define eps 0.0000001bool flag = true;double MyPow(double x, int n){ if (n == 0) { if (abs(x) >= eps) return 1; else {
2017-08-10 12:19:09 292
原创 8.6—暴力枚举法—Letter Combinations of a Phone Number
描述Given a digit string, return all possible leer combinations that the number could represent.A mapping of digit to leers (just like on the telephone buons) is given below.Input:Digit string
2017-08-10 12:18:45 289
原创 8.5—暴力枚举法—Combinations
描述Given two integers n and k, return all possible combinations of k numbers out of 1...n.For example, If n = 4 and k = 2, a solution is:[[2,4],[3,4],[2,3],[1,2],[1,3],[1,4],]#i
2017-08-10 12:18:25 266
原创 8.4—暴力枚举法—Permutations II
描述Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example, [1,1,2] have the following unique permutations: [1,1,2], [1,2,1], and [2,1,1].
2017-08-10 12:17:23 213
原创 8.3—暴力枚举法—Permutations
描述Given a collection of numbers, return all possible permutations.For example, [1,2,3] have the following permutations: [1,2,3], [1,3,2], [2,1,3], [2,3,1],[3,1,2], and [3,2,1].#include#incl
2017-08-10 12:16:58 239
原创 8.2—暴力枚举法—Subsets II
描述Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order. e solution set must not contain duplica
2017-08-10 12:16:31 187
原创 8.1—暴力枚举法—Subsets
描述Given a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For example,
2017-08-09 10:18:28 235
原创 7.3—查找—Sear a 2D Matrix
描述Write an efficient algorithm that searches for a value in an m×n matrix. is matrix has the followingproperties:Integers in each row are sorted from le to right.The first integer of each ro
2017-08-09 10:18:12 158
原创 7.2—查找—Sear Insert Position
描述Given a sorted array and a target value, return the index if the target is found. If not, return the indexwhere it would be if it were inserted in order.You may assume no duplicates in the arr
2017-08-09 10:18:01 186
原创 7.1—查找—Sear for a Range
描述Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm’s runtime complexity must be in the order of O(log n).If the target is not found
2017-08-09 10:17:36 202
原创 6.7—排序—Sort Colors
描述Given an array with n objects colored red, white or blue, sort them so that objects of the same colorare adjacent, with the colors in the order red, white and blue.Here, we will use the intege
2017-08-09 10:17:14 176
原创 6.6—排序—First Missing Positive
描述Given an unsorted integer array, find the first missing positive integer.For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant s
2017-08-09 10:17:04 204
原创 6.5—排序—Sort List
描述Sort a linked list in O(nlogn) time using constant space complexity.#include#include;using namespace std;struct node{ int data; node *next;};node *CreateNode(int a[], int n){ if (n <
2017-08-09 10:16:53 172
原创 6.4—排序—Insertion Sort List
描述Sort a linked list using insertion sort.#include#include;using namespace std;struct node{ int data; node *next;};class mylist{public: node *head;public: mylist() { head = new n
2017-08-09 10:16:40 168
原创 6.3—排序—Merge k Sorted Lists
描述Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.#include#include;using namespace std;struct node{ int data; node *next;};class myl
2017-08-09 10:16:30 178
后端基础系列教材
2019-03-16
前端基础系列教材
2019-03-16
前端基础—angular+ES6+HTTP+JS+Jquery+JavaWeb
2019-03-16
Python学习推荐书籍
2017-11-08
《STL源码剖析》&《深入探索C++对象模型》
2017-05-09
《Effective C++(中文版)》&《Essential C++(中文版)》
2017-05-09
高质量 C++&C 编程指南
2017-05-09
数据结构与算法分析_李春葆(课件+源码)
2017-05-09
LeetCode源码
2017-05-09
LeetCode题解
2017-05-09
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人