自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(226)
  • 收藏
  • 关注

原创 891. Valid Palindrome II

描述Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome.The string will only contain lowercase characters a-z. The maximum length of the string i...

2018-06-22 13:34:39 393

原创 900. Closest Binary Search Tree Value

描述Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target.Given target value is a floating point.You are guaranteed to have only one unique val...

2018-06-22 13:34:33 256

原创 914. 翻转游戏

描述翻转游戏:给定一个只包含两种字符的字符串:+和-,你和你的小伙伴轮流翻转"++"变成"--"。当一个人无法采取行动时游戏结束,另一个人将是赢家。编写一个函数,计算字符串在一次有效移动后的所有可能状态。您在真实的面试中是否遇到过这个题?  是样例给定 s = "++++", 在一次有效移动后,它会变成下列状态之一:[ "--++", "+--+", "++--"]如果无法

2018-06-22 13:34:25 1048

原创 916. 回文排列

描述给定一个字符串,判断字符串是否存在一个排列是回文排列。您在真实的面试中是否遇到过这个题?  是样例给定s = "code", 返回 False.给定s = "aab", 返回 True.给定s = "carerac", 返回 True.无难度题目,用关联容器保存数据即可。class Solution {public: /** * @param s: the given st...

2018-06-22 13:34:18 949

原创 920. 会议室

描述给定一系列的会议时间间隔,包括起始和结束时间[[s1,e1],[s2,e2],…(si < ei),确定一个人是否可以参加所有会议。您在真实的面试中是否遇到过这个题?  是样例给定区间=[[0,30],[5,10],[15,20]],返回false。这道题关键在于排序,但是我依据西方哲学家的名言:不要重复发明轮子。而使用了sort函数。/** * Definition of Inter...

2018-06-22 13:34:13 498

原创 888. 有效单词词广场

描述给定一个单词序列,检查它是否构成一个有效单词广场。一个有效的单词广场满足:如果第k行和第k列读取相同的字符串,并且0≤k<max(numRows numColumns)。给定的单词数量至少为1,且不超过500。单词长度至少为1,不超过500。每个单词只包含小写英文字母a-z。您在真实的面试中是否遇到过这个题?  是样例给定[ "abcd", "bnrt", "crmy",...

2018-06-21 19:51:01 662

原创 868. 子数组的最大平均值

描述给定一个由n个整数组成的数组,找到给定长度k的连续子数组,该子数组具有最大平均值。你需要输出最大平均值。1 <= k <= n <= 30,000.给定数组的元素将在范围[-10,000, 10,000]。您在真实的面试中是否遇到过这个题?  是样例给定nums = [1,12,-5,-6,50,3], k = 4,返回12.75解释:最大平均为(12-5-6+50)/4 ...

2018-06-21 19:43:10 505

原创 856. Sentence Similarity

描述Given two sentences words1, words2 (each represented as an array of strings), and a list of similar word pairs pairs, determine if two sentences are similar.For example, "great acting skills" and "f...

2018-06-21 19:12:08 162

原创 1199. Perfect Number

描述We define the Perfect Number is a positive integer that is equal to the sum of all its positivedivisors except itself.Now, given an integer n, write a function that returns true when it is a perfect...

2018-06-21 17:04:54 123

原创 1193. Detect Capital

描述Given a word, you need to judge whether the usage of capitals in it is right or not.We define the usage of capitals in a word to be right when one of the following cases holds:All letters in this wo...

2018-06-21 17:04:45 120

原创 1192. Longest Uncommon Subsequence I

描述Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is defined as the longest subsequence of one of these s...

2018-06-21 17:04:35 133

原创 1188. Minimum Absolute Difference in BST

描述Given a binary search tree with non-negative values, find the minimum absolute differencebetween values of any two nodes.There are at least two nodes in this BST.您在真实的面试中是否遇到过这个题?  是样例Input: 1 ...

2018-06-21 17:04:26 187

原创 1200. Relative Ranks

描述Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: "Gold Medal", "Silver Medal" and "Bronze Medal".Example 1:Input: [...

2018-06-21 17:04:17 185

原创 846. 多关键字排序

描述给定 n 个学生( 1 到 n 编号)以及他们的考试成绩,这里有两个关键字,考试成绩以及学生学号。根据第一关键字对数组进行排序(降序),如果第一关键字相同则根据第二关键字进行排序(升序).您在真实的面试中是否遇到过这个题?  是样例给出 [[2,50],[1,50],[3,100]],返回 [[3,100],[1,50],[2,50]]...

2018-06-21 17:02:48 895

原创 839. 合并两个排序的间隔列表

描述合并两个已排序的间隔列表,并将其作为一个新的排序列表返回。新的排序列表应该通过拼接两个列表的间隔并按升序排序。给定列表中的间隔一定不会重叠。不同列表中的间隔可能会重叠。您在真实的面试中是否遇到过这个题?  是样例给定 list1 = [(1,2),(3,4)] 和 list2 = [(2,3),(5,6)], 返回 [(1,4),(5,6)]....

2018-06-21 16:16:31 437

原创 1187. K-diff Pairs in an Array

描述Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are both numbers ...

2018-06-21 15:23:13 141

原创 1203. Find Mode in Binary Search Tree

描述Given a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element) in the given BST.Assume a BST is defined as follows:The left subtree of a node contains ...

2018-06-20 16:18:50 137

原创 1204. Keyboard Row

描述Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below.You may use one character in the keyboard more than on...

2018-06-20 15:56:05 130

原创 1206. Next Greater Element I

描述You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding places of nums2....

2018-06-20 15:14:28 213

原创 1209. Construct the Rectangle

描述For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length...

2018-06-20 10:38:30 140

原创 1214. License Key Formatting

描述You are given a license key represented as a string S which consists only alphanumeric character and dashes. The string is separated into N+1 groups by N dashes.Given a number K, we would want to re...

2018-06-20 10:08:19 166

原创 1320. Contains Duplicate

描述Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element ...

2018-06-20 08:49:56 106

原创 1319. Contains Duplicate II

描述Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at most k...

2018-06-20 08:49:43 181

原创 1219. Heaters

描述Winter is coming! Your first job during the contest is to design a standard heater with fixed warm radius to warm all the houses.Now, you are given positions of houses and heaters on a horizontal li...

2018-06-20 08:49:35 296

原创 1218. Number Complement

描述Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.1.The given integer is guaranteed to fit within the range of a 32-bit...

2018-06-20 08:49:25 115

原创 1216. Largest Palindrome Product

描述Find the largest palindrome made from the product of two n-digit numbers.Since the result could be very large, you should return the largest palindrome mod 1337.The range of n is [1,8].您在真实的面试中是否遇到过...

2018-06-20 08:49:16 147

原创 1314. Power of Two

描述Given an integer, write a function to determine if it is a power of two.您在真实的面试中是否遇到过这个题?  无难度题目class Solution {public: /** * @param n: an integer * @return: if n is a power of two ...

2018-06-19 16:10:11 114

原创 838. Subarray Sum Equals K

描述Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.您在真实的面试中是否遇到过这个题?  是样例Input:nums = [1,1,1], k = 2Output: 2基本思路都差不多,就是建立累...

2018-06-19 16:10:01 147

原创 1237. Number of Boomerangs

描述Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the ...

2018-06-19 16:09:51 108

原创 1225. Island Perimeter

描述You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completel...

2018-06-19 16:03:00 101

原创 1227. Repeated Substring Pattern

描述Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase Eng...

2018-06-19 15:03:37 78

原创 近期写题遇到的函数

1.ceil函数:用法:double ceil(double x)功能:返回大于或者等于指定表达式的最小整数头文件:cmath/math.h

2018-06-19 14:23:23 128

原创 1228. Poor Pigs

描述There are 1000 buckets, one and only one of them contains poison, the rest are filled with water. They all look the same. If a pig drinks that poison it will die within 15 minutes. What is the minim...

2018-06-19 14:20:03 162

原创 1230. Assign Cookies

描述Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a c...

2018-06-19 11:40:14 103

原创 1231. Minimum Moves to Equal Array Elements

描述Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.您在真实的面试中是否遇到过这个题?  是样例Input:[...

2018-06-19 11:06:45 81

原创 1236. Find All Numbers Disappeared in an Array

描述Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array.Could ...

2018-06-19 10:30:17 86

原创 1243. Number of Segments in a String

描述Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.the string does not contain any non-printable characters.您在真实的面试中是否遇到过这个题?  是...

2018-06-18 21:15:26 100

原创 1253. Convert a Number to Hexadecimal

描述Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used.1.All letters in hexadecimal (a-f) must be in lowercase.2.The hexadecimal str...

2018-06-18 20:48:21 97

原创 1254. Sum of Left Leaves

描述Find the sum of all left leaves in a given binary tree.您在真实的面试中是否遇到过这个题?  是样例 3 / \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 respectively....

2018-06-18 19:10:27 84

原创 1256. Nth Digit

描述Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...n is positive and will fit within the range of a 32-bit signed integer (n < 2^31).您在真实的面试中是否遇到过这个题?  是样例E...

2018-06-18 18:38:18 267

空空如也

空空如也

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

TA关注的人

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