problem: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 doe...
分类:
其他好文 时间:
2014-10-20 19:20:57
阅读次数:
241
// Playground - noun: a place where people can play
import UIKit
//------------------------------------------------------------------------------
// 1. for
// 传统的for循环方式在swift中同样支持
var num = 0
for(v...
分类:
编程语言 时间:
2014-10-20 15:14:51
阅读次数:
221
[leetcode]Given a binary tree, flatten it to a linked list in-place....
分类:
其他好文 时间:
2014-10-17 12:03:13
阅读次数:
119
ConstraintsTime Limit: 1 secs, Memory Limit: 64 MBDescriptionYou all are familiar with the famous 8-queens problem which asks you to place 8 queens on...
分类:
其他好文 时间:
2014-10-17 02:53:23
阅读次数:
417
Given a m x n matrix,
if an element is 0, set its entire row and column to 0. Do it in place.
class Solution {
public:
void setZeroes(std::vector > &matrix) {
int m = matrix.size();
...
分类:
其他好文 时间:
2014-10-13 18:45:17
阅读次数:
190
Building Fire Stations
Time Limit: 5 Seconds Memory Limit: 131072 KB Special Judge
Marjar University is a beautiful and peaceful place. There are N buildings and N - 1 bidirectional ro...
分类:
其他好文 时间:
2014-10-13 12:21:25
阅读次数:
123
This is a very good linked list question, as there are tricky cases you have to consider, and getting them all right in one place is harder than it lo...
分类:
其他好文 时间:
2014-10-12 05:54:07
阅读次数:
161
题目链接
题意:放最少的士兵去监视所有的道路, 但士兵不可相邻,符合的话,就输出最少的士兵数,否则输出-1
思路:其实就是二分图染色,即黑白染色,然后选择黑白染色最少的那个颜色累加,但要注意可能有多个连通块,只要有一个连通块不符合的话,就不符合。
代码:
#include
#include
#include
#include
#include
using...
分类:
其他好文 时间:
2014-10-11 22:37:06
阅读次数:
297
Flatten Binary Tree to Linked List
Total Accepted: 25034 Total
Submissions: 88947My Submissions
Given a binary tree, flatten it to a linked list in-place.
For example,
Given
1...
分类:
其他好文 时间:
2014-10-11 20:54:36
阅读次数:
214
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.
S...
分类:
其他好文 时间:
2014-10-11 18:55:56
阅读次数:
185