自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(20)
  • 收藏
  • 关注

原创 HMM(隐马尔可夫模型入门)

一、基本概念隐马尔可夫模型隐马尔可夫模型是关于时序的概率模型,描述由一个隐藏的马尔可夫链生成不可观测的状态随机序列,再由各个状态生成一个观测而产生观测随机序列的过程。隐藏的状态序列叫状态序列,每一个状态生成一个观测,由此生成的观测的随机序列叫观测序列。注意:这和分类有区别,这个一个序列。即P(Y|X)中X和Y都是序列。。一些参数隐马尔可夫模型由初始概率分布、状态转移概率分布、观测概率分布确定。

2016-06-30 22:43:57 739

原创 N语言模型(马尔科夫模型)介绍

一、马尔可夫链(语言模型方面) 假设一个长度为N的句子可以利用一串随机变量来表示,即x1, x2, …, xn,其中Xi ∈V。那么我们的语言模型是P(X1 = x1, X2 = x2,…,Xn = xn)。 显然,p(X1 = x1, X2 = x2, …, Xn = xn) = p(X1 = x1) * p(X2 = x2 | X1 = x1) * p(X3 = x3 | X

2016-06-30 21:29:23 2288

原创 87. Scramble String

2种思路: 1、递归+剪枝 2、dp思路一、递归判断 S1的左子串L和S2的右子串 && S1的右子串和S2的左子串 是否是Scramble String!! 或者 S1的左子串L和S2的左子串 && S1的右子串和S2的右子串 是否是Scramble String!! 如果是,则return true!!! 终止条件: 当len = 1时 剪枝:每次判断S1

2016-06-30 15:23:04 238

原创 85. Maximal Rectangle

题目: Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing all ones and return its area. 思路:(参考网上博文) 将该题转换成上一题Largest Rectangle in Histogram。 转换:public class Soluti

2016-06-29 23:27:13 224

原创 84. Largest Rectangle in Histogram

题目: 思路:(参考网上博文)详细博客 (1) 在height尾部添加一个0,也就是一个高度为0的立柱。作用是在最后也能凑成上面提的那种“波峰图”。(2) 定义了一个stack,然后遍历时如果height[i] 大于stack.top(),进栈。反之,出栈直到栈顶元素小于height[i]。由于出栈的这些元素高度都是递增的,我们可以求出这些立柱中所围成的最大矩形。更妙的是,由于这些被弹出的立柱处

2016-06-29 23:17:25 200

原创 java List与Array转换

一、list to array 的2种方法 List<String> list1 = new ArrayList<>(); list1.add("qf"); String[] array1 = new String[list1.size()]; list1.toArray(array1); //System.out.pri

2016-06-29 23:03:28 370

原创 归并排序空间复杂度O(1)的实现

正常的归并排序是利用分治法,即分解,解决,合并/*tmp_array[]:辅助数组。left_pos:数组左半部分的游标left_end:左边数组的右界限*/void Merge(int array[], int tmp_array[], int left_pos, int right_pos, int right_end) { int i, left_end, num_eleme

2016-06-27 22:29:39 7598 2

原创 LeetCode 115、Distinct Subsequences

2种方法 1、深度搜索 2、动态规划public class _115_ { int totalNum = 0; public int numDistinct(String s, String t) { helper2(s, t,0); return totalNum; } public void helper2(String

2016-06-27 18:57:16 231

原创 有序循环数组查找(无重复、有重复)

题目: 一、有序循环数组查找(无重复元素)。 有序数组如:01234 ,则 23401是一个有序循环数组思路: 二分查找,关键idea是:如果A[i]>=A[j]则【i,j】是有序的。abcdefg mid = ‘d’ 如果abcd有序,target不在abcd中,则对abc操作;如果target不在abcd中,则对efg操作 如果abcd无序,说明defg有序,如果target在def

2016-06-27 16:54:23 1325

原创 57. Insert Interval

题目: Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.Examp

2016-06-27 14:09:03 248

原创 连续最大子序列和的几种算法

题目: 连续子序列最大和,其实就是求一个序列中连续的子序列中元素和最大的那个。 比如例如给定序列: { -2, 11, -4, 13, -5, -2 } 其最大连续子序列为{ 11, -4, 13 },最大和为20 思路: 1、暴力解决O(N^2) 从0开始遍历,用max存储最大子串和public int maxSubArray1(int[]

2016-06-26 19:15:22 1283

原创 134. Gas Station

题目: There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to it

2016-06-26 15:17:16 221

原创 137. Single Number II

题目:Given an array of integers, every element appears three times except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using

2016-06-25 22:54:19 258

原创 136. Single Number

题目:Given an array of integers, every element appears twice except for one. Find that single one. 一开始没有考虑空间,直接用hashMap,也AC了public class Solution { public int singleNumber(int[] nums) { Hash

2016-06-25 22:28:54 268

原创 132. Palindrome Partitioning II

Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = “aab”, Return 1 since

2016-06-25 21:03:02 206

原创 [leetCode 131]Palindrome Partitioning

题目: 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”,”b”], [

2016-06-24 22:21:50 227

原创 [LeetCode129] Sum Root to Leaf Numbers

题目 Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the total sum o

2016-06-24 14:29:51 212

原创 [LeetCode] Longest Consecutive Sequence

题目: Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example, Given [100, 4, 200, 1, 3, 2], The longest consecutive elements sequence is [1, 2, 3

2016-06-24 14:10:53 263

原创 Binary Tree Maximum Path Sum

实现思路: 首先想到的是动态规划 + 后序遍历搜索。 1 / \ 2 3 maxPathValue = rightValue + leftValue + root.val; maxPathValue = 3 + 2 +1 leftValue 是左边分支最大的路径 rightValue 是右边分支最大的路径设置一个全局变量,用来存储最长的路径

2016-06-22 21:45:37 325

原创 Best Time to Buy and Sell Stock III

Best Time to Buy and Sell Stock III 首先想得的思路便是遍历 遍历数组,将数组分成左右2部分,分布对左右部分进行一次买卖,profit = leftProfit + rightProfit。public class Solution { public int maxProfit(int[] prices) { if(prices.l

2016-06-22 18:02:06 224

空空如也

空空如也

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

TA关注的人

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