leetcode
xxxknight
这个作者很懒,什么都没留下…
展开
-
leetcode解题报告228——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”].**题目比较easy直接上代码。解法较啰嗦。package array;import java.util.A原创 2015-06-28 00:42:37 · 680 阅读 · 0 评论 -
leetcode解题报告229——Majority Element II
Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.解题:虽然AC,但是感觉空间不符合题意。未完待续。。。。package hashtable;/* * Gi原创 2015-06-30 00:34:08 · 464 阅读 · 0 评论 -
leetcode解题报告233——Power of Two
Given an integer, write a function to determine if it is a power of two.题目属于easy。前两种解法是一个意思,很容易想到;第三种解法最好(没想到)。代码:package bitmanipulation;//Given an integer, write a function to determine if it is a po原创 2015-07-08 10:06:47 · 473 阅读 · 0 评论 -
leetcode解题报告234——Palindrome Linked List
题目: Given a singly linked list, determine if it is a palindrome.解法:package linkedlist;import java.util.Stack;//Given a singly linked list, determine if it is a palindrome.public class PalindromeLinked原创 2015-07-10 09:33:38 · 819 阅读 · 0 评论 -
leetcode解题报告232——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 element. empty原创 2015-07-08 09:25:46 · 353 阅读 · 0 评论 -
leetcode解题报告242——Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s.For example, s = “anagram”, t = “nagaram”, return true. s = “rat”, t = “car”, return false.Note: You may assume the s原创 2015-08-03 21:24:58 · 460 阅读 · 0 评论 -
leetcode解题报告258——Add Digits
题目: Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one dig原创 2015-08-18 17:55:01 · 571 阅读 · 0 评论