码迷,mamicode.com
首页 >  
搜索关键字:matrix swapping ii    ( 10718个结果
UVA 11992 - Fast Matrix Operations
Fast Matrix OperationsThere is a matrix containing at most 106elements divided into r rows and c columns. Each element has a location (x,y) where 10)2...
分类:其他好文   时间:2014-05-30 03:31:23    阅读次数:516
【LeetCode】Rotate Image
Rotate ImageYou 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?最简...
分类:其他好文   时间:2014-05-29 23:02:38    阅读次数:254
Leetcode: Best Time to Buy and Sell Stock II
一次过,思路是:最大收益可以由所有上升序列差价叠加中获得 1 public class Solution { 2 public int maxProfit(int[] prices) { 3 int profit = 0; 4 if (prices.lengt...
分类:其他好文   时间:2014-05-29 20:43:33    阅读次数:254
Coursera algorithm II PA4
题意:所给数据中是否有负环? 没有负环的图中所有路径中最短的值思路:1. bellmanford 判断负环2.flodyWarshall 求所有定点的最短路径细节:1. bellmanford 算法时间复杂度为 o(n^3), 因为图的使用邻接矩阵存储的, 使用邻接表代码会容易理解些, 引用 wik...
分类:其他好文   时间:2014-05-29 20:41:30    阅读次数:237
[leetcode]_Path Sum I && II
都是考查DFS。经典回溯算法,问题在于我对该类型的代码不熟悉,目前以参考别人的代码,然后加上自己的实现为主,通过类似的题目加强理解。一、给定一棵二叉树,判断是否存在从root到leaf的路径和等于给定值sum,存在返回true,否则返回false。思路:DFS。代码: 1 private b...
分类:其他好文   时间:2014-05-28 23:51:25    阅读次数:389
LeetCode Spiral Matrix
class Solution { public: vector spiralOrder(vector > &matrix) { vector ret; int cols = 0; ...
分类:其他好文   时间:2014-05-28 14:38:02    阅读次数:236
[Java]_函数传参的疑惑与思考
问题来源于leetcode上的两道题 Path Sum I && II,分别写了两个dfs。1 void dfs(TreeNode node , int sum , ArrayList curPath)2 void dfs(TreeNode node , int sum , boolean ifEx...
分类:编程语言   时间:2014-05-28 13:11:14    阅读次数:361
LeetCode Spiral Matrix II
class Solution { public: vector > generateMatrix(int n) { vector > matrix; if (n (n, 0)); }...
分类:其他好文   时间:2014-05-28 09:42:14    阅读次数:233
[leetcode]_Best Time to Buy and Sell Stock I && II
一个系列三道题,我都不会做,google之答案。过了两道,第三道看不懂,放置,稍后继续。一、Best Time to Buy and Sell Stock I题目:一个数组表示一支股票的价格变换。要求只买卖一次,获得最大收益。思路:一开始我认为是寻找最大、最小值,但由于最大值不一定总是出现在最小值的...
分类:其他好文   时间:2014-05-28 01:21:52    阅读次数:262
LeetCode122: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 co...
分类:其他好文   时间:2014-05-28 00:53:26    阅读次数:338
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!