摘要:
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 阅读全文
摘要:
Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top 阅读全文
摘要:
本文是看完july博客完美洗牌之后的个人笔记。 题目:把a1,a2,a3,a4,...,an-1 an,b1,b2,b3,...,bn-1,bn变成a1,b1,a2,b1,...,an,bn.要求时间复杂度为O(n),空间复杂度为O(1). 1.位置置换算法:b是新开的一个数组,但是时间复杂度为O( 阅读全文
摘要:
具体参考:http://articles.leetcode.com/longest-palindromic-substring-part-ii 这是个利用枚举中心节点以及能到达的最右边界来跳过一些无谓的比较的算法。 核心思想就是: 假设我们用C表示当前回文串的中心位置,P[i]记录当前的最大半径,R 阅读全文
摘要:
Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution sti 阅读全文
摘要:
Given a binary tree Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL 阅读全文
摘要:
You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose o 阅读全文
摘要:
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the lo 阅读全文
摘要:
Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero. To make pro 阅读全文
摘要:
int *p[4] 由于[]的优先级比*高,所以此处相当于int *(p[4]),即指针数组,定义了4个指向int型的指针。 int (*p)[4],这是数组指针,指定义了一个指针,他指向了数组。 一个类有基类、内部有一个其他类的成员对象,构造函数的执行顺序是怎样的? 首先调用基类的构造函数,在派生 阅读全文