随笔分类 - # 数据结构
摘要://解法一: class Solution { public: int firstUniqChar(string s) { int ret=-1; int a[26]={0}; for(int i=0;i<s.size();i++) { a[s[i]-'a']++; } for(int i=0;i<
阅读全文
摘要://解法一:递归版算法 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), l
阅读全文
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), r
阅读全文
摘要://中序遍历二叉树,解法一:递归版 //Time:O(n) SPace:O(n) /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right;
阅读全文
摘要://解法一:非递归版本 Time:O(n),Space:O(n) /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNo
阅读全文
摘要:第一:选择排序 #include <iostream> #include <string> using namespace std; template <typename T> void Swap(T& a,T& b) { T c=a; a=b; b=c; } template <typename
阅读全文

浙公网安备 33010602011771号