原创 58.Length of Last Word (最後一個單詞長度)

描述:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last

原创 202.Happy Number

A happy number is a number defined by the following process: Starting with any positive integer, replace the number by

原创 169.Majority Element (數組中出現次數超過一半的數)

Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2

原创 203.Remove Linked List Elements(刪除鏈表中值爲X的結點)

題目:Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --

原创 217.Contains Duplicate(判斷一個數組是否有重複數出現)

題目:Given an array of integers, find if the array contains any duplicates. Your function should return true if any valu

原创 198.House Robber (求非相鄰正整數的和最大值)

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed,

原创 204.Count Primes(1-N中,素數的個數)

題目:Count the number of prime numbers less than a non-negative number, n. 代碼: public class Solution {     public int co

原创 168.Excel Sheet Column Title(28 -> AB)

Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -> A

原创 231.Power of Two(2的N次方)

Given an integer, write a function to determine if it is a power of two. 方法:如果這個數是2的倍數(n%2==0),將這個數除以二(n /=2 ),循環上述操作,最

原创 226.Invert Binary Tree(交換二叉樹左右結點)

Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6

原创 225.Implement Stack using Queues (用隊列實現棧)

題目: Implement the following operations of a stack using queues. push(x) -- Push element x onto stack.pop() -- Removes

原创 206.Reverse Linked List(單鏈表逆置)

Reverse a singly linked list. /** * Definition for singly-linked list. * public class ListNode { *     int val; *     L

原创 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() --

原创 171.Excel Sheet Column Number (AB=28)

Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1

原创 連續子數組的最大和

 public Integer findGreatestSum(int[] arr){                      if(arr.length ==0)               return null;