随笔分类 -  LeetCode

摘要:问题: Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra spac 阅读全文
posted @ 2016-09-27 20:24 减掉一斤是一斤 阅读(100) 评论(0) 推荐(0)
摘要:题目 Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:You may assume that nums1 has enough space (size 阅读全文
posted @ 2016-09-26 17:28 减掉一斤是一斤 阅读(127) 评论(0) 推荐(0)
摘要:问题 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 阅读全文
posted @ 2016-09-26 16:36 减掉一斤是一斤 阅读(179) 评论(0) 推荐(0)
摘要:问题: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:You may assume that nums1 has enough space (size 阅读全文
posted @ 2016-09-26 00:13 减掉一斤是一斤 阅读(168) 评论(0) 推荐(0)
摘要:问题: Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. 阅读全文
posted @ 2016-09-25 23:37 减掉一斤是一斤 阅读(131) 评论(0) 推荐(0)
摘要:题目: 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 阅读全文
posted @ 2016-09-25 22:51 减掉一斤是一斤 阅读(141) 评论(0) 推荐(0)
摘要:class Solution {public: bool containsNearbyDuplicate(vector<int>& nums, int k) { int len=nums.size(); bool flag=false; multimap<int ,int> mulm; for(in 阅读全文
posted @ 2016-09-22 12:15 减掉一斤是一斤 阅读(115) 评论(0) 推荐(0)