最新文章列表

给定一个整数数组,找出总和最大的连续数列

题目:https://leetcode-cn.com/problems/contiguous-sequence-lcci 给定一个整数数组,找出总和最大的连续数列,并返回总和。   示例:   输入: [-2,1,-3,4,-1,2,1,-5,4] 输出: 6 解释: 连续子数组 [4,-1,2,1] 的和最大,为 6。   解题: 用变量去记录连续数列总和的最大值。 用另一 ...
ChenghuiZ 评论(0) 有1107人浏览 2020-06-18 14:27

按摩师问题-双一百解法

 题目:https://leetcode-cn.com/problems/the-masseuse-lcci/ 一个有名的按mo师会收到源源不断的预约请求,每个预约都可以选择接或不接。在每次预约服务之间要有休息时间,因此她不能接受相邻的预约。给定一个预约请求序列,替按mo师找到最优的预约集合(总预约时间最长),返回总的分钟数。   示例 1:   输入: [1,2,3,1] 输出: ...
ChenghuiZ 评论(0) 有277人浏览 2020-06-18 14:13

最大正方形

在一个二维01矩阵中找到全为1的最大正方形 您在真实的面试中是否遇到过这个题?  Yes 样例 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 返回 4 题目地址 动态规划的办法,我们可以先求出正方形最大的边长,我们推导出的公式是,原来的数组是arr[][];f[][]是存储结果的表,当最大正方形包括 ...
陶永攀 评论(0) 有575人浏览 2017-11-15 18:16

K数和

题目: 给定n个不同的正整数,整数k(k < = n)以及一个目标数字。  在这n个数里面找出K个数,使得这K个数的和等于目标数字,求问有多少种方案? 您在真实的面试中是否遇到过这个题?  Yes 样例 给出[1,2,3,4],k=2, target=5,[1,4] and [2,3]是
陶永攀 评论(0) 有405人浏览 2017-11-15 18:12

社区内互不相邻的房间内财物之和的最大值

一个很有意思的问题,一个社区,所有的房子构成一棵二叉树,每个房子里有一定价值的财物,这棵二叉树有一个根节点root。如果相邻的两座房子同时被进入,就会触发警报。一个小偷,最初只能访问root节点,并可以通过二叉树的边访问房子(注:访问不意味着进入),请问不触发警报的前提下他能偷到的财物的最大价值是多少? 以下面这棵二叉树为例,最多能偷走3+3+1=7的财物         3     / \ ...
xglv2013 评论(0) 有2248人浏览 2016-07-06 19:43

隐马尔可夫模型之:维特比算法

        接上一篇博客的内容,给出利用已知的隐马尔可夫模型和观察状态序列,输出最可能的隐藏状态序列的算法,该算法由著名信息学大师维特比提出,所以叫做维特比算法(viterbi algorithm),这其实是一个解码的过程。维特比算法依然利用动态规划,时间复杂度跟前向算法相同,最大的区别有两个:1.求和变为取最大值,即计算问题变为最优化问题 2.增加了回溯,利用一个前驱数组,记录了每条最优(也就 ...
xglv2013 评论(0) 有2304人浏览 2016-06-25 18:47

隐马尔可夫模型之:前向算法

隐马尔可夫模型(hidden markov model 简称hmm)广泛应用于语音识别,机器翻译等领域。 隐马尔可夫模型的具体定义,请参考著名论文《A tutorial on Hidden Markov Models and selected applications in speech recognition》,在阅读以下内容之前,建议读者阅读这篇论文的第I II III 节,理论性的东西在此不 ...
xglv2013 评论(0) 有2516人浏览 2016-06-23 20:53

Coin Change

You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money c ...
KickCode 评论(0) 有783人浏览 2016-02-29 04:39

Longest Increasing Subsequence

Given an unsorted array of integers, find the length of longest increasing subsequence. For example, Given [10, 9, 2, 5, 3, 7, 101, 18], The longest increasing subsequence is [2, 3, 7, 101], therefore ...
KickCode 评论(0) 有384人浏览 2016-02-28 04:22

Ugly Number II

Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ug ...
KickCode 评论(0) 有696人浏览 2016-02-25 03:36

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 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Retu ...
KickCode 评论(0) 有549人浏览 2016-02-21 03:37

House Robber II

Note: This is an extension of House Robber. After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time, a ...
KickCode 评论(0) 有572人浏览 2016-02-21 01:21

House Robber

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses ...
KickCode 评论(0) 有363人浏览 2016-02-18 02:20

Word Break

Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For example, given s = "leetcode", dict = [& ...
KickCode 评论(0) 有524人浏览 2016-02-13 03:05

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", Re ...
KickCode 评论(0) 有307人浏览 2016-02-12 04:36

Best Time to Buy and Sell Stock II

Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one a ...
KickCode 评论(0) 有439人浏览 2016-02-11 01:42

Best Time to Buy and Sell Stock

Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), de ...
KickCode 评论(0) 有521人浏览 2016-02-10 05:34

Triangle

Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [      [2],     [3,4],    [6,5,7] ...
KickCode 评论(0) 有632人浏览 2016-02-10 02:53

Distinct Subsequences

Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) ...
KickCode 评论(0) 有535人浏览 2016-02-09 09:42

Decode Ways

A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given an encoded message containing digits, determine the total ...
KickCode 评论(0) 有960人浏览 2016-02-05 08:23

最近博客热门TAG

Java(141747) C(73651) C++(68608) SQL(64571) C#(59609) XML(59133) HTML(59043) JavaScript(54918) .net(54785) Web(54513) 工作(54116) Linux(50906) Oracle(49876) 应用服务器(43288) Spring(40812) 编程(39454) Windows(39381) JSP(37542) MySQL(37268) 数据结构(36423)

博客人气排行榜

    博客电子书下载排行

      >>浏览更多下载

      相关资讯

      相关讨论

      Global site tag (gtag.js) - Google Analytics