码迷,mamicode.com
首页 >  
搜索关键字:median of two sorted    ( 17004个结果
leetcode Word Break II
Give two versions of WA code: Version 1: Runtime Error: Find the bug class Solution { public: void find(const string& s, const unordered_set& dict, vector& res) { int i, j, len = s.length(); ...
分类:其他好文   时间:2014-08-03 15:21:27    阅读次数:329
[LeetCode]Same Tree
Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. /** ...
分类:其他好文   时间:2014-08-03 12:54:55    阅读次数:201
POJ - 3468 A Simple Problem with Integers (区间求和)
Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other ...
分类:其他好文   时间:2014-08-03 12:53:25    阅读次数:311
LeetCode "Remove Duplicates from Sorted List II"
Corner cases!class Solution {public: ListNode *deleteDuplicates(ListNode *head) { if (!head) return head; if (!head->next) return hea...
分类:其他好文   时间:2014-08-03 07:51:34    阅读次数:237
POJ 3895 Cycles of Lanes
Description Each of the M lanes of the Park of Polytechnic University of Bucharest connects two of the N crossroads of the park (labeled from 1 to N). There is no pair of crossroads connected by mo...
分类:其他好文   时间:2014-08-02 23:27:14    阅读次数:327
ZOJ 1633 Big String
Big String Time Limit: 2 Seconds      Memory Limit: 65536 KB We will construct an infinitely long string from two short strings: A = "^__^" (four characters), and B = "T.T" (three characters). R...
分类:其他好文   时间:2014-08-02 21:02:04    阅读次数:291
LeetCode 第二题,Median of Two Sorted Arrays
题目再现 There are two sorted arrays A and B 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)). 题意解析...
分类:其他好文   时间:2014-08-02 18:24:13    阅读次数:335
Merge Two Sorted Lists
问题:有序合并两个有序链表分析:归并排序的合并部分class Solution {public: ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) { ListNode *helper=new ListNode(0); ...
分类:其他好文   时间:2014-08-02 18:17:03    阅读次数:170
Remove Duplicates from Sorted List
问题:将有序链表中的重复元素删除分析:由于有序,所以p结点是否重复只需要和它的前一节点比较是否相等就可以了,我们可以定义一个helper新头结点链表 将p结点与新链表的尾结点比较,若不相等则加入新链表中。class Solution{public: ListNode *deleteDup...
分类:其他好文   时间:2014-08-02 17:47:33    阅读次数:210
POJ1837:Balance(01背包)
Description Gigel has a strange "balance" and he wants to poise it. Actually, the device is different from any other ordinary balance.  It orders two arms of negligible weight and each arm's lengt...
分类:其他好文   时间:2014-08-02 15:30:13    阅读次数:235
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!