- 博客(8)
- 收藏
- 关注
原创 剑指offer:合并两个排序的链表
#include #include #include using namespace std; struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } }; class Solution { public:
2015-08-16 22:24:23 379
原创 剑指offer:二进制中1的个数
class Solution { public: int NumberOf1(int n) { int c = 0; while(n) { n = n & (n - 1); c++; } return c; } };
2015-08-13 19:52:30 410
原创 360:挑选镇长
#include #include using namespace std; int main() { int T, n, m, a, b, i, j, cnt; vector v[100001]; vector res; cin>>T; while(T--) { res.clear(); for(i = 0;
2015-08-13 15:07:49 947
原创 360:最后一个字符
正在挑战一个CrackMe的你,把需要填写的前面几位密码都正确猜出了,可是这最后一位密码,好像藏得有点深。 CrackMe的作者还挑衅般的在里面藏了个.tar.gz文件,解压缩出来,里面写道你要的最后一个字符就在下面这个字符串里。 这个字符是下面整个字符串中第一个只出现一次的字符。 (比如,串是abaccdeff,那么正确字符就是b了) 然而下面给出来的字符串好像太长太长了,单靠人力
2015-08-12 23:11:20 764
原创 leetcode:Integer to Roman
class Solution { public: string str(int x, int y) { string s; int i; if(x == 0) { if(y > 0 && y < 4) { for(i = 0; i < y;
2015-08-05 16:47:47 313
原创 leetcode:Container With Most Water
class Solution { public: int maxArea(vector& height) { /*int i, j, mx = 0; for(i = 0; i < height.size(); i++) { for(j = i + 1; j < height.size(); j++)
2015-08-04 21:56:02 324
原创 leetcode:Longest Palindromic Substring
class Solution { public: string longestPalindrome(string s) { string sNew, longest; int i, j = 0, iMax = 1, id = 1; int p[2222]; memset(p, 0, sizeof(p));
2015-08-02 20:17:22 353
原创 leetcode:Longest Substring Without Repeating Characters
class Solution { public: int lengthOfLongestSubstring(string s) { int i, j, k, len, preLen = 0, maxLen = 0; map m; map :: iterator it; for(i = 0; i < s.size();
2015-08-01 19:09:24 338
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人