- 博客(19)
- 收藏
- 关注
原创 LeetCode-Reverse_Words_in_a_String_III
题目:Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:Input: "Let's take LeetCode contest"Ou...
2018-06-29 09:52:30 193
原创 C++小技巧
1.利用istringstream将字符串按空格分隔#include<sstream>string s="a b cd efg";string t="";istringstream is(s);while(s>>t) cout<<t; //t分别为a,b,cd,efg2.string.pop_back() 删除字符串的最后一个字符string...
2018-06-29 09:47:40 268
原创 LeetCode-Reverse_String_II
题目:Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of t...
2018-06-29 09:13:03 168
原创 LeetCode-Convert_BST_To_Greater_Tree
题目:Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.Examp...
2018-06-28 10:05:21 198
原创 LeetCode-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-28 09:11:52 152
原创 LeetCode-Array_Partition_I
题目:Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as p...
2018-06-27 10:19:37 166
原创 LeetCode-Minimum_Absolute_Difference_in_BST
题目:Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes.Example:Input: 1 \ 3 / 2Output:1Explanation:The m...
2018-06-27 10:00:49 125
原创 LeetCode-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 ...
2018-06-26 19:01:53 186
原创 LeetCode-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 w...
2018-06-26 14:26:26 173
原创 LeetCode-Perfect_Number
题目:We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself.Now, given an integer n, write a function that returns true when it is a perfe...
2018-06-25 15:24:11 163
原创 LeetCode-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-25 14:49:17 190
原创 LeetCode-Base_7
题目:Given an integer, return its base 7 string representation.Example 1:Input: 100Output: "202"Example 2:Input: -7Output: "-10"Note: The input will be in range of [-1e7, 1e7].翻译:给定一个数字,返回它的7进制字符串表示...
2018-06-21 10:19:33 155
原创 LeetCode-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 12:54:00 120
原创 LeetCode-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.Example 1:Input: ["Hello", "Alaska", "Dad", "Peace"]...
2018-06-20 09:22:35 187
原创 LeetCode-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-13 10:17:42 157
原创 LeetCode-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 lengt...
2018-06-12 10:52:28 131
原创 LeetCode-Max_Consecutive_Ones
题目:Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digits are consecutive 1s....
2018-06-04 10:03:54 269
原创 LeetCode-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 r...
2018-06-04 09:39:33 339
原创 LeetCode-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.Example:Input: 2Output: 987Explanati...
2018-06-02 10:52:16 223 1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人