码迷,mamicode.com
首页 >  
搜索关键字:in-place    ( 1961个结果
【LeetCode OJ】Remove Element
题目:Given an array and a value, remove all instances of that value in place and return the new length. The order of elements can be changed. It doesn't matter what you leave beyond the new length. ...
分类:其他好文   时间:2015-04-07 09:47:14    阅读次数:130
【LeetCode OJ】Remove Element
题目:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't ...
分类:其他好文   时间:2015-04-07 09:41:55    阅读次数:134
[LeetCode]Set Matrix Zeroes
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. in place,主要是感觉比较麻烦,其实就是利用第一行和第一列保存该行列是否需要变0,再用两个变量表示第一行和第一列是否需要变0 代码: public class Solution { publi...
分类:其他好文   时间:2015-04-06 15:43:04    阅读次数:109
[LeetCode]Rotate Image
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? 思路1:直接开辟一个数组,然后按照对应关系复制即可,空间和时间复杂度o(N*N) 代码1: ...
分类:其他好文   时间:2015-04-06 14:16:43    阅读次数:124
LeetCode26/27/80 Remove Duplicates from Sorted Array I and II/Remove Element**
题目: Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in pla...
分类:其他好文   时间:2015-04-05 22:01:48    阅读次数:178
Reverse Linked List II——LeetCode
Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.No...
分类:其他好文   时间:2015-04-05 11:54:52    阅读次数:128
hdu 2962 Trucking 最短路+二分。。Dijkstra+SPFA两种算法实现。
Problem Description A certain local trucking company would like to transport some goods on a cargo truck from one place to another. It is desirable to transport as much goods as possible each trip. Unfortunately, one cannot always use the roads in the shor...
分类:编程语言   时间:2015-04-05 09:16:13    阅读次数:208
LeetCode Set Matrix Zeroes
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. click to show follow up. Follow up: Did you use extra space? A straight forward solution using O(m...
分类:其他好文   时间:2015-04-04 23:47:00    阅读次数:163
Reverse Linked List II--LeetCode
题目: Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note: Given m, ...
分类:其他好文   时间:2015-04-04 12:20:09    阅读次数:138
【leetcode刷题笔记】Rotate Image
You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?题解:如果要原地算法的话,就只能用交换...
分类:其他好文   时间:2015-04-03 16:52:32    阅读次数:129
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!