自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

柯森锎的博客

学习的技术博客

  • 博客(97)
  • 收藏
  • 关注

原创 Qt图形界面编程入门(1)——习题3.2 信号和槽

开始学习Qt的图形界面编程,买了清华大学出版社的《Qt图形界面编程入门》学习,做第三章的习题2。题目编写程序,一个对话框内有一个标签和一个按钮,标签对象初始显示0,每次单击按钮,标签显示的数字就加1。思路不需要传递内容,那么按钮信号用clicked,创建一个自定义的QLabel的派生类,添加一个AddNum函数,无参数。代码新建一个无UI向导的Dialog应用。头...

2018-07-13 17:39:19 4195 1

原创 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

2016-11-24 22:14:44 453

原创 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

2016-11-23 23:17:13 448

原创 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

2016-11-17 22:58:52 392

原创 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

2016-10-23 17:59:20 365

原创 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排序;

2016-10-23 16:22:49 481

原创 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()

2016-10-23 16:12:14 310

原创 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;

2016-10-22 23:48:59 336

原创 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. 相同的数字连写、所表示的数等

2016-10-22 23:22:41 284

原创 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

2016-10-11 21:05:51 407

原创 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

2016-10-11 20:25:00 224

原创 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

2016-09-29 18:59:08 330

原创 动态规划解析

参考《算法导论》动态规划章节。 判断一个问题能否用动态规划解决,要求问题满足两个条件: 1)存在最优子结构,即一个问题可以通过n(n>=1)个选择划分成n或n+1个同类子问题+选择代价; 2)存在重叠子问题,不同的问题会重复调用同一个子问题;动态规划解决问题的步骤: 1)刻画一个最优解的结构特征,即寻找一个最优子结构; 2)一个递归求解方案; 3)计算最优解的值,两种方法

2016-09-26 23:03:38 439

原创 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

2016-09-25 21:22:28 333

原创 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;

2016-09-23 23:09:42 287

原创 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

2016-09-23 22:40:16 332

原创 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

2016-09-23 22:07:59 198

原创 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.题目解析找出最大的回文子串; 开始的想法是遍

2016-09-22 20:30:05 208

原创 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:

2016-09-21 23:27:18 305

原创 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

2016-09-21 19:27:54 262

原创 LeetCode 2. Add Two Numbers

题目描述You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a l

2016-09-20 21:46:31 343

原创 PAT甲级练习题A1097. Deduplication on a Linked List (25)

题目描述Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value o

2016-09-07 20:38:23 274

原创 PAT甲级练习题A1038. Recover the Smallest Number (30)

题目描述Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given {32, 321, 3214, 0229, 87}, we can recover many numbers such like 32-321-3214-022

2016-09-01 22:25:13 259

原创 PAT甲级练习题A1025. PAT Ranking (25)

题目描述Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklist

2016-08-17 21:09:48 430

原创 PAT甲级练习题A1024. Palindromic Number (25)

题目描述A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numb

2016-08-17 16:34:30 257

原创 PAT甲级练习题A1023. Have Fun with Numbers (20)

题目描述Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number

2016-08-17 15:46:34 315

原创 PAT甲级练习题A1022. Digital Library (30)

题目描述A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit numbe

2016-08-15 20:53:20 494

原创 PAT甲级练习题A1021. Deepest Root (25)

题目描述A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a ro

2016-08-15 17:05:27 243

原创 PAT甲级练习题A1020. Tree Traversals (25)

题目描述Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the

2016-08-14 20:30:26 467

原创 PAT甲级练习题A1018. Public Bike Management (30)

题目描述There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to any other stations in t

2016-08-12 22:54:19 1612

原创 PAT甲级练习题A1017. Queueing at Bank (25)

题目描述Suppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers have to wait in line behind the yellow

2016-08-12 18:06:26 313

原创 PAT甲级练习题A1016. Phone Bills (25)

题目描述A reversible prime in any number system is a prime whose “reverse” in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a

2016-08-12 16:41:22 319

原创 PAT甲级A1014. Waiting in Line (30)

题目描述Suppose a bank has N windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the customers to wait in line are:The spa

2016-08-10 19:08:11 502

原创 PAT甲级A1013. Battle Over Cities (25)

题目描述It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we

2016-08-10 17:03:33 353

原创 PAT甲级A1012. The Best Rank (25)

题目描述To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algebra), and E -

2016-08-10 15:28:50 389 4

原创 PAT甲级练习题A1007.Maximum Subsequence Sum (25)

题目描述Given a sequence of K integers { N1, N2, …, NK }. A continuous subsequence is defined to be { Ni, Ni+1, …, Nj } where 1 <= i <= j <= K. The Maximum Subsequence is the continuous subsequence which h

2016-08-03 22:19:45 351

原创 PAT甲级练习题A1004. Counting Leaves

题目描述A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. InputEach input file contains one test case. Each case starts with a line c

2016-07-17 21:19:57 807

原创 PAT甲级练习题A1003. Emergency

题目描述As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and th

2016-07-17 21:13:38 2031

原创 PAT甲级练习题A1002. A+B for Polynomials

题目描述This time, you are supposed to find A+B where A and B are two polynomials.InputEach input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polyno

2016-07-17 20:52:44 992

原创 链表

链表的本质就是一个个串联的节点,由一个虚拟零节点和其他节点组成,末尾的节点指向空或者是零节点。 链表的节点i由三个部分组成: 1. 节点地址loca; 2. 节点的值val; 3. 下一个节点的地址next;所以并不需要一定建立这样的节点结构,只要能够形成这三个要素就可以。 比如使用一个长度为n的数组或者vector A[n],A[0]作为零节点; 那么第i个节点,i->loca=i,i

2016-07-13 22:19:37 262

空空如也

空空如也

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

TA关注的人

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