上一页 1 2 3 4 5 6 7 8 9 10 ··· 18 下一页
摘要: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For exam 阅读全文
posted @ 2016-01-31 07:20 fenshen371 阅读(177) 评论(0) 推荐(0) 编辑
摘要: Given an unsorted integer array, find the first missing positive integer. For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2. Your algorithm s 阅读全文
posted @ 2016-01-30 14:31 fenshen371 阅读(159) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example:Given the below binary tree and sum 阅读全文
posted @ 2016-01-30 14:05 fenshen371 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 题目:给几个Email的list,输出全部list的交集(在全部list中都出现过的email)。 思路:用set记录前i个list中都含有的email,当进行第i+1时,检查每个email是否在该set中存在,若存在,则说明该email在前i+1个list中都有,则将它记录到另一个set中。整个算 阅读全文
posted @ 2016-01-30 10:33 fenshen371 阅读(397) 评论(0) 推荐(0) 编辑
摘要: Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 思路: 采用位运算。我们先将两个数都看作是正数。 我们将除数左移一位就是将它 阅读全文
posted @ 2016-01-30 09:31 fenshen371 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 问题:给一个循环链表,和一个要删除的节点,将其删除。时间复杂度O(n)。核心代码如下: 1 ListNode *next = node->next; 2 ListNode *cur = node; 3 while (cur->next != node) 4 cur = cur->next; 5 cu 阅读全文
posted @ 2016-01-30 08:36 fenshen371 阅读(100) 评论(0) 推荐(0) 编辑
摘要: Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. You may assum 阅读全文
posted @ 2016-01-30 08:08 fenshen371 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 给一个sorted array 0 0 0 1 1 1 1,然后找出第一个1的位置。 边界情况:array为空或者全0。 思路:二分查找。为了优化,可以先判断最后一个数是不是0。 1 class Solution 2 { 3 public: 4 int FindBrokenCode(vector<i 阅读全文
posted @ 2016-01-30 06:08 fenshen371 阅读(218) 评论(0) 推荐(0) 编辑
摘要: Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. 阅读全文
posted @ 2016-01-30 05:37 fenshen371 阅读(169) 评论(0) 推荐(0) 编辑
摘要: The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11.11 is read off 阅读全文
posted @ 2016-01-30 04:04 fenshen371 阅读(170) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 18 下一页