Qt图形界面编程入门(1)——习题3.2 信号和槽 开始学习Qt的图形界面编程,买了清华大学出版社的《Qt图形界面编程入门》学习,做第三章的习题2。题目编写程序,一个对话框内有一个标签和一个按钮,标签对象初始显示0,每次单击按钮,标签显示的数字就加1。思路不需要传递内容,那么按钮信号用clicked,创建一个自定义的QLabel的派生类,添加一个AddNum函数,无参数。代码新建一个无UI向导的Dialog应用。头...
LeetCode 19. Remove Nth Node From End of List 题目描述Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked
LeetCode 18. 4Sum 题目描述Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: The solution se
LeetCode 17. Letter Combinations of a Phone Number 题目描述Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit string "2
LeetCode 16. 3Sum Closest (Two-Pointer) 题目描述Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exac
LeetCode 15. 3Sum (Medium) 题目描述Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.题目解析最直接的是三重循环; 由于要求去掉重复的答案,所以要先对nums排序;
LeetCode 14. Longest Common Prefix (easy) 题目描述Write a function to find the longest common prefix string amongst an array of strings.代码class Solution {public: string longestCommonPrefix(vector<string>& strs) { int n_str=strs.size()
LeetCode 13. Roman to Integer 题目描述Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.代码class Solution {public: int romanToInt(string s) { map<char,int>dig;
LeetCode 12. Integer to Roman 题目描述Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.题目解析将阿拉伯数字转换为罗马数字。 罗马数字表示方法: I-1,X-10,C-100,M-1000; V-5,L-50,D-500; 1. 相同的数字连写、所表示的数等
LeetCode 11. Container With Most Water(Two-Pointer 详解) 题目描述Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two
LeetCode 44. Wildcard Matching 题目描述Implement wildcard pattern matching with support for ‘?’ and ‘*’.‘?’ Matches any single character. ‘*’ Matches any sequence of characters (including the empty sequence).The matching should cover t
LeetCode 32. Longest Valid Parentheses(hard) 题目描述Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.For “(()”, the longest valid parentheses substring is “()”, which
动态规划解析 参考《算法导论》动态规划章节。 判断一个问题能否用动态规划解决,要求问题满足两个条件: 1)存在最优子结构,即一个问题可以通过n(n>=1)个选择划分成n或n+1个同类子问题+选择代价; 2)存在重叠子问题,不同的问题会重复调用同一个子问题;动态规划解决问题的步骤: 1)刻画一个最优解的结构特征,即寻找一个最优子结构; 2)一个递归求解方案; 3)计算最优解的值,两种方法
LeetCode 10. Regular Expression Matching(hard) 题目描述Implement regular expression matching with support for ‘.’ and ‘*’.‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element.The matching should cover the entire input st
LeetCode 9. Palindrome Number 题目描述Determine whether an integer is a palindrome. Do this without extra space.题目解析注意负数不是回文数;代码class Solution {public: bool isPalindrome(int x) { if(x==0) { return true;
LeetCode 8. String to Integer (atoi) 题目描述Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cas
LeetCode 7. Reverse Integer 题目描述Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321click to show spoilers.Have you thought about this? Here are some good questions to ask before coding. Bo
LeetCode 5. Longest Palindromic Substring 题目描述Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.题目解析找出最大的回文子串; 开始的想法是遍
LeetCode 4. Median of Two Sorted Arrays 题目描述 There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example 1:
LeetCode 3. Longest Substring Without Repeating Characters 题目描述Given a string, find the length of the longest substring without repeating characters.Examples:Given “abcabcbb”, the answer is “abc”, which the length is 3.Given “bbbbb”, the answer is “b”, with th