码迷,mamicode.com
首页 >  
搜索关键字:complexity    ( 1097个结果)
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? Suppose a sorted array is rotated at some pivot unknown to y...
分类:其他好文   时间:2015-06-11 14:47:30    阅读次数:101
Leetcode[4]-Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).思路:先将两个数组合并,然后排序,最后找中位数中位数:若有n...
分类:其他好文   时间:2015-06-11 14:45:57    阅读次数:90
Leetcode[81]-Search for a Range
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm’s runtime complexity must be in the order of O(log n).If the target is not found in the ar...
分类:其他好文   时间:2015-06-11 11:07:35    阅读次数:98
Leetcode[148]-Sort List
Sort a linked list in O(n log n) time using constant space complexity.分析:题目要求时间复杂度为O(nlogn),所以一开始想到的就是快速排序,但是快速排序一直AC不了,然后就想到用归并排序,没想到归并排序竟然可以。下面给出详细代码:归并排序需要做的 找到中间点 合并两个排好序的链表 递归实现归并排序 Code(c++):/**...
分类:其他好文   时间:2015-06-10 14:15:10    阅读次数:102
Leetcode[136]-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 without using extra me...
分类:其他好文   时间:2015-06-10 08:59:53    阅读次数:114
leetcode_Factorial Trailing Zeroes_easy
Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 方法:找1...n中每个数因式分解中,5的个数(5的个数一般大于2的个数),即为10的个数 注意:题目要求时间复杂度:...
分类:其他好文   时间:2015-06-09 17:23:55    阅读次数:110
【Minimum Window】cpp
题目:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S="ADOBECOD...
分类:Windows程序   时间:2015-06-08 17:03:09    阅读次数:187
Sort List -- leetcode
Sort a linked list in O(n log n) time using constant space complexity. 算法一  自顶向下折半归并,递归 使用递归。进行折半。 先使用快慢指针,找到中间结点。将链表一分为二。 对此两链表进行递归排序后,进行归并。 在leetcode上实际执行时间为62ms。 /** * Definition for...
分类:其他好文   时间:2015-06-08 09:57:20    阅读次数:118
Search for a Range ——LeetCode
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the ord...
分类:其他好文   时间:2015-06-08 08:24:59    阅读次数:124
Sort List ——LeetCode
Sort a linked list inO(nlogn) time using constant space complexity.链表排序,要求时间复杂度O(nlgn),我写的归并排序。/** * Definition for singly-linked list. * public class...
分类:其他好文   时间:2015-06-07 17:18:21    阅读次数:131
共1097条   上一页 1 ... 52 53 54 55 56 ... 110 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!