Skip to content

Instantly share code, notes, and snippets.

@goctave
goctave / 3.c
Created April 18, 2012 01:38
CareerCup 1.3
/************************************
O(n^2)的算法
*************************************/
#include <stdio.h>
#include <string.h>
void unique(char str[])
{
int len = strlen(str);
int i, j;
@goctave
goctave / 2.c
Created April 17, 2012 02:09
CareerCup 1.2
#include <stdio.h>
#include <string.h>
void exchange(char str[])
{
int len = strlen(str);
char *beg, *end;
char temp;
beg = str;
end = str + len - 1;
@goctave
goctave / 1.c
Created April 16, 2012 03:10
CareerCup 1.1
/**************************************************
1.最简单的方法就是两层循环,复杂度O(n^2)
2.使用排序,然后找重复。复杂度为O(nlgn)+O(n)=O(nlgn)
3.直接使用快排,在排序过程中,如果发现有重复的,立即结束递归
****************************************************/
#include <stdio.h>
#include <string.h>
int repeat;