自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 每日一题 day59 (Dp topic)

文章目录problemapproach 1 `recursive TLE`approach 2 `dp`problem377. Combination Sum IVGiven an array of distinct integers nums and a target integer target, return the number of possible combinations that add up to target.The test cases are generated so tha

2022-03-30 23:30:06 391 1

原创 每日一题 day 58(DP topic)

文章目录problemwrong approachapproach `memorize dp`problem518. Coin Change 2You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.Return the number of combinations that

2022-03-25 00:04:09 311

原创 每日一题 day 57 (DP topic)

文章目录problem `classical bag problem`wrong approach `59/188, Greedy`wrong approach 2 `TLE, recursive`appraoch 3 `memorize dp`approach `bag problem , dp`problem classical bag problem322. Coin ChangeYou are given an integer array coins representing coins of

2022-03-24 00:15:48 497 2

原创 蓝桥杯 时间显示

文章目录题目代码题目纯送分题代码#include<iostream>#include<stdio.h>>using namespace std;int main(){ long long x; cin >> x; int mods = 24*60*60*1000;//1 day's ms int mods_h = 60*60*1000;//1 hour's ms int mods_m = 60*1000; int mods_s =

2022-03-23 21:56:27 807

原创 蓝桥杯 杨辉三角

文章目录题目代码题目参考链接代码#include <iostream>#include <cstring>#include <algorithm>using namespace std;typedef long long LL;int n;LL C(int a, int b) //计算C(a,b){ LL res = 1; for(int i = a, j = 1; j <= b; i --, j ++)

2022-03-22 20:41:01 514

原创 每日一题 day 56(DP topic)

文章目录problemapproach `DP`approach `shorter code`wrong approachproblem1143. Longest Common SubsequenceGiven two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0.A subsequence of a

2022-03-20 21:22:03 222

原创 每日一题 day 55(DP topic)

文章目录problemapproach 1approach 2 `shorter code`problem392. Is SubsequenceGiven two strings s and t, return true if s is a subsequence of t, or false otherwise.A subsequence of a string is a new string that is formed from the original string by deleting

2022-03-18 23:55:22 220

原创 每日一题 day 54 (DP topic)

文章目录problemapproach 1 `Brute force`approach 3 `Greedy`problem376. Wiggle SubsequenceA wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) m

2022-03-17 15:15:19 281

原创 OS笔记1 进程与线程

