自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(17)
  • 资源 (5)
  • 收藏
  • 关注

原创 leetcode- Permutations II

题目:  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

2015-06-29 14:52:24 718

原创 leetcode - Jump Game II

题目: Jump Game II   Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length

2015-06-29 00:00:08 602

原创 leetcode - Next Permutation

题目: Next Permutation  Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rea

2015-06-22 17:59:18 504

原创 leetcode - Divide Two Integers

题目: Divide Two Integers  Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT.  分析: 1、设法在不溢出的前提下,把除数和被除数转化成正数进行计算。

2015-06-22 16:11:32 546

原创 leetcode - Merge k Sorted Lists

题目: Merge k Sorted Lists Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.  分析: 用multiset作为小根堆,multiset的begin是value最小的结点。 注意:

2015-06-21 09:45:02 802

转载 leetcode - Container With Most Water

题目: Container With Most Water Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints

2015-06-20 20:37:06 513

原创 leetcode - Longest Palindromic Substring

题目: Longest Palindromic Substring   Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest

2015-06-20 16:35:32 668

原创 leetcode - Valid Number

题目: Valid Number Validate if a given string is numeric. Some examples: "0" => true " 0.1 " => true "abc" => false "1 a" => false "2e10" => true class Solution { public: bool is

2015-06-10 11:07:47 728

原创 leetcode - Regular Expression Matching

题目: Regular Expression Matching   '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). The

2015-06-09 21:28:09 553

转载 leetcode - Count Complete Tree Nodes

题目: Count Complete Tree Nodes   Given a complete binary tree, count the number of nodes. In a complete binary tree every level, except possibly the last, is completely filled, and all

2015-06-06 17:35:37 520

原创 manacher算法的实现

manacher算法的解释见 这里。 //求字符串s中最大回文的长度,要求字符串s不包含字符‘#’ int manacher(const string &s) { if (s.size() <= 1) return s.size(); //往s每个字符之间以及s的首尾都插入‘#’ string str(s.size() * 2 + 1, '#'); for (int

2015-06-05 11:51:31 1204

原创 【回文】leetcode - Shortest Palindrome

题目: Shortest Palindrome   Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by perf

2015-06-05 11:01:33 852

原创 leetcode - Missing Ranges

题目: Missing Ranges Given a sorted integer array where the range of elements are [0, 99]inclusive, return its missing ranges. For example, given [0, 1, 3, 50, 75], return[“2”, “4->49”, “51->74”, “

2015-06-04 16:15:00 827

原创 leetcode - One Edit Distance

题目: One Edit Distance Given two strings S and T, determine if they are both oneedit distance apart. Hint: 1. If | n – m | is greater than 1, we know immediately both are not one-editdistance a

2015-06-04 15:27:10 660

原创 【动态规划】leetcode - Maximal Square

题目: Maximal Square   Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area. For example, given the following matrix: 1 0 1 0

2015-06-03 15:20:09 1148

转载 【字符串】KMP算法的实现

来源:脑客爱刷题 vector GetNextArr(const string &match) { vector NextArr; if (match.empty()) return NextArr; if (match.size() == 1) return vector(1, -1); NextArr = vector(match.size()); NextArr

2015-06-02 11:07:53 457

原创 leetcode - Contains Duplicate III

题目: Contains Duplicate III   Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j] is at mo

2015-06-02 09:36:49 1086

VC++程序: 将字符串转换成公式并计算结果

int Calculate(string formula) 函数功能:输入一个字符串公式string formula,允许四则混合运算,然后输入公式中对应变量的取值,最后返回int类型计算结果。 变量的格式:必须由1位字母加1位数字组成,如a1、b2等。 如输入字符串 “(a1+b2)/(-100)”,以及a1=100,b2=300,得到结果-4。遇到小数则向下取整。 公式的格式: 1、只包含变量、常数、四则符号、小括号四种符号,不支持大括号和中括号 2、允许正数前加正号,如+100 3、不允许空括号,如 “8*( )” 4、允许负数,但负数必须加括号,如 "5/(-1)"。当负数在公式开头时,可不加括号, 如 "-a1+90"和“+a1+90” 都是对的 5、允许纯常数公式,如 “5*(-9)” 6、允许用户输入多余的空格,但空格不能造成公式错误, 如公式 “(1 08+a2)/a 3” 是错的,(- 7)和(- n5)是错的,去掉空格就对了。

2014-10-23

N皇后问题C++代码

N皇后问题C++代码

2014-06-07

从上到下打印二叉树结点

用队列实现从上到下打印二叉树每个节点,同一层的节点按照从左到右的顺序打印。用C++实现。

2014-06-08

判断二叉搜索树的前序遍历

《剑指offer》面试题24的相关题目。输入一个整数数组,判断该数组是不是某二叉搜索树的前序遍历。假设输入的数组的任意两个数字互不相同。

2014-06-08

求字符的所有排列

求字符的全排列,如输入三个字符a、b、c,则它们的组合有a,b,c,ab,ac,bc,abc。

2014-06-08

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除