- 博客(22)
- 资源 (5)
- 收藏
- 关注
转载 [LeetCode] Implement Trie (Prefix Tree) 实现字典树(前缀树)
Implement a trie with insert, search, and startsWith methods.Note: You may assume that all inputs are consist of lowercase letters a-z.这道题让我们实现一个重要但又有些复杂的数据结构-字典树, 又称前缀树或单词查找树,详细介绍可以参见网友董的博客,例如,一个保存了8
2015-10-09 09:59:50
374
原创 Binary Tree Inorder Traversal
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class
2015-10-08 10:08:58
225
原创 Single Number II
class Solution {public: int singleNumber(vector<int>& nums) { int dig[32] = {0}; for(auto i : nums){ for(int j = 0; j < 32; j++) { dig[j] += i&0x01;
2015-10-08 09:11:33
213
原创 Generate Parentheses
class Solution {public: vector<string> res; void dfs(string s, int left, int right, int n){ if(left == n && right == n){ res.push_back(s); return; }
2015-10-08 08:41:22
204
原创 Sort Colors
class Solution {public: void sortColors(vector<int>& nums) { int i = 0, j = nums.size()-1, k = 0; while(k < j + 1){ if(nums[k] == 0){ swap(nums[i++], nu
2015-10-07 23:25:16
232
原创 Remove Nth Node From End of List
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* rem
2015-10-07 22:55:40
280
原创 Letter Combinations of a Phone Number
class Solution {public: string dic[10] = {"", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"}; vector<string> res; void dfs(string& digits, string s, int cur, int len){
2015-10-07 18:37:10
228
原创 Longest Common Prefix
class Solution {public: string longestCommonPrefix(vector<string>& strs) { string s = ""; const int len = strs.size(); if(len == 0) return s; string cur = strs[0];
2015-10-07 18:20:24
208
原创 Palindrome Number
注意tempx需要记录改变x之前的值class Solution {public: bool isPalindrome(int x) { if(x < 0) return false; int res = 0, tempx = x; while(x){ if(res > INT_MAX/10) return false
2015-10-07 17:42:58
269
原创 String to Integer (atoi)
class Solution {public: int myAtoi(string str) { int i = 0; bool isNeg = false; while(isspace(str[i])) i++; if(str[i]=='-') isNeg = true; if(str[i]=='+' ||s
2015-10-07 17:36:12
203
原创 Reverse Integer
class Solution {public: int reverse(int x) { bool isNeg = false; if(x < 0) { x = -x; isNeg = true; } int c = 0; while(x){
2015-10-07 12:55:49
186
原创 Longest Palindromic Substring
class Solution {public: string longestPalindrome(string s) { const int len = s.length(); int maxlen = 1, ii = 0, jj = 0; bool f[len+1][len+1]; for(int i = 0; i <= l
2015-10-07 12:52:10
199
原创 Longest Substring Without Repeating Characters
class Solution {public: int lengthOfLongestSubstring(string s) { int dic[256]; for(int i = 0; i < 256; i++) dic[i] = -1; int maxlen = 0, j = 0; for(int i = 0; i < s
2015-10-07 12:44:40
221
原创 Add Two Numbers
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* add
2015-10-07 12:37:24
279
原创 Two Sum
class Solution {public: vector<int> twoSum(vector<int>& nums, int target) { unordered_map<int, int> m; vector<int> res; for(int i = 0; i < nums.size(); i++){ m[
2015-10-07 12:33:16
210
原创 Longest Valid Parentheses
Longest Valid Parenthesesclass Solution {public: int longestValidParentheses(string s) { const int len = s.length(); stack<int> stk; vector<bool> v(len, false); for
2015-09-19 12:23:07
226
原创 Rectangle Area
class Solution {public: int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) { int a = (C-A)*(D-B)+(G-E)*(H-F); if((C<=E)||(G<=A)||(H<=B)||(D<=F)) return a;
2015-09-19 11:48:51
214
原创 Move Zeroes
Move Zeroesmy solutionclass Solution {public: void moveZeroes(vector<int>& nums) { const int len = nums.size(); int j = 0; for(int i = 0; i < len; i++){ if(nums[
2015-09-19 10:54:38
203
转载 Compare Version Numbers
欢迎使用Markdown编辑器写博客const int len1 = version1.length(); const int len2 = version2.length(); int i = 0, j = 0; while(i < len1 || j < len2){ int v1 = 0, v2 = 0;
2015-09-19 10:25:31
316
转载 继续上篇 对于IplImage的操作
04.#include "stdafx.h" 05.#include 06.#include 07.#include 08.#include 09.#include 10.int main(int argc, char *argv[]) 11.{ 12. IplImage* img = 0; 13. int height
2013-05-25 18:39:35
610
转载 dopenCV中IplImage的使用
开始做人脸检测的移植工作了,前段时间完成了opencv的1.0版的源代码包在montavista的工具链下的编译,经过交叉编译成功的将facedetect例程在DM6446的ARM上跑通了。但这个程序里的IplImage是通过cvLoadImage一jpg图片得到的,而我的程序里是利用v4l2驱动从摄像头读到的UYVY格式的数据,因此想自己来创建这个IplImage的结构体。IplImag
2013-05-25 18:37:39
563
原创 第一篇博客!
今天搬家到优快云这个博客helloed02,这是第一篇博客,不谈技术问题。本人电子出身,现又加入计算机科学的领域。图像处理,人工智能方向。有一颗不服输的心,希望这里能见证我的成长!
2013-05-24 15:48:53
348
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人