先来放一波过程中用到的资料和官方文档好了。
basic layout_qt5.8
QBoxLayout Class_qt5.8
QString Class 5.8
QChar Class qt 5.8
Standard Dialogs Example qt 5.8
更新的部分还是放在最前面好了。
convert from QString to char *的时候有个坑。
In order to convert a QString to a char*, then you first need to get a latin1 representation of the string by calling toLatin1() on it which will return a QByteArray. Then call data() on the QByteArray to get a pointer to the data stored in the byte array. See the documentation: See the following example for a demonstration:
症状是不管安装什么,都会说有一大堆依赖无法安装。。。
大概是: a depends b[i],but b[i] is not be installed. (b==0..n)
最后会提示Unable to correct problems, you have held broken packages
解决办法:用synaptic工具,把可能存在问题的包都清除掉。
A peak element is an element that is greater than its neighbors.
Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.
The array may contain multiple peaks, in that case return the index to any one of the peaks is fine.
You may imagine that num[-1] = num[n] = -∞.
For example, in array [1, 2, 3, 1], 3 is a peak element and your function should return the index number 2.
Find the contiguous subarray within an array (containing at least one number) which has the largest product.
For example, given the array [2,3,-2,4], the contiguous subarray [2,3] has the largest product = 6.
思路:由于有正,有负,还有0.。。所以比最大子串之和要复杂一些。。。
dp[i].max表示到当前位置的最大乘积。
Given a sorted integer array without duplicates, return the summary of its ranges.
For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"].
题意:把连续的数连续表示
思路:模拟。注意有负数,注意有-2147483648这种数据。
本来还想着,可能是leetcode加数据的审核机制太松,导致被人加了奇怪的数据。。。
Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn’t one, return 0 instead.
For example, given the array [2,3,1,2,4,3] and s = 7, the subarray [4,3] has the minimal length under the problem constraint
思路:尺取即可。。好久没写,竟然调了半天。。。
代码实现 1/* *********************************************** 2Author :111qqz 3Created Time :2017年04月13日 星期四 20时48分00秒 4File Name :209.cpp 5************************************************ */ 6class Solution { 7 8public: 9 10 int ruler(vector<int>nums,int tar,int n) 11 { 12 int head = 0; 13 int tail = 0; 14 int sum = 0 ; 15 int res = 0x3f3f3f3f; 16 while (tail<n&&head<=tail) 17 { 18 sum = sum + nums[tail]; 19 if (sum>=tar) 20 { 21 res = min(res,tail-head+1); 22 while (sum>=tar&&head<tail) 23 { 24 sum-=nums[head]; 25 head++; 26 } 27 if (sum>=tar) 28 { 29 res = min(res,tail-head+1); 30 } 31 else 32 { 33 head--; 34 sum+=nums[head]; 35 res = min(res,tail-head+1); 36 } 37 } 38 39 40 41 tail++; 42 } 43 return res==0x3f3f3f3f?0:res; 44 } 45 46 47 int minSubArrayLen(int s, vector<int>& nums) { 48 int n = nums.size(); 49 int res = ruler(nums,s,n); 50 return res; 51 52 53 } 54 55};
Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.
题意:给你n个数,要求找出出现此处大于n/3的。。。
思路:之前做过一个找出n个数出现此处大于n/2的题目,思想是“非吾族类,其心必异”。。
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.
Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively.
题意:一个数组,由0,1,2组成,现在要求升序排列
思路:无脑做法就是计数排序,扫两遍,时间复杂度O(n),空间复杂度O(1)