HQBUPT
码龄12年
关注
提问 私信
  • 博客:56,583
    56,583
    总访问量
  • 87
    原创
  • 1,229,871
    排名
  • 15
    粉丝
  • 0
    铁粉
IP属地以运营商信息为准,境内显示到省(区、市),境外显示到国家(地区)
IP 属地:北京市
  • 加入CSDN时间: 2013-01-04
博客简介:

HQBUPT的专栏

查看详细资料
个人成就
  • 获得3次点赞
  • 内容获得69次评论
  • 获得2次收藏
创作历程
  • 87篇
    2014年
成就勋章
TA的专栏
  • LeetCode
    84篇
  • 其他
    3篇
创作活动更多

超级创作者激励计划

万元现金补贴,高额收益分成,专属VIP内容创作者流量扶持,等你加入!

去参加
  • 最近
  • 文章
  • 代码仓
  • 资源
  • 问答
  • 帖子
  • 视频
  • 课程
  • 关注/订阅/互动
  • 收藏
搜TA的内容
搜索 取消

[LeetCode] Decode Ways

int numDecodings(string s) { if (s.length() == 0 || s[0] == '0') { return 0; } else if (s.length() == 1) { return 1; } int numWithoutLastTwo = 1, numWithoutLastOne = 1, num = 0; for (int
原创
发布博客 2014.07.24 ·
922 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

[LeetCode] ZigZag Conversion

string convert(string s, int nRows) { if (nRows <= 1) { return s; } string* rowStr = new string[nRows]; bool down = true; int i = 0, row = 0; while (i < s.length()) { if (down) { row
原创
发布博客 2014.07.20 ·
608 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

C++中 string转int 和 int转string

#include using namespace std;stringstream strStream;string str = "-123";stream<<str;int val;stream>>val;
原创
发布博客 2014.07.20 ·
1413 阅读 ·
0 点赞 ·
0 评论 ·
1 收藏

[LeetCode] Count and Say

string countAndSay(string s) { string result; int index1 = 0, index2 = 0, count = 0; while(index1 < s.length()) { if (s[index2] == s[index1]) { count++; index2++; } if (index2 =
原创
发布博客 2014.07.20 ·
651 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

[LeetCode] Anagrams

vector anagrams(vector &strs) { map hashTable; for (int i = 0; i < strs.size(); i++) { string str = strs[i]; sort(str.begin(), str.end()); if (hashTable.count(str) == 0) { hashTable[str]
原创
发布博客 2014.07.17 ·
557 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

[LeetCode] 3Sum

vector > threeSum(vector &num) { sort(num.begin(), num.end()); vector> triplets; int n = num.size(); if (n == 0) { return triplets; } int lastNum = num[0] + 1; for (int aIndex = 0; aIndex <
原创
发布博客 2014.07.17 ·
449 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

[LeetCode] Insert Interval

vector insert(vector &intervals, Interval newInterval) { int beg = intervals.size(), end = intervals.size()-1; bool getBeg = false; for (int i = 0; i < intervals.size(); i++) { if (newInterval.s
原创
发布博客 2014.07.16 ·
518 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

[LeetCode] Longest Common Prefix

string longestCommonPrefix(vector &strs) { string commonPrefix; if(strs.empty()) { return commonPrefix; } int index = 0; while(1) { for(int i = 0; i < strs.size(); i++) { string str = strs
原创
发布博客 2014.07.15 ·
538 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

[LeetCode] Pow(x, n)

double pow(double x, int n) { if (n == INT_MIN) { return 1.0/(pow(x, -(n+1))*x); } else if(n < 0) { return 1.0/pow(x, -n); } else if(n == 0) { return 1.0; } else if (n == 1) { retur
原创
发布博客 2014.07.15 ·
462 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

[LeetCode] Two Sum

vector twoSum(vector &numbers, int target) { vector twoIndex; map numIndex; for(int i = 0; i < numbers.size(); i++) { int num = target - numbers[i]; if(!numIndex.count(num)) { numIndex[numbe
原创
发布博客 2014.07.15 ·
528 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

[LeetCode] Longest Consecutive Sequence

int longestConsecutive(vector &num) { map map; for (int i = 0; i < num.size(); i++) { map[num[i]] = true; } int maxLen = 0; for (int i = 0; i < num.size(); i++) { if (map[num[i]] == tru
原创
发布博客 2014.07.14 ·
503 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

[LeetCode] Implement strStr()

char *strStr(char *haystack, char *needle) { if (haystack == NULL || needle == NULL){ return NULL; } int haystack_len = strlen(haystack); int needle_len = strlen(needle); for(int i = 0; i <= ha
原创
发布博客 2014.07.14 ·
602 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

[LeetCode] Candy

int candy(vector &ratings) { int n = ratings.size(); int* candy = new int[n]; for(int i = 0; i < n; i++) { candy[i] = 1; } for(int i = 1; i < n; i++) { if(ratings[i] > ratings[i-1] && candy[i
原创
发布博客 2014.07.14 ·
545 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

Bayesian Face Revisited: A Joint Formulation 算法流程图

Joint Bayesian Face Verification
原创
发布博客 2014.07.14 ·
12978 阅读 ·
3 点赞 ·
69 评论 ·
12 收藏

[LeetCode] Palindrome Number

bool isPalindrome(int x) { if (x < 0) { return false; } int xReverse = 0; int xTmp = x; while (xTmp != 0) { if (xReverse > INT_MAX/10) { return false; } xReverse *= 10; if ((IN
原创
发布博客 2014.07.13 ·
489 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

[LeetCode] String to Integer (atoi)

int atoi(const char *str) { if (str == NULL) { return 0; } while (*str == ' ') { str++; } bool negative = false; if (*str == '+') { negative = false; str++; } else if (*str == '-')
原创
发布博客 2014.07.13 ·
613 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

[LeetCode] Valid Palindrome

bool isPalindrome(string s) { int left = 0, right = s.length()-1; while (left <= right) { char leftChar = s[left]; if (!((leftChar >= '0' && leftChar = 'a' && leftChar = 'A' && leftChar <= 'Z')
原创
发布博客 2014.07.13 ·
466 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

[LeetCode] Validate Binary Search Tree

vector inorderTraversal(TreeNode *root) { vector pre_node; vector val; if (root == NULL) { return val; } pre_node.push_back(root); while(!pre_node.empty()) { TreeNode* cur_node = pre_node
原创
发布博客 2014.07.13 ·
543 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

[LeetCode] Partition List

ListNode *partition(ListNode *head, int x) { ListNode* virtualHead = new ListNode(-1); virtualHead->next = head; ListNode* lessNode = virtualHead; ListNode* preNode = virtualHead; ListNode* curNo
原创
发布博客 2014.07.13 ·
452 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏

[LeetCode] Search in Rotated Sorted Array II

bool search(int A[], int n, int target) { int beg = 0, end = n-1; while (beg <= end) { int mid = (beg+end)/2; if (A[beg] < A[end]) { if (target < A[mid]) { end = mid - 1; }
原创
发布博客 2014.07.13 ·
436 阅读 ·
0 点赞 ·
0 评论 ·
0 收藏
加载更多