自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 蓝桥杯 买不到的数目(DP动态规划巧解)C++实现

小明开了一家糖果店。他别出心裁:把水果糖包成4颗一包和7颗一包的两种。糖果不能拆包卖。 小朋友来买糖的时候,他就用这两种包装来组合。当然有些糖果数目是无法组合出来的,比如要买 10 颗糖。 你可以用计算机测试一下,在这种包装情况下,最大不能买到的数量是17。大于17的任何数字都可以用4和7组合出来。 本题的要求就是在已知两个包装的数量时,求最大不能组合出的数字。 输入 两个正整数,表示每种包装中糖的颗数(都不多于1000) 输出 一个正整数,表示最大不能买到的糖数 样例输入 4 7 样例输出

2020-07-19 03:36:28 318

原创 LeetCode 55. Jump Game (Greedy)

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 at that position. 数组中的每一个元素表示你在这个位置能跳跃的最大距离。 Determine if you a

2020-07-04 00:56:42 108

原创 LeetCode 54. Spiral Matrix 经典题目: 如何顺时针遍历二维数组

Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. 给定一个包含 m x n 个元素的矩阵(m 行, n 列),请按照顺时针螺旋顺序,返回矩阵中的所有元素。 Example 1: Input: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Output: [1,2,3,6,9,8,7,4,5] Exampl

2020-07-03 23:30:43 552

原创 LeetCode 53. Maximum Subarray (DP) C++

Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. 给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。 Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation: [4,

2020-07-03 16:03:20 116

原创 LeetCode 52. N-Queens II 回溯法+约束编程 C++

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return the number of distinct solutions to the n-queens puzzle. n 皇后问题研究的是如何将 n 个皇后放置在 n×n 的棋盘上,并且使皇后彼此之间不能相互攻击。 给定一个

2020-07-02 08:54:20 118

原创 LeetCode 51. N-Queens 回溯法配合约束编程 C++

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. Each solution contains a distinct board configuration of the n-

2020-07-02 08:40:47 108

空空如也

空空如也

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

TA关注的人

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