![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
笔试题
lvjun93
这个作者很懒,什么都没留下…
展开
-
笔试题1
单机存储100亿大数据量的key-value数据,要就能够支持插入和查询操作,单条数据长度不变,平均1024字节,假设可用内存10G,磁盘空间不限,请设计一个存储查询模块,支持按照key来获取对应的value,设计目标以查询性能为先,尽量节约资源,查询可以理解为网名的检索行为。1)说明该设计方案和主要思路,以及优缺点 2)详细说明该思路下 查询和插入的操作流程 3)如果增加更新原创 2013-01-23 22:04:31 · 473 阅读 · 0 评论 -
归并排序
//将有二个有序数列a[first...mid]和a[mid...last]合并。 void mergearray(int a[], int first, int mid, int last, int temp[]) { int i = first, j = mid + 1; int m = mid, n = last; int k = 0;原创 2013-10-03 19:40:36 · 599 阅读 · 0 评论 -
堆排序(最小堆)
#include #include #include using namespace std;//------------------------堆排序--------------------------- inline void Swap(int &a, int &b) { int c = a; a = b; b = c; }原创 2013-10-03 15:18:30 · 710 阅读 · 0 评论 -
百度笔试写的两个题,还没写完。后续需要再完善一下。
1. 把一个链表,从中间拆开2. 后面一段颠倒过来3. 重新交叉成链ABCDEFABC DEFABC FEDAFBECD只要搞成最后这种形式就好了一个链表, 从中间分成两个子链表,第二个链表逆序。再把两个链表 并在一起haodeListNode* Deal(ListNode* L){}从中间拆分,需要求链表长度//逆置链表ListNode原创 2013-09-13 22:38:30 · 876 阅读 · 0 评论 -
求字符串的全排列python版本和c++版本
l=[]def All(str1): for i in str1: tmp=str1.replace(i,'') l.append(i) if len(tmp)>1: All(tmp) del l[-1] else: print ''.join(l)+t原创 2013-08-30 19:22:14 · 1742 阅读 · 0 评论 -
快速排序【递归版】
#include#include#include#include#includeusing namespace std; /**把数组分为两部分,轴pivot左边的部分都小于轴右边的部分**/template int partition(vector &vec,int low,int high){ Comparable pivot=vec[low]; //任选元素作为轴原创 2013-09-01 23:51:44 · 634 阅读 · 0 评论 -
快速排序(递归版本)+python版本
快速排序#include<iostream>using namespace std;void swap(int *a,int *b){ int temp=*a; *a=*b; *b=temp;}int partition2(int data[],int low,int high){ int i=low; int j=high; int privot...原创 2013-02-27 11:04:45 · 755 阅读 · 1 评论 -
[剑指offer]替换空格
E:\数据结构\剑指offer代码 何海涛\剑指offer代码\01ReplaceBlank\ReplaceBlank>a.exewww sogou comwww_=_sogou_=_com_=_#includeusing namespace std;void ReplaceBlank(char string1[]){ if (string1 == NULL原创 2013-06-26 01:09:19 · 1090 阅读 · 0 评论 -
求子数组最大乘积
#include #include #include using namespace std;int findMaxProduct(int *a,int n){ if ( a == NULL ) { cout<<"input illegal"<<endl; return 0; } if ( n == 1 ) return a[0]; in原创 2013-06-02 23:10:53 · 784 阅读 · 0 评论 -
二分查找(折半查找)
#includeusing namespace std;int Binary_Search(int *a,int n,int key){ int low,high,mid; low = 0; high =n; while (low <= high ) { mid = low + ( high - low )/2; if ( key < a[mid]) high = m原创 2013-03-12 11:53:32 · 649 阅读 · 0 评论 -
单链表逆置
#includeusing namespace std;struct Node{ int data; Node *next;};typedef struct Node Node;Node *reverseList(Node *head){ if(head==NULL||head->next==NULL) return head; Node *p1=head; Nod原创 2013-05-31 00:13:46 · 664 阅读 · 0 评论 -
2013年5月19日阿里巴巴笔试题-字符串逆序
#include#include using namespace std;void ReverseWord(char *p, char* q){ while(p < q) { char t = *p; *p++ = *q; *q-- = t; }}char* ReverseSentence(char* s){char *p = s;char*q = s;w原创 2013-05-23 00:38:45 · 1266 阅读 · 0 评论 -
2013腾讯第二届编程马拉松大赛-日期加减(小Q失恋日记)
#include#includeusing namespace std;class Date{public: Date (int, int ,int); friend Date & f_add (Date & , int); friend ostream & operator << (ostream & ,Date &);private: int year; int mont原创 2013-03-24 00:05:13 · 1501 阅读 · 0 评论 -
搜狗笔试题:07更新数组每个元素为其他每个元素的积
一个长度为n的数组a[0],a[1],...,a[n-1]。现在更新数组的每个元素,即a[0]变为a[1]到a[n-1]的积,a[1]变为a[0]和a[2]到a[n-1]的积,...,a[n-1]为a[0]到a[n-2]的积。程序要求:要求具有线性复杂度,不能使用除法运算符。思路是思想跟这个一样,用两个数组b、cb[i] = a[0] *... * a[i -原创 2013-03-18 18:11:27 · 805 阅读 · 0 评论 -
搜狗笔试题目:4*5的棋盘,在左下角的格子移动到右上角的格子,求有多少种移动方法
4*5的棋盘,在左下角的格子移动到右上角的格子,求有多少种移动方法。给定一个m*n的格子或棋盘,问从左下角走到右上角的走法总数(每次只能向右或向上移动一个方格边长的距离)解答:把棋盘看做二维坐标,设f(m,n)代表从坐标(0,0)到坐标(m,n)的移动方法,则f(m,n)=f(m-1,n)+f(m,n-1)初始为f(0,0)=0,f(0,1)原创 2013-03-18 15:01:49 · 1541 阅读 · 1 评论 -
16进制字符串转换为整型
#includeusing namespace std;int char_16_to_int(char * str){if (str == NULL) return 0;int sum = 0;while(*str != '\0'){ if (*str='0') sum = sum *16 + int(*str - '0'); if (*str='A') sum原创 2013-03-14 20:38:39 · 2128 阅读 · 0 评论 -
char* to double
#include#include using namespace std;double char_x_to_double(char* input_char){ int flag = 0; double sum = 0.0; double divisor = 10.0; char *p = input_char; if (*input_char) { //所有输入的数值都原创 2013-03-14 19:56:32 · 2309 阅读 · 0 评论 -
如何判断单链表是否存在环
给定一个单链表,只给出头指针h:1、如何判断是否存在环?2、如何知道环的长度?3、如何找出环的连接点在哪里?4、带环链表的长度是多少? 解法:1、对于问题1,使用追赶的方法,设定两个指针slow、fast,从头指针开始,每次分别前进1步、2步。如存在环,则两者相遇;如不存在环,fast遇到NULL退出。转载 2013-03-11 11:07:11 · 663 阅读 · 0 评论 -
数轴上从左到右有n个点、a[0] a[1]……a[n-1]给定一根长度为l绳子、求绳子最多覆盖其中几个点
算法描述:数组题算法描述:maxCover=1 , coverNum = 0 ,beginPos=0,endPos=1 分别表示最多覆盖点数,当前遍历开始节点和结束点1 如果a[endPos] – a[beginPos]== l 这个是时候正好覆盖coverNum = endPos–beginPos + 1; 右移动beginPos++;endPos++;2原创 2013-10-06 16:46:25 · 2609 阅读 · 0 评论