P3295 [SCOI2016]萌萌哒 题目描述 一个长度为 nn 的大数,用 S_1S_2S_3 \cdots S_nS1?S2?S3??Sn?表示,其中 S_iSi? 表示数的第 ii 位, S_1S1? 是数的最高位。告诉你一些限制条件,每个条件表示为四个数,l_1,r_1,l_2,r_2l1 ...
分类:
其他好文 时间:
2020-05-04 19:10:08
阅读次数:
64
题目: 解答: 总的来说就是利用杨辉三角形后一行与前一行的关系。更新过程为:从倒数第二个元素开始往前更新 它等于原来这个位置的数 + 前一个位置的数行[i] = 行[i] + 行[i-1] 1 class Solution { 2 public: 3 vector<int> getRow(int r ...
分类:
编程语言 时间:
2020-05-04 17:33:24
阅读次数:
77
题目: 解答: 1 class Solution { 2 public: 3 int maxProfit(vector<int>& prices) 4 { 5 int profit = 0; 6 for (int i = 1; i < prices.size(); i++) 7 { 8 int tm ...
分类:
编程语言 时间:
2020-05-04 17:32:01
阅读次数:
63
题目: 解答: 1 class Solution { 2 public: 3 vector<int> twoSum(vector<int>& numbers, int target) 4 { 5 int low = 0; 6 int high = numbers.size() - 1; 7 8 wh ...
分类:
编程语言 时间:
2020-05-04 17:27:43
阅读次数:
67
用递归实现回溯法 注意:对于越界的检查是row>=matrix.length和col>=matrix[0].length要加上等号(这个错误找了半个小时呜呜呜) public class Solution { private int[][] act = {{0,1},{0,-1},{-1,0},{1 ...
分类:
其他好文 时间:
2020-05-04 17:23:52
阅读次数:
53
45. 跳跃游戏 II 题目来源: "https://leetcode cn.com/problems/jump game ii" 题目 给定一个非负整数数组,你最初位于数组的第一个位置。 数组中的每个元素代表你在该位置可以跳跃的最大长度。 你的目标是使用最少的跳跃次数到达数组的最后一个位置。 示例 ...
分类:
编程语言 时间:
2020-05-04 17:19:00
阅读次数:
66
这题是 55.跳跃游戏的升级版 ?? "力扣Leetcode 55. 跳跃游戏" 给定一个非负整数数组,你最初位于数组的第一个位置。 数组中的每个元素代表你在该位置可以跳跃的最大长度。 你的目标是使用最少的跳跃次数到达数组的最后一个位置。 示例: 解释: 跳到最后一个位置的最小跳跃数是 2。从下标为 ...
分类:
其他好文 时间:
2020-05-04 17:16:37
阅读次数:
56
1 class Trie 2 { 3 public: 4 bool is_end; //是否以该单词结尾 5 Trie* son[26]; //该节点儿子的个数 6 Trie() 7 { 8 is_end = false; 9 for(int i = 0;i < 26;i ++) son[i] = ...
分类:
其他好文 时间:
2020-05-04 00:37:49
阅读次数:
68
题目 https://leetcode cn.com/problems/find the kth smallest sum of a matrix with sorted rows/ 给你一个 m n 的矩阵 mat,以及一个整数 k ,矩阵中的每一行都以非递减的顺序排列。 你可以从每一行中选出 1 ...
分类:
编程语言 时间:
2020-05-03 20:16:18
阅读次数:
80
link class Solution { public: struct Comp{ bool operator()(vector<int>& v1, vector<int>& v2){ return v1[0]+v1[1]>v2[0]+v2[1]; } }; int kthSmallest(vec ...
分类:
其他好文 时间:
2020-05-03 20:13:29
阅读次数:
92