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 fo...
分类:
其他好文 时间:
2015-08-25 16:53:27
阅读次数:
159
冒泡排序是最常用的小型数据排序方式,下面是用C语言实现的,及其两种优化方式。
第一种优化方式是设置一个标记位来标记是否发生了交换,如果没有发生交换就提前结束;
第二种优化方式是记录最后放生交换的位置,作为下一趟比较结束的位置。
#include
/*
* 打印数组
* */
void printArray(int arr[], int n) {
int i = 0;
fo...
分类:
编程语言 时间:
2015-08-21 23:20:51
阅读次数:
202
#include
#include
using namespace std;
//数组右移m位,左边补0;
//如:1 2 3
// 4 5 6
// 7 8 9
//右移动2位的结果是:
// 0 0 1
// 0 0 4
// 0 0 7
void Grial(int(*a)[4], int n,int m)
{ fo...
分类:
编程语言 时间:
2015-08-21 21:29:22
阅读次数:
146
UIFontDescriptor *bodyFontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleBody]; self.textView.font = [UIFont fo...
分类:
移动开发 时间:
2015-08-20 18:30:04
阅读次数:
136
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo...
分类:
其他好文 时间:
2015-08-20 10:14:39
阅读次数:
94
测试代码为: public?static?void?main(String[]?args)?{
List<String>?strList?=?new?ArrayList<String>();
strList.add("1");
strList.add("2");
strList.add("3");
strList.add("4");
fo...
分类:
编程语言 时间:
2015-08-19 17:57:08
阅读次数:
141
oracle无效且未通过重新验证代码如下:SQL code如下:--创建中国地图表createtablechina_address(idnumbernotnullprimarykey,address_namevarchar2(30)notnull,parent_address_idnumber,fo...
分类:
数据库 时间:
2015-08-19 10:58:44
阅读次数:
174
public static List ToList(DataTable dt){ List> list = new List>(); foreach (DataRow dr in dt.Rows) { Dictionary result = new Dictionary(); fo...
分类:
其他好文 时间:
2015-08-19 10:58:39
阅读次数:
129
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo...
分类:
其他好文 时间:
2015-08-18 18:02:56
阅读次数:
198
字典树,题目并无难度,关键是如何输入空格推出循环
用getline输入C++的字符串要加上 #include..........
这题G++交会无限超内存
#include
#include
#include
using namespace std;
string str;
struct stu
{
int m;
stu *a[26];
stu()
{
m=0;
fo...
分类:
其他好文 时间:
2015-08-16 18:24:38
阅读次数:
91