摘要:
问题描述Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after rainin... 阅读全文
摘要:
问题描述You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?解决思路难点在于,如何... 阅读全文
摘要:
问题描述Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order r... 阅读全文
摘要:
Tree Traversal树的遍历方式有前序、中序和后序(DFS),以及层次遍历(BFS)。1.递归;2.非递归,辅助栈。实现方式见:http://www.cnblogs.com/harrygogo/p/4599097.html 阅读全文
摘要:
问题描述Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators... 阅读全文
摘要:
最短路算法的求解,都是基于下列事实:节点A到节点B的最短路径有两种可能,一种是直接从A到B,另一种是从A经过若干个节点到B。Dijkstra算法:单源最短路径问题,时间复杂度为O(n^2);不能处理权值为负的边;Floyd算法:求解图中任意节点之间的最短路径,时间复杂度为O(n^3);可以处理任意数... 阅读全文
摘要:
问题描述Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longes... 阅读全文
摘要:
问题描述Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.F... 阅读全文
摘要:
PCAPCA全称为Principal Components Analysis,即主成分分析,是一种常用的降维方法。PCA将原来众多具有一定相关性的指标重新组合成一组新的相互无关的综合指标来代替原来的全部指标。将n维特征映射到k维全新的正交特征上。PCA的实现一般有两种:特征值分解和SVD.原理对原始... 阅读全文
摘要:
问题描述Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.解决思路难点在于如何不使用辅助空间。一个巧妙的想法是,1. 使用两个标记变量,row0_has_zeros和col... 阅读全文