Leetcode
文章平均质量分 71
dolphin_wby
这个作者很懒,什么都没留下…
展开
-
Leetcode 74: Search a 2D Matrix
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each原创 2015-12-15 08:46:09 · 240 阅读 · 0 评论 -
Leetcode 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"]]Note:原创 2015-12-17 07:05:22 · 476 阅读 · 0 评论 -
Leetcode 165: Compare Version Numbers
Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.You may assume that the version strings are non-empty and co原创 2015-12-17 07:37:22 · 277 阅读 · 0 评论 -
Leetcode 240: Search a 2D Matrix II
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Integers in原创 2015-12-15 09:03:35 · 219 阅读 · 0 评论 -
Leetcode 280: Wiggle Sort
Given an unsorted array nums, reorder it in-place such that nums[0] = nums[2] .For example, given nums = [3, 5, 2, 1, 6, 4], one possible answer is [1, 6, 2, 5, 3, 4].Solution:The rule原创 2015-12-15 09:27:47 · 356 阅读 · 0 评论 -
Leetcode 162: Find Peak Element
A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple peaks, in原创 2015-12-15 08:29:08 · 255 阅读 · 0 评论 -
Leetcode 154: Find Minimum in Rotated Sorted Array II
Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Solution:If there are duplicates in the rotated a原创 2015-12-15 08:18:42 · 317 阅读 · 0 评论 -
Leetcode 153: Find Minimum in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate exists in原创 2015-12-15 07:43:27 · 199 阅读 · 0 评论 -
Leetcode 11: Container With Most Water
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). Fin原创 2015-12-15 06:19:15 · 211 阅读 · 0 评论 -
Leetcode243: Shortest Word Distance
Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.For example,Assume that words = ["practice", "makes", "perfect", "coding", "原创 2015-12-15 05:56:07 · 230 阅读 · 0 评论 -
Leetcode 293: Flip Game
You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip two consecutive "++" into "--". Th原创 2015-12-17 07:55:49 · 836 阅读 · 0 评论