码迷,mamicode.com
首页 >  
搜索关键字:median of two sorted    ( 17004个结果
Remove Duplicates from Sorted List
题目 Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3. 方法 遍...
分类:其他好文   时间:2014-06-11 00:41:44    阅读次数:207
[LeetCode] Merge Sorted Array [22]
题目: Given two sorted integer arrays A and B, merge B into A as one sorted array. 原题链接(点我) 解题思路: 合并两个数组为一个有序数组,这题也很简单,唯一考查的地方就是怎么处理数组,是从前往后还是从后往前。一般情况,从后往前的效率比从前往后高,也要省不少事。代码如下,从后开始合并。 代码实现:...
分类:其他好文   时间:2014-06-11 00:37:42    阅读次数:314
【002】}链表或字符串模拟加法/加一/乘法
链表模拟加法/字符串模拟二进制加法/数组模拟加一操作/打印1到最大的n位数/字符串模拟乘法============================================Add Two Numbers两个链表代表两个数字,每个结点的值都是一位数字,单链表逆序存放这两个数字,构造出一个新的链表...
分类:其他好文   时间:2014-06-10 22:02:23    阅读次数:409
[leetcode]Divide Two Integers @ Python
原题地址:https://oj.leetcode.com/problems/divide-two-integers/题意:Divide two integers without using multiplication, division and mod operator.解题思路:不许用乘、除和求...
分类:编程语言   时间:2014-06-10 21:43:00    阅读次数:267
DMV to track the temp file usage for SQLServer
There are three DMVs you can use to track tempdb usage:sys.dm_db_task_space_usagesys.dm_db_session_space_usagesys.dm_db_file_space_usageThe first two ...
分类:数据库   时间:2014-06-10 11:27:07    阅读次数:307
Network | router & switch
路由器A router is a device that forwards data packets between computer networks. This creates an overlay internetwork, as a router is connected to two or...
分类:Web程序   时间:2014-06-10 11:26:26    阅读次数:277
【leetcode】Remove Duplicates from Sorted Array
int removeDuplicates(int A[], int n) { if(n <= 1) return n; int newIndex = 0; for(int i = 1; i < n; ++i){ if(A[i] != A[newIndex]) A[++newIndex] ...
分类:其他好文   时间:2014-06-10 10:57:49    阅读次数:131
【leetcode】Convert Sorted List to Binary Search Tree
问题: 给定一个有序链表,生成对应的平衡二叉搜索树。 分析 见Convert Sorted Array to Binary Search Tree 实现: TreeNode *buildTree(ListNode* head, ListNode *end){ if(head == NULL || head == end) return NULL; ...
分类:其他好文   时间:2014-06-10 07:17:29    阅读次数:264
GPS-Graph Processing System Graph Coloring算法分析 (三)
Graph coloring is the problem of assigning a color to each vertex of an undirected graph such that no two adjacent vertices have the same color. We implement the greedy algorithm from Scalable parallel graph coloring algorithms. The algorithm iteratively f...
分类:其他好文   时间:2014-06-10 07:10:19    阅读次数:260
leetcode——Divide Two Integers 不用乘除取余操作求除法(AC)
题目只有简单的一句话,看起来可真简单啊,呵呵,假象。这个题目的难点在于对时间效率的限制和边界值的测试。第一印象肯定是循环一个个把因子从被除数中减去不久行了么,可是对于比如INT_MAX/1或者INT_MIN/1之类的执行时间长的可怕,会超出时间限制。改善时间效率的思路是参考网上别人代码,将因子不断乘以2(可以通过移位实现,同时结果也从1开始不断移位加倍),然后和被除数比较,等到大于被除数一半了,就从被除数中减去,将因子个数叠加入结果中。然后在剩下的被除数中采用同样的方法减去小于其一半的因子和,循环往复。我在...
分类:其他好文   时间:2014-06-10 06:51:06    阅读次数:209
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!