数组
文章平均质量分 50
macans
止步就是退步
展开
-
LeetCode----best-time-to-buy-and-sell-stock-ii
题目描述 Say you have an array for which the ith 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原创 2016-10-09 22:09:03 · 345 阅读 · 0 评论 -
LeetCode----best-time-to-buy-and-sell-stock
题目描述 Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one shar原创 2016-10-09 19:40:40 · 315 阅读 · 0 评论 -
LeetCode----surrounded-regions
题目描述 Given a 2D board containing'X'and'O', capture all regions surrounded by'X'. A region is captured by flipping all'O's into'X's in that surrounded region . For example, X X X X X原创 2016-10-13 09:23:59 · 407 阅读 · 0 评论 -
max-points-on-a-line
求二维共线的最多点数原创 2016-09-22 21:19:02 · 374 阅读 · 0 评论 -
LeetCode----best-time-to-buy-and-sell-stock-iii
题目描述 Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at mosttwo transactions.原创 2016-10-13 12:29:54 · 555 阅读 · 0 评论 -
清除行列
题目描述 请编写一个算法,若N阶方阵中某个元素为0,则将其所在的行与列清零。 给定一个N阶方阵int[][](C++中为vector)mat和矩阵的阶数n,请返回完成操作后的int[][]方阵(C++中为vector),保证n小于等于300,矩阵中的元素为int范围内。 测试样例: [[1,2,3],[0,1,2],[0,0,1]], 3 返回:[[0,0,3],[0,0原创 2016-10-20 19:30:22 · 496 阅读 · 0 评论 -
像素翻转
题目描述 有一副由NxN矩阵表示的图像,这里每个像素用一个int表示,请编写一个算法,在不占用额外内存空间的情况下(即不使用缓存矩阵),将图像顺时针旋转90度。 给定一个NxN的矩阵,和矩阵的阶数N,请返回旋转后的NxN矩阵,保证N小于等于500,图像元素小于等于256。 测试样例: [[1,2,3],[4,5,6],[7,8,9]],3 返回:[[7,4,1],[8,5原创 2016-10-21 10:03:10 · 264 阅读 · 0 评论