
Easy
文章平均质量分 70
ljffdream
这个作者很懒,什么都没留下…
展开
-
【LeetCode】Majority Numbers
【题目】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 array is non-empty and the majorit原创 2014-12-24 10:22:30 · 316 阅读 · 0 评论 -
【Leetcode】Reverse Integer
【题目】Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321Have you thought about this?Here are some good questions to ask before coding. Bonus po转载 2015-07-12 10:38:46 · 382 阅读 · 0 评论 -
【Leetcode】Valid Sudoku
【题目】Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A parti转载 2015-07-05 10:37:08 · 381 阅读 · 0 评论 -
【Leetcode】Compare version numbers
【题目】Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.You may assume that the version strings are non-em转载 2015-07-04 20:45:25 · 315 阅读 · 0 评论 -
【Leetcode】Factorial Trailing Zeroes
【题目】Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.Credits:Special thanks to @ts for adding this problem an转载 2015-07-04 22:55:21 · 372 阅读 · 0 评论 -
【Leetcode】Delete Node in a LinkedList
【题目】Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node转载 2015-07-26 16:47:59 · 298 阅读 · 0 评论 -
【leetcode】Rotate Array
【题目】Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:Try to come up as many solut翻译 2015-07-02 23:21:57 · 294 阅读 · 0 评论 -
【Leetcode】String to Integer(ATOI)
【题目】Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possibl转载 2015-07-12 17:03:52 · 395 阅读 · 0 评论 -
【Leetcode】Zigzag Conversion
【题目】The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H N转载 2015-07-26 13:36:05 · 339 阅读 · 0 评论 -
【Leetcode】Panlidrome Linked List
【题目】Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?【思路】panlidrome的话,回文,就是前后是一样的。第一个和最后一个一样, 第二个和倒数第二个一样。linked list转载 2015-07-17 11:27:36 · 332 阅读 · 0 评论 -
【Leetcode】Implement Queue using Stacks
【题目】Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.peek() -- Get the front elem转载 2015-07-20 22:20:09 · 336 阅读 · 0 评论 -
【Leetcode】Lowest Common Ancestor of a Binary Search Tree
【题目】Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defi转载 2015-07-20 21:05:28 · 340 阅读 · 0 评论 -
【Leetcode】House Robber
【题目】You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adja转载 2015-07-02 16:24:31 · 261 阅读 · 0 评论 -
【Leetcode】Reversed Linked List
【题目】 Reverse a singly linked list.click to show more hints.Hint: A linked list can be reversed either iteratively or recursively. Could you implement both?【思路】 我自己想的办法就是可以用一个stack,先把每一个元素都装进去转载 2015-06-29 00:09:58 · 323 阅读 · 0 评论 -
[Leetcode]Happy Number
[题目]Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the s转载 2015-07-01 13:29:44 · 318 阅读 · 0 评论 -
【Leetcode】Excel Sheet Column Number
【题目】Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3原创 2015-01-03 09:32:06 · 275 阅读 · 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 -> Z 27 -> AA 28 -> AB原创 2015-01-03 10:02:07 · 267 阅读 · 0 评论 -
【Leetcode】 Intersection of two linked list
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 ↘原创 2015-03-30 13:48:16 · 414 阅读 · 0 评论 -
【Leetcode】Find peak numbers
【题目】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 index.The array may contain multipl原创 2015-04-08 10:35:46 · 384 阅读 · 0 评论 -
【Leetcode】number of 1 bits
【题目】Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 00000000原创 2015-04-08 09:58:32 · 379 阅读 · 0 评论 -
[Leetcode]Invert Binary Tree
[题目]Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired by this original tweet by原创 2015-06-18 16:30:12 · 738 阅读 · 0 评论 -
【Leetcode】Contains Duplicate 1 and 2
【题目】Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every el原创 2015-06-20 20:50:11 · 273 阅读 · 0 评论 -
【Leetcode】Summary Ranges
【题目】Given a sorted integer array without duplicates, return the summary of its ranges.For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"].Credits:Special thanks to @jianchao.l转载 2015-06-27 20:30:48 · 413 阅读 · 0 评论 -
【Leetcode】Rectangular Area
【题目】 Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure. Rectangle Area图片: https:转载 2015-06-28 23:29:14 · 337 阅读 · 0 评论 -
【Leetcode】Isomorphic Strings
【题目】Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced转载 2015-06-29 23:11:27 · 309 阅读 · 0 评论 -
[Leetcode]Remove Linked List Elements
[题目]Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5Credits:Special th原创 2015-07-01 09:41:30 · 329 阅读 · 0 评论 -
【leetcode】Count Primes
【题目】Description:Count the number of prime numbers less than a non-negative number, n.Credits:Special thanks to @mithmatt for adding this problem and creating all test cases.Hint:Let's转载 2015-07-21 09:29:39 · 308 阅读 · 0 评论