上一页 1 2 3 4 5 6 7 8 9 10 ··· 19 下一页

2016年4月15日

数字在排序数组中出现的次数

摘要: class Solution { public: int lowindex(vector&data,int k,int low,int high) { if(lowk) return lowindex(data,k,low,mid-1); if(data[mid]&data,int k,int... 阅读全文

posted @ 2016-04-15 11:36 RenewDo 阅读(124) 评论(0) 推荐(0) 编辑

两个链表的第一个公共结点

摘要: class Solution { public: ListNode* FindFirstCommonNode( ListNode *pHead1, ListNode *pHead2) { if(!pHead1||!pHead2) return NULL; int len1=0,len2=0; ListNode* p1=pHe... 阅读全文

posted @ 2016-04-15 09:47 RenewDo 阅读(68) 评论(0) 推荐(0) 编辑

2016年4月13日

数组中的逆序对

摘要: 重新复制的数组应该在每次合并后都更新,剑指offer好像没有做。 阅读全文

posted @ 2016-04-13 12:19 RenewDo 阅读(139) 评论(0) 推荐(0) 编辑

第一个只出现一次的字符位置

摘要: class Solution { public: int FirstNotRepeatingChar(string str) { if(str=="")return -1; vector a(256,0); for(int i=0;i<str.size();i++) a[str[i]]++; fo... 阅读全文

posted @ 2016-04-13 10:22 RenewDo 阅读(118) 评论(0) 推荐(0) 编辑

丑数

摘要: class Solution { public: int min3(int x,int y,int z) { int m; m=(x ugly(index,0); ugly[0]=1; int num=1; int num2=0,num3=0,num5=0,res=0; ... 阅读全文

posted @ 2016-04-13 10:03 RenewDo 阅读(180) 评论(0) 推荐(0) 编辑

把数组排成最小的数

摘要: string 型默认为“”;它是不能和NULL进行比较的。牛客网上刷这题,居然因为我判断输入为空时,返回NULL,判我死循环!!! 阅读全文

posted @ 2016-04-13 08:59 RenewDo 阅读(97) 评论(0) 推荐(0) 编辑

2016年4月12日

STL sort 的用法

摘要: sort的原型: 说明: 1、排序的区间可以是数组下标或者迭代器,如果是迭代器必须是随机迭代器(如vector支持的迭代器和自己定义的支持随机迭代器的数据结构) 2、默认情况下是采用从小到大的方式排列的 3、STL内部提供了less<T>() 、greater<T>(),以及自定义的数据结构: st 阅读全文

posted @ 2016-04-12 11:14 RenewDo 阅读(371) 评论(0) 推荐(0) 编辑

vs2012:sprintf no safe

摘要: 将数字转换成字符串函数 出现异常情况如下: error C4996: 'sprintf': This function or variable may be unsafe. 建议我换成sprintf_s,换过后还是不行。 后来另起一个项目进行测试,发现可以直接使用,不知道为什么上个不能用? 查找原因 阅读全文

posted @ 2016-04-12 10:14 RenewDo 阅读(264) 评论(0) 推荐(0) 编辑

整数中1出现的次数(从1到n整数中1出现的次数)

摘要: 1、最高位:为1 则是后面位(如123,则应取23);不为1 则是最高位的(如223,则取100) 2、其它位:如223,可分为0-23,24-123,124-223。其它位是指24-123,124-223的除最高位的1其余可能有的1,可以发现24-123其实其它位为:25,26···99,0,1, 阅读全文

posted @ 2016-04-12 08:33 RenewDo 阅读(185) 评论(0) 推荐(0) 编辑

2016年4月11日

最小的K个数

摘要: class Solution { public: vector GetLeastNumbers_Solution(vector input, int k) { vector res; if(input.size()> max; multiset>::iterator it; for(int i=0;i<input.... 阅读全文

posted @ 2016-04-11 12:02 RenewDo 阅读(94) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 9 10 ··· 19 下一页

导航