随笔分类 -  Leetcode (C++)

1 2 3 4 5 ··· 10 下一页

167. Two Sum II - Input array is sorted (Array)
摘要:Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function 阅读全文

posted @ 2018-05-21 11:52 joannae 阅读(101) 评论(0) 推荐(0)

169. Majority Element (Array)
摘要:Given 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 that the 阅读全文

posted @ 2017-04-08 20:18 joannae 阅读(112) 评论(0) 推荐(0)

171. Excel Sheet Column Number (Math)
摘要:Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 阅读全文

posted @ 2017-04-07 03:00 joannae 阅读(142) 评论(0) 推荐(0)

168. Excel Sheet Column Title (Math)
摘要:Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 阅读全文

posted @ 2017-04-07 02:59 joannae 阅读(150) 评论(0) 推荐(0)

166. Fraction to Recurring Decimal (Math)
摘要:Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating 阅读全文

posted @ 2017-03-23 01:57 joannae 阅读(113) 评论(0) 推荐(0)

165. Compare Version Numbers (String)
摘要:Compare two version numbers version1 and version2. If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. You may assu 阅读全文

posted @ 2017-03-22 21:51 joannae 阅读(115) 评论(0) 推荐(0)

164. Maximum Gap (Array; sort)
摘要:Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Try to solve it in linear time/space. Return 阅读全文

posted @ 2017-03-20 23:55 joannae 阅读(98) 评论(0) 推荐(0)

162. Find Peak Element (Array; Divide-and-Conquer)
摘要:A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its inde 阅读全文

posted @ 2017-03-20 21:40 joannae 阅读(129) 评论(0) 推荐(0)

160. Intersection of Two Linked Lists (List;Two-Pointers)
摘要: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 → a2 ↘ 阅读全文

posted @ 2017-03-20 21:01 joannae 阅读(112) 评论(0) 推荐(0)

155. Min Stack (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() -- Remov 阅读全文

posted @ 2017-03-15 06:55 joannae 阅读(122) 评论(0) 推荐(0)

154. Find Minimum in Rotated Sorted Array II (Array; Divide-and-Conquer)
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find th 阅读全文

posted @ 2017-01-17 01:09 joannae 阅读(187) 评论(0) 推荐(0)

153. Find Minimum in Rotated Sorted Array (Array; Divide-and-Conquer)
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find th 阅读全文

posted @ 2017-01-17 00:48 joannae 阅读(136) 评论(0) 推荐(0)

152. Maximum Product Subarray (Array; DP)
摘要: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],th 阅读全文

posted @ 2016-12-11 23:15 joannae 阅读(188) 评论(0) 推荐(0)

151. Reverse Words in a String (String)
摘要:思路: 本题考查的目的并不是使用字符串的函数。方法是两次reverse,先对每个单词先做一次翻转,然后对整个字符串做一次翻转。 需要注意的是去除extra space,并且对全space字符串、以及最后一个单词要做特殊处理。 阅读全文

posted @ 2016-12-09 23:31 joannae 阅读(191) 评论(0) 推荐(0)

103. Binary Tree Zigzag Level Order Traversal (Tree, Queue; BFS)
摘要:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and 阅读全文

posted @ 2016-11-15 21:54 joannae 阅读(202) 评论(0) 推荐(0)

102. Binary Tree Level Order Traversal (Tree, Queue; BFS)
摘要:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree [3, 阅读全文

posted @ 2016-11-15 21:46 joannae 阅读(210) 评论(0) 推荐(0)

100. Same Tree (Tree;DFS)
摘要: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 an 阅读全文

posted @ 2016-11-14 22:37 joannae 阅读(251) 评论(0) 推荐(0)

98. Validate Binary Search Tree (Tree; DFS)
摘要:Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows: The left subtree of a node contains only 阅读全文

posted @ 2016-11-14 20:39 joannae 阅读(269) 评论(0) 推荐(0)

94. Binary Tree Inorder Traversal(Tree, stack)
摘要:Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2].Note: Recur 阅读全文

posted @ 2016-11-13 07:09 joannae 阅读(239) 评论(0) 推荐(0)

81. Search in Rotated Sorted Array II (Array; Divide-and-Conquer)
摘要:Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function 阅读全文

posted @ 2016-11-11 21:11 joannae 阅读(248) 评论(0) 推荐(0)

1 2 3 4 5 ··· 10 下一页

导航