数据结构&算法
文章平均质量分 61
PenyChow
这个作者很懒,什么都没留下…
展开
-
二叉搜索树和双向链表
二叉搜索树转变为双向链表(在原来节点进行变化,仅仅改变left和right的指向)原创 2014-04-16 10:27:09 · 639 阅读 · 0 评论 -
Leetcode_Merge Sorted Array
Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements fro原创 2014-08-04 23:36:00 · 489 阅读 · 0 评论 -
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 / 3return [1,2,3].原创 2014-08-04 23:40:40 · 481 阅读 · 0 评论 -
Leetcode_Palindrome_Partitioning_DFS 算法
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["aa","原创 2014-08-04 23:18:14 · 508 阅读 · 0 评论 -
Leetcode_Remove Duplicates from Sorted Array II
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [1,1,1,2,2,3],Your function should return length = 5, and A is now [1,1,2,原创 2014-08-04 23:50:49 · 551 阅读 · 0 评论 -
Leetcode_Permutations II
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1].原创 2014-08-04 19:18:50 · 583 阅读 · 0 评论 -
Leetcode_Wildcard Matching
字符串模式匹配实现原创 2014-08-04 23:43:29 · 824 阅读 · 0 评论 -
Leetcode_Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node's key.Th原创 2014-08-04 23:37:59 · 527 阅读 · 0 评论 -
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 relative order of the nodes in each of原创 2014-08-03 20:45:13 · 668 阅读 · 0 评论 -
leetcode_ReverseLinkedListII
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->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy t原创 2014-08-03 20:50:39 · 542 阅读 · 0 评论 -
leetcodr_AddTwoNumbers
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 two numbers and return it as a link原创 2014-08-03 20:54:17 · 548 阅读 · 0 评论 -
连连看自动解算程序
今天花了我四个小时写了一个练练自动解算程序, 广度+剪枝 双向交替效率还行 100*100的矩阵,给出6个不同的随机id的话 10秒内跑完 直接上代码#include #include #include #include #include using namespace std;const int ROW=9; //矩阵行数,测试的时候请原创 2014-04-02 23:45:05 · 1099 阅读 · 0 评论 -
2014微软实习生招聘第二题
Time Limit: 10000msCase Time Limit: 1000msMemory Limit: 256MBDescriptionConsider a string set that each of them consists of {0, 1} only. All strings in the set have the same nu原创 2014-04-12 23:39:44 · 606 阅读 · 0 评论 -
根据前序和中序列 重建二叉树
输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并输出它的后序遍历序列。输入:输入可能包含多个测试样例,对于每个测试案例,输入的第一行为一个整数n(1输入的第二行包括n个整数(其中每个元素a的原创 2014-05-09 01:12:27 · 927 阅读 · 0 评论 -
经典题目——字符串全排序
题目描述:输入一个字符串,按字典序打印出该字符串中字符的所有排列。例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba。输入:每个测试案例包括1行。输入一个字符串,长度不超过9(可能有字符重复),字符只包括大小写字母。输出:对应每组数据,按字典序输出所有排列。样例输入:abcBCA原创 2014-04-16 15:06:14 · 975 阅读 · 0 评论 -
Leetcode_Add Binary
leetcode_Add Binary原创 2014-08-04 23:44:22 · 688 阅读 · 0 评论