上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 17 下一页
摘要: scanf() ####函数会根据参数中的转义说明获取对应的值的类型,在获取值的时候会自动跳过前面的若干空格、制表符以及换行符(\n),如下图所示。 ####scanf()只会获取第一个符合转移说明的值,如果没有获取到那么原本输入队列中的值不会改变,仍旧在输入队列中。 ####scanf()只会回去 阅读全文
posted @ 2022-11-29 17:38 破忒头头 阅读(159) 评论(0) 推荐(0)
摘要: #include <stdio.h> //指向类型为 unsigned char 类型的对象指针 typedef unsigned char *byte_pointer; //size_t 32位4字节 64位8字节 void show_bytes(byte_pointer start,size_t 阅读全文
posted @ 2022-11-17 19:03 破忒头头 阅读(30) 评论(0) 推荐(0)
摘要: LeetCode 167.TowSum 双指针 class Solution { public: vector<int> twoSum(vector<int>& numbers, int target) { int l = 0,r = numbers.size()-1,sum=0; while(l<r){ sum = numbers[l] 阅读全文
posted @ 2022-11-13 23:22 破忒头头 阅读(25) 评论(0) 推荐(0)
摘要: ![](https://img2022.cnblogs.com/blog/2836885/202211/2836885-20221113152017188-1445824613.png) ![](https://img2022.cnblogs.com/blog/2836885/202211/2836885-20221113152052218-1554518467.png) 阅读全文
posted @ 2022-11-13 15:20 破忒头头 阅读(17) 评论(0) 推荐(0)
摘要: LeetCode 665. 非递减数列 class Solution { public: bool checkPossibility(vector<int>& nums) { int n = nums.size(); for(int i=0;i<n-1;i++){ int x = nums[i],y = nums[i+1]; if(x>y 阅读全文
posted @ 2022-11-12 23:44 破忒头头 阅读(28) 评论(0) 推荐(0)
摘要: LeetCode 406.根据身高重建队列 首先根据身高从小到大排序如果身高相等那么根据第二个值降序排序 class Solution { public: vector<vector<int>> reconstructQueue(vector<vector<int>>& people) { int n = people.size(); sor 阅读全文
posted @ 2022-11-11 23:13 破忒头头 阅读(18) 评论(0) 推荐(0)
摘要: LeetCode 122. 买卖股票的最佳时机 II 就是不断寻找最长的非递增序列 class Solution { public: int maxProfit(vector<int>& prices) { if(prices.empty()||prices.size()<2){ return 0; } int i=0; int res = 0; in 阅读全文
posted @ 2022-11-10 17:40 破忒头头 阅读(24) 评论(0) 推荐(0)
摘要: LeetCode 763. 划分字母区间 1、一上来先遍历数组,找到每个字母最后出现的位置。 2、再次遍历数组,保持一个last,表示当前至少应该在哪里分割 class Solution { public: vector<int> partitionLabels(string s) { //先遍历一遍数组,记录每一个字母最后出现的位置; i 阅读全文
posted @ 2022-11-10 17:12 破忒头头 阅读(44) 评论(0) 推荐(0)
摘要: LeetCode 452. 用最少数量的箭引爆气球 贪心 1、先按照所有起球的右边界排序,记录第一个气球的右边界位置,如果后续气球的左边界小于记录中的值那么这个气球就是可以被箭射中的,这种情况不做处理。 2、当出现遍历的时候某一个起球的左边界大于当前记录中的值的时候,那么此时第一个箭就射不中当前的气球了,所以箭的数量++,并且记录中的值等于当前遍历气 阅读全文
posted @ 2022-11-10 16:17 破忒头头 阅读(32) 评论(0) 推荐(0)
摘要: LeetCode 605. 种花问题 贪心 class Solution { public: bool canPlaceFlowers(vector<int>& flowerbed, int n) { int m = flowerbed.size(); int pre = -1; for(int i=0;i<m;i++){ //寻找区间 阅读全文
posted @ 2022-11-09 17:48 破忒头头 阅读(24) 评论(0) 推荐(0)
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 17 下一页