![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
inter
文章平均质量分 82
mandagod
这个作者很懒,什么都没留下…
展开
-
面试的时候的一些记录 - 不断更新
学长们的求职血泪史(C/C++/JAVA) http://blog.csdn.net/huomanqingying/article/details/12876759菜鸟用careercup书和leetcode准备的一点体会 http://blog.sina.com.cn/s/blog_631d3a630101mg9t.html不是技术牛人,如何拿到国内IT巨头的Offer http://blo原创 2015-07-29 11:23:46 · 607 阅读 · 0 评论 -
string - memcpy源码
//// main.cpp// AUTO_PRO//// Created by yanzhengqing on 12-12-11.// Copyright (c) 2012年 yanzhengqing. All rights reserved.//#include <iostream>using namespace std;#ifdef _MSC_VER#pragma function(原创 2016-08-27 11:15:19 · 694 阅读 · 0 评论 -
排序算法集合 - 4
7. 基数排序 Radix Sort基数排序的执行时间为O(kn)。技术排序是个整数(或其他一些数据类型)排序算法,充分利用整数的位数有限这个前提。使用基数排序时,我们会迭代访问数字的每一位,按各个位对这些数字进行分组,这样,个位为0的数字就会分在同一组里面。然后再按十位进行分组,如此反复执行同样的过程,逐级按更高位进行排序,直到最后整个数组变为有序的数组。其他比较排序算法的平均执行时间不会由于O(原创 2016-09-04 16:00:14 · 368 阅读 · 0 评论 -
约瑟夫环问题的简单解法(数学公式法)
关于约瑟夫环问题,无论是用链表实现还是用数组实现都有一个共同点:要模拟整个游戏过程,不仅程序写起来比较烦,而且时间复杂度高达O(nm),当n,m非常大(例如上百万,上千万)的时候,几乎是没有办法在短时间内出结果的。我们注意到原问题仅仅是要求出最后的胜利者的序号,而不是要读者模拟整个过程。因此如果要追求效率,就要打破常规,实施一点数学策略。为了讨论方便,先把问题稍微改变一下,并不影响原意:转载 2017-04-04 14:29:52 · 1684 阅读 · 0 评论 -
排序算法集合 -3
5. 插入排序 Insertion Sort插入排序最好的运行时间是O(n),已经排序好了情况下,平均情况最情况都是O(n2),所以处理随机的未排序数据时并不是好的算法。通过将每个新元素与已经排序好的元素做比较,并将其插入到正确的位置来建立一个排序的数组,就像玩扑克一样,拿到新的牌放入到已经排序好的中间。插入排序是稳定的原地排序算法,特别适合对小的数据集合进行排序,通常作为其他更复杂的排序算法的构原创 2016-09-04 14:51:09 · 487 阅读 · 0 评论 -
LintCode 整数排序
class Solution {public: /* * @param A: an integer array * @return: */ void sortIntegers(vector &A) { // write your code here //bubleSort(A); //selectio原创 2017-09-11 23:03:17 · 327 阅读 · 0 评论 -
strcat, strcpy, strlen, strcmp实现
// 方法strcatchar *strcat(char *strDest, const char *strSrc){ assert((strDest != NULL) && (strSrc != NULL)); char *address = strDest; while(*strDest) strDes原创 2015-07-29 10:55:57 · 406 阅读 · 0 评论 -
反转一个单链表的循环和递归实现
// 方法一, 递归实现ListNode* ReverseList(ListNode* pHead){ return ReverseListRecursive(NULL,pHead); }// 返回反转后的头结点ListNode* ReverseListRecursive(ListNode* pPrev, ListNode* pNode){ // 空链表 if原创 2017-12-15 10:20:40 · 333 阅读 · 0 评论 -
合并两个有序列表的循环和递归实现
// 方法一, 循环实现ListNode* Merge(ListNode* pHead1, ListNode* pHead2){ if(pHead1 == NULL) return pHead2; else if(pHead2 == NULL) return pHead1; ListNode* pMergedHead = NULL;原创 2017-12-15 10:25:26 · 685 阅读 · 0 评论 -
查找算法 - 1
// 循环实现int binarySearch(int *a, int len, int x) { int low = 0; int high = len-1; int mid; while (low <= high) { mid = (low + high) / 2; if (a[mid] < x) lo原创 2017-12-15 10:42:18 · 217 阅读 · 0 评论 -
排序算法集合 - 5
堆排序// Heap Sort int LeftChild( int i ) { return ( 2 * ( i ) + 1 );} void PercDown( vector &A, int i, int N ) { int Child; int Tmp; for( Tmp = A[ i ]; LeftChild( i原创 2017-12-17 15:15:15 · 193 阅读 · 0 评论 -
排序算法集合 -2
4. 快速排序 Quick Sort快速排序的执行时间和空间: 平均情况为O(nlog(n)), 最差情况为O(n2), 存储空间:O(log(n))。//------------------------------------------------------------void swap(int *a, int left, int right) { int temp = a[left原创 2016-09-04 13:12:37 · 290 阅读 · 0 评论 -
排序算法集合 -1
1. 冒泡排序 Bubble Sort冒泡排序的执行时间和空间复杂度: 平均情况与最差情况为O(n2), 存储空间为O(1)。/************************************************************************* > File Name: bubbleSort.c > Author: > Mail: >原创 2016-09-04 12:56:48 · 376 阅读 · 0 评论 -
排序算法集合 -6
Shell排序实现Shell排序基于插入排序实现,也被称为窄增量排序,因为DL.Shell至1959提出命名。 该方法的基本思想是:先将整个待排元素序列切割成若干个子序列(由相隔某个“增量”的元素组成的,n/2, n/4,,,1)分别进行直接插入排序,然后依次缩减增量再进行排序,待整个序列中的元素基本有序(增量足够小)时,再对全体元素进行一次直接插入排序。由于直接插入排序在原创 2017-12-18 10:05:27 · 257 阅读 · 0 评论 -
排序算法集合 -7
计数排序计数排序是一个非基于比较的排序算法,该算法于1954年由 Harold H. Seward 提出。它的优势在于在对一定范围内的整数排序时,它的复杂度为Ο(n+k)(其中k是整数的范围),快于任何比较排序算法。当然这是一种牺牲空间换取时间的做法,而且当O(k)>O(n*log(n))的时候其效率反而不如基于比较的排序(基于比较的排序的时间复杂度在理论上的下限是O(n*log(n)),原创 2017-12-18 10:39:50 · 216 阅读 · 0 评论 -
string - strncat源码
//// main.cpp// AUTO_PRO//// Created by yanzhengqing on 12-12-11.// Copyright (c) 2012年 yanzhengqing. All rights reserved.//#include using namespacestd;/*** *char *strncat(front, back, coun原创 2015-07-29 10:23:02 · 676 阅读 · 0 评论 -
Two Sum III – Data structure design
Question: Design and implement a TwoSum class. It should support the following operations: add and find. add(input) – Add the number input to an internal data structure. find(value) – Find if there原创 2016-07-09 01:25:40 · 463 阅读 · 0 评论 -
Two Sum II – Input array is sorted
Question: Similar to Question [1. Two Sum], except that the input array is already sorted in ascending order.Solution: Of course we could still apply the [Hash table] approach, but it costs us O(n) e原创 2016-07-09 00:39:45 · 398 阅读 · 0 评论 -
string - strlen源码
//// main.cpp// AUTO_PRO//// Created by yanzhengqing on 12-12-11.// Copyright (c) 2012年 yanzhengqing. All rights reserved.//#include using namespace std;/*** *strlen - return the length of原创 2015-07-28 23:36:12 · 514 阅读 · 0 评论 -
string - strcpy源码
//// main.cpp// AUTO_PRO//// Created by yanzhengqing on 12-12-11.// Copyright (c) 2012年 yanzhengqing. All rights reserved.//#include using namespace std;/*** *char *strcpy(dst, src) - copy原创 2015-07-29 10:25:39 · 338 阅读 · 0 评论 -
string - memmove源码
//// main.cpp// AUTO_PRO//// Created by yanzhengqing on 12-12-11.// Copyright (c) 2012年 yanzhengqing. All rights reserved.//#include #include using namespace std;/****memmove - Copy sourc原创 2015-07-29 10:31:33 · 452 阅读 · 0 评论 -
string - strrchr源码
//// main.cpp// AUTO_PRO//// Created by yanzhengqing on 12-12-11.// Copyright (c) 2012年 yanzhengqing. All rights reserved.//#include using namespace std;/*** *char *strrchr(string, ch) - fi原创 2015-07-29 10:20:17 · 418 阅读 · 0 评论 -
string - strncpy源码
//// main.cpp// AUTO_PRO//// Created by yanzhengqing on 12-12-11.// Copyright (c) 2012年 yanzhengqing. All rights reserved.//#include using namespace std;/*** *char *strncpy(dest, source, co原创 2015-07-28 23:39:18 · 2784 阅读 · 0 评论 -
string - strchr源码
//// main.cpp// AUTO_PRO//// Created by yanzhengqing on 12-12-11.// Copyright (c) 2012年 yanzhengqing. All rights reserved.//#include using namespace std;/*** *char *strchr(string, c) - sear原创 2015-07-29 10:23:07 · 618 阅读 · 0 评论 -
string - strcat源码
//// main.cpp// AUTO_PRO//// Created by yanzhengqing on 12-12-11.// Copyright (c) 2012年 yanzhengqing. All rights reserved.//#include using namespace std;/*** *char *strcat(dst, src) - conc原创 2015-07-29 10:25:43 · 425 阅读 · 0 评论 -
string - strncmp源码
//// main.cpp// AUTO_PRO//// Created by yanzhengqing on 12-12-11.// Copyright (c) 2012年 yanzhengqing. All rights reserved.//#include using namespace std;/*** *int strncmp(first, last, count原创 2015-07-28 23:40:50 · 455 阅读 · 0 评论 -
string - memset源码
//// main.cpp// AUTO_PRO//// Created by yanzhengqing on 12-12-11.// Copyright (c) 2012年 yanzhengqing. All rights reserved.//#include using namespace std;/****char *memset(dst, val, count)原创 2015-07-29 10:55:24 · 428 阅读 · 0 评论 -
string - memchr源码
//// main.cpp// AUTO_PRO//// Created by yanzhengqing on 12-12-11.// Copyright (c) 2012年 yanzhengqing. All rights reserved.//#include using namespace std;/*** *char *memchr(buf, chr, cnt) -原创 2015-07-29 10:28:57 · 672 阅读 · 0 评论 -
string - memcmp源码
//// main.cpp// AUTO_PRO//// Created by yanzhengqing on 12-12-11.// Copyright (c) 2012年 yanzhengqing. All rights reserved.//#include #include using namespace std;/*** *int memcmp(buf1, bu原创 2015-07-29 10:28:06 · 448 阅读 · 0 评论 -
Pascal's Triangle
Given numRows, generate the first numRows of Pascal’s triangle.For example, given numRows = 5, Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]/******************************原创 2016-07-09 23:58:55 · 307 阅读 · 0 评论 -
Shortest Word Distance
Shortest Word Distance Total Accepted: 1754 Total Submissions: 4239 Difficulty: EasyGiven a list of words and two words word1 and word2, return the shortest distance between these two words in the lis原创 2016-07-10 14:59:32 · 377 阅读 · 0 评论 -
3sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain duplic原创 2016-07-13 15:38:43 · 354 阅读 · 0 评论 -
Missing Ranges
Question: Given a sorted integer array where the range of elements are [0, 99] inclusive, return its missing ranges. For example, given [0, 1, 3, 50, 75], return [“2”, “4->49”, “51->74”, “76->99”]Exa原创 2016-07-07 14:41:56 · 291 阅读 · 0 评论 -
找两个链表的共同点
pNode* findCommonList(pNode* l1, pNode* l2) { if (!l1 || !l2) return NULL; pNode dummy; pNode* tail = &dummy; map<int, int> hashTab; // record the node exits pNode* l = l1;原创 2016-07-07 21:02:10 · 377 阅读 · 0 评论 -
Two Sum
Code it now: https://oj.leetcode.com/problems/two-sum/ Difficulty: Easy, Frequency: HighQuestion: Given an array of integers, find two numbers such that they add up to a specific target number. The f原创 2016-07-08 23:22:15 · 310 阅读 · 0 评论 -
多线程经典面试题
多线程在笔试面试中经常出现,下面列出一些公司的多线程笔试面试题。首先是一些概念性的问答题,这些是多线程的基础知识,经常出现在面试中的第一轮面试(我参加2011年腾讯研究院实习生招聘时就被问到了几个概念性题目)。然后是一些选择题,这些一般在笔试时出现,虽然不是太难,但如果在选择题上花费大多时间无疑会对后面的编程题造成影响,因此必须迅速的解决掉。最后是综合题即难一些的问答题或是编程题。这种题目当然是最...转载 2018-03-02 16:08:42 · 7164 阅读 · 0 评论