- 博客(29)
- 资源 (5)
- 收藏
- 关注
原创 leetcode:Spiral Matrix II
leetcode:Spiral Matrix II 题目:Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix
2016-08-30 22:32:57 461
原创 leetcode:二叉树之Construct Binary Tree from Inorder and Postorder Traversal
leetcode:二叉树之Construct Binary Tree from Inorder and Postorder Traversal题目:Given inorder and postorder traversal of a tree, construct the binary tree.Note: You may assume that duplicates do not e
2016-08-19 11:28:40 360
原创 leetcode:二叉树之Construct Binary Tree from Preorder and Inorder Traversal
leetcode:二叉树之Construct Binary Tree from Preorder and Inorder Traversal题目:Given preorder and inorder traversal of a tree, construct the binary tree.Note: You may assume that duplicates do not exi
2016-08-19 11:07:38 408
原创 leetcode:二叉树之Binary Tree Postorder Traversal
leetcode:二叉树之Binary Tree Postorder TraversalGiven a binary tree, return the postorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2 /
2016-08-18 12:45:57 271
原创 leetcode:二叉树之Binary Tree Inorder Traversal
leetcode:二叉树之Binary Tree Inorder TraversalGiven a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2
2016-08-18 12:36:20 320
原创 笔记之stack堆栈容器
笔记之stack堆栈容器:#include #include using namespace std;//堆栈的元素插入称为入栈,元素的删除称为出栈。由于元素的入栈和出栈总在栈顶进行,//因此,堆栈是一个后进先出(Last In First Out)表,即 LIFO 表int main(){ // 创建堆栈对象 stack s; // 元素入栈 //
2016-08-18 12:21:51 438
原创 leetcode:二叉树之Binary Tree Preorder Traversal
leetcode:二叉树之Binary Tree Preorder Traversal题目:Given a binary tree, return the preorder traversal of its nodes’ values.For example,Given binary tree {1,#,2,3}, 1 \ 2
2016-08-18 12:03:13 333
原创 二叉搜索树
二叉搜索树(BinarySearch Tree,也叫二叉搜索树,或称二叉排序树Binary Sort Tree):定义:二叉查找树或者是一棵空树,或者是具有下列性质的二叉树: (1)、若它的左子树不为空,则左子树上所有结点的值均小于它的根结点的值; (2)、若它的右子树不为空,则右子树上所有结点的值均大于它的根结点的值; (3)、它的左、右
2016-08-16 12:46:14 208
原创 二叉树的建立与遍历(前序,中序,后序)
二叉树(Binary Tree):定义:二叉树是n(n>=0)个结点的优先集合,该集合或者为空集(称为空二叉树),或者由一个根结点和两棵互不相交的、分别称为根结点的左子树和右子树组成。链式存储结构(二叉链表):由一个数据域(data)和两个指针域构成(lchild,rchild分别指向左右孩子)。如下图:例如:二叉链表的结点结构定义代码:typedef stru
2016-08-15 23:02:06 5020
原创 递归
递归概念: 递归算法是一种直接或者间接调用自身函数或者方法的算法。它通常把一个大型复杂的问题层层转化为一个与原问题相似的规模较小的问题来求解。使用递归的两个条件:既然递归的思想是把问题分解成为规模更小且与原问题有着相同解法的问题,那么是不是这样的问题都能用递归来解决呢?答案是否定的。并不是所有问题都能用递归来解决。那么什么样的问题可以用递归来解决呢?一般来讲,能用递归来解决的问题必须满
2016-08-15 12:12:12 399
原创 leetcode:暴力枚举法之Combinations
leetcode:暴力枚举法之Combinations题目;Given two integers n and k, return all possible combinations of k numbers out of 1...n.For example, If n = 4 and k = 2, a solution is:[ [2,4], [3,4],
2016-08-15 11:08:36 675
原创 leetcode:暴力枚举法之Permutations
leetcode:暴力枚举法之Permutations题目:Given a collection of numbers, return all possible permutations.For example, [1,2,3] have the following permutations: [1,2,3], [1,3,2], [2,1,3], [2,3,1],[3,1,2],
2016-08-14 14:26:46 734
原创 leetcode:暴力枚举法之Subsets II
leetcode:暴力枚举法之Subsets II题目;Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order. The solution
2016-08-13 12:22:07 412
原创 leetcode:暴力枚举法之Subsets
leetcode:暴力枚举法之Subsets题目:Given a set of distinct integers, S, return all possible subsets.Note:• Elements in a subset must be in non-descending order.• the solution set must not contain dupl
2016-08-13 11:24:33 674
原创 leetcode:字符串之Length of Last Word
leetcode:字符串之Length of Last Word题目:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not
2016-08-11 18:17:55 691
原创 leetcode:字符串之Anagrams
leetcode:字符串之Anagrams题目:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.For example,Input: ["tea","and","ate","eat",
2016-08-11 17:50:44 363
原创 leetcode:字符串之Simplify Path
leetcode:字符串之Simplify Path题目:Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"Corner Cases:• Did you co
2016-08-11 16:24:42 467
原创 leetcode:字符串之Valid Palindrome && Palindrome Number
leetcode:字符串之Valid Palindrome题目:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,”A man, a plan, a canal: Panama” is a p
2016-08-10 12:20:14 305
转载 机器学习常见算法分类汇总
转载自: 机器学习常见算法分类汇总机器学习无疑是当前数据分析领域的一个热点内容。很多人在平时的工作中都或多或少会用到机器学习的算法。这里IT经理网为您总结一下常见的机器学习算法,以供您在工作和学习中参考。机器学习的算法很多。很多时候困惑人们都是,很多算法是一类算法,而有些算法又是从其他算法中延伸出来的。这里,我们从两个方面来给大家介绍,第一个方面是学习的方式,第二个方面是算法的类似
2016-08-09 13:38:26 399
原创 leetcode:单链表之Remove Nth Node From End of List
leetcode:单链表之Remove Nth Node From End of List题目:Given a linked list, remove the nth node from the end of list and return its head.For example,Given linked list: 1->2->3->4->5, and n = 2.Afte
2016-08-04 11:15:24 380
原创 leetcode:单链表之Rotate List
leetcode:单链表之Rotate List题目:Given a list, rotate the list to the right by k places, where k is non-negative.For example: Given 1->2->3->4->5->nullptr and k = 2, return 4->5->1->2->3->nullptr.
2016-08-04 10:53:41 276
原创 leetcode:单链表之Remove Duplicates from Sorted List II
leetcode:单链表之Remove Duplicates from Sorted List II题目:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbersfrom the original list.For example,
2016-08-03 18:25:25 418
原创 leetcode:单链表之Remove Duplicates from Sorted List
leetcode:单链表之Remove Duplicates from Sorted List题目:Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1-
2016-08-03 16:54:13 245
原创 leetcode:单链表之Partition List
leetcode:单链表之Partition List题目:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relati
2016-08-03 16:12:08 476
原创 leetcode:单链表之Reverse Linked List II
leetcode:单链表之Reverse Linked List II题目:Reverse a linked list from position m to n. Do it in-place and in one-pass.For example: Given 1->2->3->4->5->nullptr, m = 2 and n = 4,return 1->4->3->2-
2016-08-03 14:45:03 371
原创 单链表
单链表:是一种链式存取的数据结构,用一组地址任意的存储单元(这组存储单元既可以是连续的,也可以是不连续的)存放线性表中的数据元素。单链表结构示意图:单链表结构体定义:typedef struct Node{ ElemType data; struct Node *next;}Node;typedef struct Node *LinkList; /* 定义Li
2016-08-02 19:13:37 295 1
原创 leetcode: 单链表之Add Two Numbers
leetcode: 单链表之Add Two Numbers题目:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the
2016-08-02 17:34:52 263
原创 leetcode:数组之Rotate Image
leetcode:数组之Rotate Image给定一二维数组,将其旋转90度。例如C++实现:#include #include using namespace std;void rotate(vector>& matrix) { const int n = matrix.size(); for (int i = 0; i < n; ++i) /
2016-08-01 15:54:21 289
原创 leetcode:数组之Remove Element
leetcode:数组之Remove Element给定一数组及要删除的元素,返回删除元素后数组的长度。C++实现#include using namespace std;int removeElement(int a[],int n,int elem){ int index =0; for(int i=0;i<n;i++) { if(a[i]!=elem)
2016-08-01 15:24:28 228
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人