- 博客(12)
- 收藏
- 关注
原创 longest-substring-without-repeating-characters
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for “abcabcbb” is “abc”, which the length is 3. For ...
2018-04-22 17:11:24 320
原创 求数组的最大值和次大值、最大值和最小值
题目一:求数组的最大值和次大值void select_max(const int*a, int size, int&nMax, int& nSecondMax){ nMax = a[0]; nSecondMax = a[0]; for (int i = 0; i < size; i++) { if (nMax < a...
2018-04-21 17:42:45 8335 2
原创 sort list(归并排序)
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode *s...
2018-04-18 16:04:05 347
转载 median of the two sorted arrays
转载至:https://blog.csdn.net/chen_xinjia/article/details/69258706public static double findMedianSortedArrays(int[] nums1, int[] nums2) { int MIN_VALUE = 0x80000000; int MAX_VALUE = 0x7...
2018-04-18 15:19:12 137
原创 2sum、3sum、3close_sum、4sum
题目一: Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target,...
2018-04-18 14:14:06 212
原创 sqrtx
int sqrt(int x) { if(x < 0) return-1; if(x==0) return 0; int low=1,high=x/2+1; while(low<=high) { int mid=((high-low)>>1)+low; ...
2018-04-18 10:57:03 143
原创 连续子数组的最大乘积
class Solution { public: int maxProduct(vector<int>& nums) { int last_max = nums[0]; int last_min = nums[0]; int result = nums[0]; int cur_max...
2018-04-17 20:39:49 867
原创 epoll下ET模式为何一定要用要用非阻塞的模式~
ET 模式是一种边沿触发模型,在它检测到有 I/O 事件时,通过 epoll_wait 调用会得到有事件通知的文件描述符,每于每一个被通知的文件描述符,如可读,则必须将该文件描述符一直读到空,让 errno 返回 EAGAIN 为止,否则下次的 epoll_wait 不会返回余下的数据,会丢掉事件。而如果你的文件描述符如果不是非阻塞的,那这个一直读或一直写势必会在最后一次阻塞。...
2018-04-12 12:40:36 5274 3
原创 连续子数组的最大和
Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array[−2,1,−3,4,−1,2,1,−5,4], the contiguous subarray[4,−1,2,1]has the...
2018-04-02 19:15:26 156
原创 携程春招第二题(输入问题)
#include<iostream>**#include<sstream>**#include<string>#include<vector>using namespace std;void rotate(vector<vector<int> > &matrix) { //主对角线翻转 ...
2018-04-01 14:30:36 178
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人