文章目录前言进程的基本概念进程的属性内存模型的中的进程映像线程的基本概念进程间的组织关系进程与线程前言操作系统浩如烟海,而进程是OS中相当重要的一个概念,在阅读了lqm老师的进程控制的pdf之后,我打算进行一些自我总结与提炼,若有笔误,恳请指正。进程的基本概念进程的属性一个进程含有多个属性,进程在linux系统中有一个结构体的定义,而这个结构体里包含了很多属性,主要有:进程控制块 PCB (task_tsruct )( 在内核空间中 )(线程也有PCB!)内存描述符 mm_struct (

2022-03-16 21:37:48 315

原创 每日一题 day 53 (DP topic)

文章目录problemapproach 1 `DP`approach 2 `Greedy with Binary search`approach 3 ` Binary Indexed Tree` `others approach`problem300. Longest Increasing SubsequenceGiven an integer array nums, return the length of the longest strictly increasing subsequence.A

2022-03-16 11:46:26 638

原创 字符串DP问题

文章目录前言例题1例题2前言对于一些字符串问题,比如求一串字符中最长的回文串,或者是一些回文串的变种问题,我们一般可以使用一个二维的DP数组来保存计算的结果,从而减少计算量,下面我用两个例题来解释例题1例题的链接例题2516. Longest Palindromic Subsequence给定一个字符串s,找出s中最长的回文子序列的长度。子序列是一个序列,可以通过删除部分或不删除元素而从另一个序列派生,而不改变其余元素的顺序。我们可以将一个字符串的任意字串用一个二维DP数组来表示,比如s[

2022-03-15 10:57:13 245

原创 每日一题 day 52 (DP topic)

文章目录problemapproach 1problem516. Longest Palindromic SubsequenceGiven a string s, find the longest palindromic subsequence’s length in s.A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without chang

2022-03-15 10:13:25 172

原创 每日一题 day 51 (DP topic)

文章目录problemapproach 1problem221. Maximal SquareGiven an m x n binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area.Example 1:Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","

2022-03-14 22:19:50 491

原创 二维DP问题

文章目录前言小技巧例题 1方法一 求组合数方法二 动态规划例题 2方法一 dp例题 3方法一 dp前言我们经常会碰到二维DP问题,比如给你一张地图(一般是二维矩阵),让你计算出从地图的左上端走到右下端的路径有多少条 / 最短的路径之和,这种问题一般会被限制运动的空间(至少我现在所碰到的题目),一般是只能向下和向右移动。我对dp问题理解不深,对于二维dp问题我的理解就是找出最优子结构(递推方程)之后,用一个二维数组来保存历史状态就能解决问题了小技巧一般这种问题很容易被矩阵上边和左边这两条bounda

2022-03-13 12:38:49 2501

原创 每日一题 day 50(DP topic)

文章目录problemapproach 1`DP`approach 2 `DP less space`problem64. Minimum Path SumGiven a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path.Note: You can only move

2022-03-13 11:58:30 106

原创 每日一题 day 49 (DP topic)

文章目录problemapproach 1 `DP`approach 2 `DP merge two loop`approach 3 `others dp`approach 4 `others dp, less space`problem63. Unique Paths IIA robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only

2022-03-12 16:21:50 117

原创 求组合数算法(大数板子)

代码long C(int m, int n) { if(m < n) swap(m, n); long res = 1; for(int i = m+1, j=1; i <= m+n; i++, j++){ // Instead of taking factorial, keep on multiply & divide res *= i; res /= j; } return res;}例题链

2022-03-11 17:12:17 183

原创 每日一题 day48 (DP topic)

文章目录problemapproach `permutation`approach 1 `DP`approach 2 `DP improve`problem62. Unique PathsThere is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner

2022-03-11 17:09:27 263

原创 每日一题 day 47 (DP topic)

文章目录problemapproachproblem304. Range Sum Query 2D - ImmutableGiven a 2D matrix matrix, handle multiple queries of the following type:Calculate the sum of the elements of matrix inside the rectangle defined by its upper left corner (row1, col1) and low

2022-03-10 12:42:19 103

原创 数组前缀和解决二维DP问题

文章目录用法例题1用法例题1题目链接

2022-03-09 15:11:58 164

原创 每日一题 day 46 (DP topic)

文章目录problemwrong approach 1 `TLE`approach 2 `DP`approach 3 `wonderful DP`problem1314. Matrix Block SumGiven a m x n matrix mat and an integer k, return a matrix answer where each answer[i][j] is the sum of all elements mat[r][c] for:i - k <= r <

2022-03-09 14:41:29 128

原创 每日一题 day45 (DP topic)

文章目录problemapproach 1approach 2 `with some trick`problem931. Minimum Falling Path SumGiven an n x n array of integers matrix, return the minimum sum of any falling path through matrix.A falling path starts at any element in the first row and chooses th

2022-03-08 10:21:37 100

原创 每日一题 day 44 (DP topic)

文章目录problemmy approachproblem118. Pascal’s TriangleGiven an integer numRows, return the first numRows of Pascal’s triangle.In Pascal’s triangle, each number is the sum of the two numbers directly above it as shown:Example 1:Input: numRows = 5Output

2022-03-07 13:39:53 73

原创 每日一题 day 43 (DP topic)

文章目录problemwrong approachapproach 1problemwrong approachclass Solution {public: int numTrees(int n) { vector<int> dp(23, 0); dp[0] = 1, dp[1] = 1, dp[2] = 2; for(int i=3; i<=n; i++){ if(i%2){

2022-03-06 15:44:28 86

原创 每日一题 day 42 (DP topic)

文章目录problemapproachproblem264. Ugly Number IIAn ugly number is a positive integer whose prime factors are limited to 2, 3, and 5.Given an integer n, return the nth ugly number.Example 1:Input: n = 10Output: 12Explanation: [1, 2, 3, 4, 5, 6, 8, 9, 1

2022-03-05 15:21:38 183

原创 每日一题 day 41 (DP topic)

文章目录problemwrong approachwrong approach `tle`dfs + memorizationproblem91. Decode WaysA message containing letters from A-Z can be encoded into numbers using the following mapping:'A' -> "1"'B' -> "2"...'Z' -> "26"To decode an encoded mess

2022-03-04 17:27:00 292

原创 每日一题 day 40 (DP topic)

文章目录problemapproach 1 `brute force`approach 2 `without extra space`approach 3 `shortest code, but not best`problem413. Arithmetic SlicesAn integer array is called arithmetic if it consists of at least three elements and if the difference between any tw

2022-03-03 13:03:23 136

原创 树形DP问题

文章目录前言例题 1DFS剪枝(树形DP)前言这段话引用自这位佬在树形动态规划当中,我们一般先算子树再进行合并,在实现上与树的后序遍历相似,都是先遍历子树,遍历完之后将子树的值传给父亲。简单来说我们动态规划的过程大概就是先递归访问所有子树,再在根上合并那可能就有人会问了,这不就是树的后序遍历吗?递归计算完所有子树后将值返回给父节点,跟DP有啥子关系?其实是因为在很多此类问题中,很多时候会产生重复的计算(递归的通病),所以我们需要将计算结果记忆化,以减少计算量我的个人理解是 树形DP = DFS+

2022-03-03 11:25:06 253

原创 每日一题 day 39 (dp topic)

文章目录problemapproach 1 `TLE`approach 2 `DP`approach 3 `two point`wrong approachproblem42. Trapping Rain WaterGiven n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.E

2022-03-02 17:23:49 151

原创 每日一题 day 38 (DP topic)

文章目录problemwrong solution 1 `Brute force recursive`solution 2 `dp`solution 3 `DFS + prune`problem139. Word BreakGiven a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dicti

2022-03-01 12:16:15 296

原创 每日一题 day 37 (DP topic)

文章目录solutionNOTE714. Best Time to Buy and Sell Stock with Transaction FeeYou are given an array prices where prices[i] is the price of a given stock on the ith day, and an integer fee representing a transaction fee.Find the maximum profit you can achiev

2022-02-28 12:36:43 290

原创 美赛用到的可视化技巧

文章目录敏感度分析Xgboost画特征重要性设置坐标轴格式敏感度分析import numpy as npimport pandas as pdfrom pyecharts import options as optsfrom pyecharts.charts import Bar3Dfrom pyecharts.faker import Fakerimport randomfrom pyecharts.globals import ThemeType data = [(i, j, j*0

2022-02-27 13:28:54 542

原创 有限状态机解DP问题

文章目录前言例题1解释例题2解释前言在写某些动态规划问题的时候,把问题描述为有限状态机的形式可以帮助我们解决这种DP问题下面将用两道例题来解释例题1You are given an integer array prices where prices[i] is the price of a given stock on the ith day.On each day, you may decide to buy and/or sell the stock. You can only hold a

2022-02-27 13:08:14 352

原创 每日一题 day 36 (DP topic)

文章目录solution 1solution 2solution 3NOTE309. Best Time to Buy and Sell Stock with CooldownYou are given an array prices where prices[i] is the price of a given stock on the ith day.Find the maximum profit you can achieve. You may complete as many transact

2022-02-27 12:40:57 291

原创 每日一题 day 35 (DP topic)

文章目录my solutionsolution 2 `good solution`solution 3 `best and fastest solution`NOTE122. Best Time to Buy and Sell Stock IIYou are given an integer array prices where prices[i] is the price of a given stock on the ith day.On each day, you may decide to b

2022-02-26 15:14:19 79

原创 力扣第三十四天(DP topic)

文章目录problem Ⅰsolution 1problem Ⅱwrong solutioncorrect solutionproblem Ⅰ1014. Best Sightseeing PairYou are given an integer array values where values[i] represents the value of the ith sightseeing spot. Two sightseeing spots i and j have a distance j - i

2022-02-26 01:21:46 70

原创 力扣第三十三天(DP topic)

文章目录problem Ⅰsolutionproblem Ⅱsolutionproblem Ⅰ152. Maximum Product SubarrayGiven an integer array nums, find a contiguous non-empty subarray within the array that has the largest product, and return the product.The test cases are generated so that the

2022-02-25 00:23:48 503

原创 力扣第三十二天(DP topic)

文章目录problem Ⅰsolution 1solution 2 `without dp array`problem Ⅱsolutionproblem Ⅰ53. Maximum SubarrayGiven an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.A subarray is a co

2022-02-18 00:07:46 346

原创 力扣第三十一天(DP topic)

文章目录problem Ⅰsolution 1solution 2problem Ⅱsolutionproblem Ⅰ55. Jump GameYou are given an integer array nums. You are initially positioned at the array’s first index, and each element in the array represents your maximum jump length at that position.Ret

2022-02-17 01:17:04 8192

原创 力扣第三十天(DP topic)

文章目录problem Ⅰsolution 1problem Ⅱsolution 1problem Ⅰ213. House Robber IIYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means t

2022-02-16 02:06:00 279

空空如也

空空如也

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

TA关注的人

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