- 博客(21)
- 收藏
- 关注
原创 [LeetCode 49]Group Anagrams(利用数据结构和排序简化问题)
问题描述49 Group Anagrams Given an array of strings, group anagrams together.For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”], Return:[ [“ate”, “eat”,”tea”], [“nat”,”tan”], [“bat”]
2017-03-30 09:31:20 294
原创 [LeetCode 3] Longest Substring Without Repeating Characters
class Solution {public: int lengthOfLongestSubstring(string s) { vector<int> charIndex(256, -1); int longest = 0, m = 0; for (int i = 0; i < s.length(); i++) { m = max(char
2017-02-26 23:31:29 202
原创 [LeetCode 15] 3Sum
class Solution {public: vector<vector<int>> threeSum(vector<int>& nums) { sort(nums.begin(),nums.end()); vector<vector<int>> res; for(int i=0;i<nums.size();i++) {
2017-02-26 23:29:08 278
原创 [LeetCode 77] Combinations(精妙的迭代)
题目内容77.Combinations Given two integers n and k, return all possible combinations of k numbers out of 1 … n.For example, If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2],
2017-02-08 23:25:16 385
原创 [LeetCode 199] Binary Tree Right Side View (递归的层数)
题目内容199 Binary Tree Right Side View Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example: Given th
2017-02-08 22:51:12 221
原创 [LeetCode 62] Unique Paths(教科书般的动态规划)
题目内容62 Unique PathsA robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying
2016-11-25 00:01:02 466
原创 [LeetCode 309] Best Time to Buy and Sell Stock with Cooldown(动态规划及进一步优化)
题目内容309 Best Time to Buy and Sell Stock with Cooldown Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may c
2016-11-24 19:29:31 213
原创 [LeetCode 424] Longest Repeating Character Replacement(滑动窗方法)
题目内容424 Longest Repeating Character ReplacementGiven a string that consists of only uppercase English letters, you can replace any letter in the string with another letter at most k times. Find the le
2016-11-22 21:02:38 470
原创 [LeetCode 137] Single Number II(位运算的巧妙运用初级篇)
题目内容137 Single Number II Given an array of integers, every element appears three times except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you im
2016-11-14 21:38:45 395
原创 [LeetCode 108] Convert Sorted Array to Binary Search Tree
题目内容108 Convert Sorted Array to Binary Search Tree Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 题目来源题目分析因为有序,此题不需要将数字插入二叉树时进行平衡二叉树操作。只需每次将数组中间的数字
2016-11-14 21:11:33 195
原创 [LeetCode 337] House Robber III
题目内容House Robber IIITotal Accepted: 29353 Total Submissions: 71912 Difficulty: Medium Contributors: AdminThe thief has found himself a new place for his thievery again. There is only one entrance
2016-11-12 19:04:13 232
原创 [LeetCode 144] Binary Tree Preorder Traversal(迭代法)
题目内容144 Binary Tree Preorder Traversal Given a binary tree, return the preorder traversal of its nodes’ values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1
2016-10-04 10:41:24 258
原创 [LeetCode 94]Binary Tree Inorder Traversal(迭代法)
题目内容94.Binary Tree Inorder Traversal Given a binary tree, return the inorder traversal of its nodes’ values. For example: Given binary tree [1,null,2,3],1 \ 2 / 3 return [1,3,2]
2016-10-04 10:20:40 274
原创 [LeetCode 136] Single Number
题目内容Single Number Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it
2016-08-29 23:38:43 273
原创 [LeetCode 278] First Bad Version(二分查找的一个常见注意点)
题目内容278.First Bad Version You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each versio
2016-08-28 23:06:13 554
原创 [LeetCode 7]Reverse Integer(处理整数溢出)
题目内容7.Reverse Interger 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 a
2016-08-28 20:05:24 507
原创 [LeetCode 107]Binary Tree Level Order Traversal II(递归法)
题目内容107 Binary Tree Level Order Traversal II Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root). For exa
2016-07-24 17:39:08 819
原创 [LeetCode 198] House Robber(动态规划)
题目内容 198 House Robber You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of t
2016-07-22 18:05:01 227
原创 [LeetCode 121]Best Time to Buy and Sell Stock(动态规划)
题目内容 121 Best Time to Buy and Sell Stock Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transact
2016-07-19 22:38:08 467
原创 [LeetCode 206] Reverse Linked List(迭代法)
题目内容 206.Reverse Linked List Reverse a singly linked list.题目来源代码示例//Reverse with iterationListNode* reverseList(ListNode* head) { ListNode* p=head; ListNode* q=NULL;
2016-07-08 23:40:04 393
原创 [LeetCode 169]Majority Element: Moore Voting Algorithm
问题来源**>169.Majority Element Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empt
2016-07-08 21:42:59 234
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人