随笔分类 -  Algorithm

上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 14 下一页

[LeetCode] Binary Search Tree Iterator
摘要:Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the next... 阅读全文

posted @ 2015-01-21 14:49 Eason Liu 阅读(180) 评论(0) 推荐(0)

[Jobdu] 题目1507:不用加减乘除做加法
摘要:题目描述:写一个函数,求两个整数之和,要求在函数体内不得使用+、-、*、/四则运算符号。输入:输入可能包含多个测试样例。对于每个测试案例,输入为两个整数m和n(1 2 3 int add(int a, int b) { 4 int n1, n2; 5 do { 6 ... 阅读全文

posted @ 2015-01-21 13:26 Eason Liu 阅读(516) 评论(0) 推荐(0)

[LeetCode] Dungeon Game
摘要:The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a... 阅读全文

posted @ 2015-01-20 22:42 Eason Liu 阅读(1664) 评论(0) 推荐(0)

[LeetCode] Largest Number
摘要:Given a list of non negative integers, arrange them such that they form the largest number.For example, given[3, 30, 34, 5, 9], the largest formed num... 阅读全文

posted @ 2015-01-13 17:02 Eason Liu 阅读(2806) 评论(0) 推荐(0)

[LeetCode] Text Justification
摘要:Given an array of words and a lengthL, format the text such that each line has exactlyLcharacters and is fully (left and right) justified.You should p... 阅读全文

posted @ 2015-01-12 16:56 Eason Liu 阅读(264) 评论(0) 推荐(0)

[LeetCode] Compare Version Numbers
摘要:Compare two version numbersversion1andversion1.Ifversion1>version2return 1, ifversion1 val2) return 1;26 if (val1 < val2) return -1;27 ... 阅读全文

posted @ 2015-01-12 15:49 Eason Liu 阅读(3594) 评论(0) 推荐(0)

[LeetCode] Find Peak Element
摘要:A peak element is an element that is greater than its neighbors.Given an input array wherenum[i] ≠ num[i+1], find a peak element and return its index.... 阅读全文

posted @ 2015-01-12 14:05 Eason Liu 阅读(321) 评论(0) 推荐(0)

[LeetCode] Factorial Trailing Zeroes
摘要:Given an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.Credits:Special thanks to@tsf... 阅读全文

posted @ 2015-01-12 13:40 Eason Liu 阅读(214) 评论(0) 推荐(0)

[LeetCode] Insert Interval
摘要:Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially... 阅读全文

posted @ 2015-01-12 13:24 Eason Liu 阅读(169) 评论(0) 推荐(0)

[LeetCode] Merge Intervals
摘要:Given a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15,18]. 1 /** 2 * De... 阅读全文

posted @ 2015-01-10 22:18 Eason Liu 阅读(175) 评论(0) 推荐(0)

[LeetCode] Excel Sheet Column Number
摘要:Related to questionExcel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A ... 阅读全文

posted @ 2015-01-09 19:48 Eason Liu 阅读(156) 评论(0) 推荐(0)

[LeetCode] Excel Sheet Column Title
摘要:Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 ->... 阅读全文

posted @ 2015-01-09 19:47 Eason Liu 阅读(151) 评论(0) 推荐(0)

[LeetCode] Intersection of Two Linked Lists
摘要:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a... 阅读全文

posted @ 2015-01-09 19:44 Eason Liu 阅读(171) 评论(0) 推荐(0)

[LeetCode] Find Minimum in Rotated Sorted Array II
摘要:Follow upfor "Find Minimum in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Suppose a sort... 阅读全文

posted @ 2015-01-09 19:42 Eason Liu 阅读(142) 评论(0) 推荐(0)

[LeetCode] Min Stack
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes... 阅读全文

posted @ 2015-01-08 11:58 Eason Liu 阅读(421) 评论(0) 推荐(0)

[LeetCode] Find Minimum in Rotated Sorted Array
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).Find the minimum element.You m... 阅读全文

posted @ 2015-01-08 11:45 Eason Liu 阅读(178) 评论(0) 推荐(0)

[LeetCode] Maximum Product Subarray
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the... 阅读全文

posted @ 2015-01-08 11:26 Eason Liu 阅读(131) 评论(0) 推荐(0)

[Jobdu] 题目1504:把数组排成最小的数
摘要:题目描述:输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个。例如输入数组{3,32,321},则打印出这三个数字能排成的最小数字为321323。输入:输入可能包含多个测试样例。对于每个测试案例,输入的第一行为一个整数m (1 2 #include 3 #i... 阅读全文

posted @ 2014-12-23 17:00 Eason Liu 阅读(207) 评论(0) 推荐(0)

[Jobdu] 题目1544:数字序列区间最小值
摘要:题目描述:给定一个数字序列,查询任意给定区间内数字的最小值。输入:输入包含多组测试用例,每组测试用例的开头为一个整数n(1 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int n, t; 8 int l, r; 9... 阅读全文

posted @ 2014-12-03 18:58 Eason Liu 阅读(2619) 评论(0) 推荐(0)

[Jobdu] 题目1408:吃豆机器人
摘要:题目描述:淘宝公司内部有许多新鲜的小玩具,例如淘宝智能机器人。小时候,大家都玩过那个吃豆子的游戏吧,这机器人就是按照这个游戏设计的,它会朝着豆子的方向行走。不过机器人还存在一个bug,他只会朝南和朝东走。现在有一块空地,分成了n*m个格子,每个格子内有一颗豆子。机器人的起点在西北角,终点在东南角。请... 阅读全文

posted @ 2014-08-11 11:16 Eason Liu 阅读(599) 评论(0) 推荐(0)

上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 14 下一页