随笔分类 -  Leetcode (C++)

上一页 1 ··· 6 7 8 9 10

1.Two Sum (Array; HashTable)
摘要:Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two n 阅读全文

posted @ 2015-07-09 22:32 joannae 阅读(208) 评论(0) 推荐(0)

Intersection of Two Linked Lists(LIST-2 POINTER)
摘要: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: a1 → a... 阅读全文

posted @ 2015-01-16 21:52 joannae 阅读(154) 评论(0) 推荐(0)

Find Peak Element(ARRAY - Devide-and-Conquer)
摘要:QUESTIONA 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 it... 阅读全文

posted @ 2015-01-12 23:07 joannae 阅读(277) 评论(0) 推荐(0)

Dungeon Game (GRAPH - DP)
摘要:QUESTIONThe 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 ... 阅读全文

posted @ 2015-01-09 22:22 joannae 阅读(226) 评论(0) 推荐(0)

Binary Search Tree Iterator
摘要:QUESTIONImplement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will retur... 阅读全文

posted @ 2015-01-08 23:38 joannae 阅读(142) 评论(0) 推荐(0)

Factorial Trailing Zeroes (Divide-and-Conquer)
摘要:QUESTIONGiven an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.FIRST TRYclass Sol... 阅读全文

posted @ 2015-01-03 19:21 joannae 阅读(222) 评论(0) 推荐(0)

Excel Sheet Column Number(STRING-TYPE CONVERTION)
摘要:QUESTIONRelated to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For examp... 阅读全文

posted @ 2015-01-03 17:06 joannae 阅读(166) 评论(0) 推荐(0)

Majority Element(ARRAY-BINARY SEARCH)
摘要:QUESTIONGiven an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume t... 阅读全文

posted @ 2015-01-03 10:47 joannae 阅读(165) 评论(0) 推荐(0)

Excel Sheet Column Title (STRING - TYPE CONVERTION)
摘要:QUESTIONGiven a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... ... 阅读全文

posted @ 2015-01-03 07:34 joannae 阅读(213) 评论(0) 推荐(0)

Fraction to Recurring Decimal(STRING-TYPE CONVERTION)
摘要:QUESTIONGiven two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is re... 阅读全文

posted @ 2014-12-19 19:37 joannae 阅读(288) 评论(0) 推荐(0)

Compare Version Numbers(STRING-TYPE CONVERTION)
摘要:QUESTIONCompare two version numbers version1 and version1.If version1 > version2 return 1, if version1 integer2) return 1; else if(integer1 i... 阅读全文

posted @ 2014-12-17 23:00 joannae 阅读(218) 评论(0) 推荐(0)

Evaluate Reverse Polish Notation (STRING-TYPE CONVERTION)
摘要:QuestionEvaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or an... 阅读全文

posted @ 2014-12-16 23:09 joannae 阅读(174) 评论(0) 推荐(0)

Max Points on a Line (HASH TABLE
摘要:QUESTIONGiven n points on a 2D plane, find the maximum number of points that lie on the same straight line.1ST TRY/** * Definition for a point. * stru... 阅读全文

posted @ 2014-12-16 22:40 joannae 阅读(202) 评论(0) 推荐(0)

Maximum Gap (ARRAY - SORT)
摘要:QUESTIONGiven an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.R... 阅读全文

posted @ 2014-12-16 06:42 joannae 阅读(324) 评论(0) 推荐(0)

上一页 1 ··· 6 7 8 9 10

导航