- 博客(10)
- 资源 (5)
- 收藏
- 关注
原创 构建二叉树
/*1.一直一个排序数组,求转换为一个平衡二叉查找树*//** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeN
2016-04-22 15:27:23 428
原创 每一个树右边的指针
1 / \ 2 3 /\ /\ 4 5 6 7 root random root->right random->left root random 1 -> NULL 1 NULL / \
2016-04-19 16:18:20 361
原创 树的最大路径和
/** * * Definition for a binary tree node. * * struct TreeNode { * * int val; * * TreeNode *left; * * TreeNode *right; * * TreeNode(int x) : val(x), left(NUL
2016-04-18 16:21:56 695
原创 树的前中后非递归遍历
/** * * Definition for a binary tree node. * * struct TreeNode { * * int val; * * TreeNode *left; * * TreeNode *right; * * TreeNode(int x) : val(x), left(NUL
2016-04-18 14:06:06 400
原创 pow函数
/*分治思想n= 5 2 1 0 x^5 x^2 x^1 x^0 x^2 * x^2 *x x^1 * x^1 1*1*x 1*/class Solution { public:
2016-04-18 11:42:05 542
原创 sqrt函数
/*时间复杂度 O(lon(n)) 空间 O(1) */class Solution { public: int mySqrt(int x) { int left = 1; int right = x/2; int mid ; int
2016-04-18 11:32:49 917
原创 STL中list的重写
#pragma once#ifndef __________LIST______________ #define __________LIST______________ //************************************************************* template class list { private: struct
2016-04-14 22:24:02 614
原创 最长递增子序列
#include #include int Get_Max_Length(int arr[],int n){ int Lis[1000]; //到下表为止的数组的最大长度 int Max[1000]; //到下标为止的长度的最小数字 Lis[1] = 1; //初始化第一个元素 int MaxLen = 1; Max[1] = arr[
2016-04-14 21:33:08 333
原创 计数排序
#include #include #include using namespace std;void CountSort(int arr[],int n){ if(arr == NULL || n <= 0) { return ; } int MIN = arr[0]; int MAX = arr[0]; for(in
2016-04-12 11:08:22 312
原创 LPS最长回文子序列
#include#include#includeusing namespace std;int lpsDp(char * str,int n){ int dp[n][n], tmp; memset(dp,0,sizeof(dp)); for(int i=0; i<n; i++) dp[i][i] = 1; // i 表示 当前长度为 i+1的 子序列 for(int i=1;
2016-04-04 16:38:50 699
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人