自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

New coder, Step further

winter is coming...

  • 博客(168)
  • 收藏
  • 关注

转载 907. Sum of Subarray Minimums

leetcode, 单调栈,monotonic stack, stack, array, 数组

2022-06-13 16:16:37 140

转载 Callback in C++

Callback in C++非原创,转载自:https://stackoverflow.com/questions/2298242/callback-functions-in-c文章目录Callback in C++非原创,转载自:https://stackoverflow.com/questions/2298242/callback-functions-in-c@[TOC](文章目录)1. What are callables in C++(11)2. Function Pointer2.1 n

2022-03-21 14:54:56 148

原创 138. Copy List with Random Pointer

A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.这题的难点在于如何合理的复制random指针这个属性。当我们先不考虑ra...

2019-02-10 16:40:59 281

原创 110. Balanced Binary Tree

Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in which the depth of the two subtrees of every node never differ...

2019-02-05 17:48:24 133

原创 200. Number of Islands

Given a 2d grid map of '1’s (land) and '0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume...

2019-02-01 17:56:31 389

原创 310. Minimum Height Trees

For an undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called min...

2019-01-31 17:37:14 123

原创 Graph representation and definition

representation:adjacency matrix好处是对边或者权重的queries 都是O(1), remove or add an edge也是O(1). 坏处是对点不友好,增加一个点的操作是O(V^2). 而且本身存储太space consuming,同样是点的平方复杂度。导致在sparse matrix里不适用。Adjacency Matrix is a 2D ar...

2019-01-28 08:33:22 266

原创 241. Different Ways to Add Parentheses

Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *.Example 1:Inpu...

2019-01-22 16:26:07 145 1

原创 687. Longest Univalue Path 二刷

Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the root.Note: The length of path between two nodes is r...

2019-01-14 16:09:21 153

原创 437. Path Sum III 二刷

You are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a given value. The path does not need to start or end at the root or a leaf, but it must ...

2019-01-14 09:47:51 103

原创 297. Serialize and Deserialize Binary Tree

这题是更general一些的二叉树serialization和deserialization,没有了BST里面的大小关系可以依赖,所以需要额外的存储,一种思路是生成两个序列,比如preorder和inorder,一种是存储NULL节点,是得我们可以按顺序或者按数量来以此恢复。因为NULL节点的大小普遍小于真实的node value,或者说存储更方便(任意指定符合即可),所以后者是我们主要使用的方法...

2019-01-07 10:43:06 114

原创 449. Serialize and Deserialize BST

经典题目之一,二叉树的遍历和深度广度优先都相关。一般的binary tree的serialization 和 deserialization 相对麻烦一点,因为没有多余特征可以利用。但binary search tree就有重要的大小关系可以利用。或者说,binary tree的恢复,往往需要preorder 和inorder两个序列,或者postorder和inorder。但是binary s...

2019-01-07 10:06:54 163

原创 DP intro: Rod cutting problem

Given a rod of length n inches and an array of prices that contains prices of all pieces of size smaller than n. Determine the maximum value obtainable by cutting up the rod and selling the pieces. Fo...

2018-12-24 15:47:51 236

原创 About the reverse_iterator

reverse_iterator: 反向迭代器A copy of the original iterator (the base iterator) is kept internally and used to reflect the operations performed on the reverse_iterator: whenever the reverse_iterator is in...

2018-12-05 16:07:16 95

原创 Backtracking

需要注意的点:是否需要排序,一般有重复需要排序;isVisited 可以用来避免重复选择,比如permutationlastVisited可以用在有重复数字的时候避免结果重复不同题目区分点在于,递归中的结束条件,什么时候将tempres 放入res中,如何避免重复,每次选择的范围,选择的起始点。例题参考如下:Subsets : https://leetcode.com/proble...

2018-11-16 16:55:42 154

原创 Invoke a function in computer

函数调用在计算机中的几种参数传递的方式

2017-12-19 12:11:49 234

原创 23. Merge k Sorted Lists

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.这是一道不难,却很值得思考的题目。包含了很多常见的算法思想。

2017-12-19 06:14:49 408

原创 407. Trapping Rain Water II

Given an m x n matrix of positive integers representing the height of each unit cell in a 2D elevation map, compute the volume of water it is able to trap after raining.Note: Both m and n are less tha

2017-12-11 12:26:12 197

原创 42. Trapping Rain Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1], retu

2017-12-10 11:49:34 175

原创 173. Binary Search Tree Iterator

mplement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Note: next() and hasNe

2017-12-08 11:12:16 123

原创 155. Min Stack

常数时间获取栈的最小值

2017-12-08 10:20:33 136

原创 738. Monotone Increasing Digits

greedy algorithm

2017-12-06 05:02:25 152

原创 713. Subarray Product Less Than K

sliding window

2017-12-06 00:42:12 162

原创 685. Redundant Connection II

leetcode 685 redundant connection II有向图找环路invalid tree 修复

2017-12-04 05:37:42 520

原创 684. Redundant Connection

连通分量,无向图找环。

2017-12-03 12:47:09 192

转载 Union-find and Disjoint Set Union

Disjoint Set Union (DSU) is a data structure that keeps track of a set of elements partitioned into a number of disjoint (non-overlapping) subsets. A union-find algorithm is an algorithm that performs

2017-12-03 12:31:45 320

原创 737. Sentence Similarity II

leetcode 737 sentence similarity II 递归写法和非递归写法

2017-12-01 11:25:58 334

原创 734. Sentence Similarity

Given two sentences words1, words2 (each represented as an array of strings), and a list of similar word pairs pairs, determine if two sentences are similar.For example, “great acting skills” and “fine

2017-11-30 13:36:04 427

原创 733. Flood Fill

An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535).Given a coordinate (sr, sc) representing the starting pixel (row and column)

2017-11-30 12:35:00 634

原创 732. My Calendar III

leetcode 732. My calendar III

2017-11-29 03:59:44 330

原创 [124]. Binary Tree Maximum Path Sum, [543]. Diameter of Binary Tree

[124]. Binary Tree Maximum Path Sum [543]. Diameter of Binary Tree

2017-11-21 09:44:43 141

原创 129. Sum Root to Leaf Numbers

leetcode 129 sum root to leaf numbers

2017-11-21 05:15:50 137

原创 [437]. Path Sum III,[687]. Longest Univalue Path

[437]. Path Sum III [687]. Longest Univalue Path

2017-11-21 02:54:19 142

原创 [112]. Path Sum,[113]. Path Sum II

[112]. Path Sum [113]. Path Sum II

2017-11-21 02:21:29 142

原创 leetcode: 729. My Calendar I,731. My Calendar II

leetcode 729 My Calendar I, 731 My Calendar II

2017-11-21 00:43:19 344

原创 334. Increasing Triplet Subsequence

是否有符合递增规律的三个数

2017-11-16 08:15:13 139

原创 673. Number of Longest Increasing Subsequence

leetcode 673并列两dynamic programming

2017-11-16 08:11:28 124

原创 300. Longest Increasing Subsequence

O(n^2) dynamic programming

2017-11-16 08:00:31 129

原创 718. Maximum Length of Repeated Subarray

leetcode, 718dynamic programming

2017-11-15 10:31:02 117

原创 209. Minimum Size Subarray Sum

binary searchtwo pointers

2017-11-15 06:41:39 127

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除