自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

hidentity的博客

一个心理学本科生用来记录代码的博客

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

原创 LeetCode 132. Palindrome Partitioning II

Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs.Example:Input:"aab"Output: 1Explana...

2019-03-03 15:59:01 113

原创 LeetCode 765. Couples Holding Hands

N couples sit in 2N seats arranged in a row and want to hold hands. We want to know the minimum number of swaps so that every couple is sitting side by side. A swapconsists of choosing any two people,...

2019-02-22 01:37:31 130

原创 LeetCode 041.First Missing Positive

Given an unsorted integer array, find the smallest missing positive integer.Example 1:Input: [1,2,0]Output: 3Example 2:Input: [3,4,-1,1]Output: 2Example 3:Input: [7,8,9,11,12]Outpu...

2019-02-21 23:18:20 85

原创 LeetCode 456.132 Pattern

Given a sequence of n integers a1, a2, ..., an, a 132 pattern is a subsequence ai, aj, ak such that i < j < k and ai < ak < aj. Design an algorithm that takes a list of n numbers as input ...

2018-09-26 14:37:38 136

原创 LeetCode 044.Wildcard Matching

Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the...

2018-09-25 19:07:04 96

原创 LeetCode 030.Substring with Concatenation of All Words

You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in sthat is a concatenation of each word in words exactly once and wit...

2018-09-25 18:50:14 105

原创 LeetCode 719.Find K-th Smallest Pair Distance

Given an integer array, return the k-th smallest distance among all the pairs. The distance of a pair (A, B) is defined as the absolute difference between A and B.Example 1:Input:nums = [1,3,1]...

2018-09-24 18:29:26 274

原创 LeetCode 045.Jump Game 2

Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to...

2018-09-17 22:35:46 125

原创 LeetCode 004.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)).You may assume nums1 and n...

2018-09-13 21:30:47 148

原创 PAT A1096.Consecutive Factors

Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3*5*6*7, where 5, 6, and 7 are the three consecutive numbers. Now given

2017-09-09 21:08:01 234

原创 PAT A1016.Phone Bills

A long-distance telephone company charges its customers by the following rules:Making a long-distance call costs a certain amount per minute, depending on the time of day when the call is made. Wh

2017-05-27 21:34:39 192

原创 PAT A1101.Quick Sort

There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot are moved to its le

2017-05-27 21:28:21 214

原创 PAT A1078.Hashing

1078. Hashing (25)时间限制100 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueThe task of this problem is simple: insert a seque

2017-05-27 17:58:00 202

原创 PAT A1010. Radix PAT和牛客网全A思路以及PAT上测试例10的讨论

就是这个想法,导致了测试例10的错误。我之前特费解,测试例10的内容到底是啥,好像有很多人错,甚至还有人说测试例10有问题,PAT平台上的答案有错误。看到有人贴出的全A的代码中,只要添上一段if(str1==str2) cout<<Radix;这样的代码,就能通过测试例10,我更加不解了。很显然这段代码是错误的。举个例子,如果一个测试例的内容是“1 1 1 10”,显然正确答案是2。但是如果添上上述的那段代码,这个测试例的输出会变成10,是错误的。

2017-04-09 21:38:51 682

原创 PAT A1007. Maximum Subsequence Sum

这道题的动态规划思想非常简单:(1)记录以第i位为结尾的所有连续子串中,sum最大的那一个连续子串的sum和起始点。举两个例子————串{1 2 3 4 5 6}中,以3为尾时,最大连续子串和为6(1+2+3),起始点为1;在串{-1 -2 3 4 5 6}中,以3为尾时,最大连续子串和为3,起始点就是3。

2017-04-07 18:42:54 185

原创 PAT A1002. A+B for Polynomials

用map就可以很轻松地写出来,但是提交之后只对了前三个测试例,费解很久。为了不浪费时间,最后还是去牛客网上试了测试例,发现是因为系数为0的项应该被及时去除。知道这个原因后稍作修改就AC了。

2017-04-07 17:42:26 196

原创 PAT A1072. Gas Station

一道简单的图算法题,我的做法是对每个Candidate节点做一次迪杰斯特拉算法,然后选择最优的节点。唯一需要注意的一点是这道题的节点选择条件比较绕

2017-04-07 15:35:07 606 1

原创 PAT A1001. A+B Format

Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).InputEach input file cont

2017-04-06 19:31:21 222

原创 PAT A1005. Spell It Right

Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.Input Specification:Each input file contains one test case.

2017-04-06 19:06:54 327

原创 PAT A1018. Public Bike Management

PAT A1018. Public Bike Management

2017-04-06 13:48:33 308

原创 PAT A1082. Reading Number in Chinese

PAT A1082. Reading Number in Chinese

2017-04-05 21:04:00 642

空空如也

空空如也

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

TA关注的人

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