Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.
题目解析:
将一个矩阵中0所在行,以及所在列都置为0.
方法一:
将矩阵中,0的行和列的下标保存下来,并且分别去除里面重复的下标,之后遍历矩阵,将记录的这些行和列均置为0.代码如下:
cla...
分类:
其他好文 时间:
2015-06-13 09:52:50
阅读次数:
110
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 mat...
分类:
其他好文 时间:
2015-06-12 00:38:54
阅读次数:
113
Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new lengt...
分类:
其他好文 时间:
2015-06-11 18:55:25
阅读次数:
113
No.27 Remove ElementGiven an array and a value, remove all instances of that value in place and return the new length.The order of elements can be cha...
分类:
其他好文 时间:
2015-06-11 18:24:51
阅读次数:
104
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 beyo...
分类:
其他好文 时间:
2015-06-11 14:44:37
阅读次数:
132
#include #include #define MAXN 2000using namespace std;struct node{ char c; int place;};node _node[MAXN];int index;void fun_q(int place);int len;strin...
分类:
其他好文 时间:
2015-06-11 12:46:15
阅读次数:
125
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, n satisfy the following co...
分类:
其他好文 时间:
2015-06-11 09:33:31
阅读次数:
141
Remove Duplicates from Sorted Array
题目:
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...
分类:
其他好文 时间:
2015-06-10 19:32:23
阅读次数:
133
Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes’ values.For example,
Given {1,2,3,4}, reorder it to {1,4,2,3}...
分类:
其他好文 时间:
2015-06-10 19:26:11
阅读次数:
152
#include#include#include#define MAXN 30005using namespace std;int place[MAXN];int up[MAXN];int pre[MAXN];void init(){ int i; for(i = 0; i >c; ...
分类:
其他好文 时间:
2015-06-10 17:15:21
阅读次数:
105