LeetCode
oo笨小孩oo
静心知路,独自修行,勿忘初心,方得始终
展开
-
LeetCode 226. Invert Binary Tree
题目Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9to 4 / \ 7 2 / \ / \ 9 6 3 1public class Solution226 { public static void main(String[] args) { S原创 2016-05-15 21:32:59 · 384 阅读 · 0 评论 -
LeetCode 206. Reverse Linked List
LeetCode 206. Reverse Linked List Reverse a singly linked list.原创 2016-05-21 23:20:07 · 533 阅读 · 0 评论 -
LeetCode 217. Contains Duplicate
LeetCode 217. Contains Duplicate 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原创 2016-05-18 13:54:06 · 416 阅读 · 0 评论 -
LeetCode 169. Majority Element
LeetCode 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 ⌋ times.You may assume that the array is non-empty原创 2016-05-18 13:55:15 · 323 阅读 · 0 评论 -
LeetCode 171. Excel Sheet Column Number
LeetCode 171. 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原创 2016-05-18 12:54:14 · 598 阅读 · 0 评论 -
LeetCode 242. Valid Anagram
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原创 2016-05-17 23:49:48 · 420 阅读 · 0 评论 -
LeetCode 100. Same Tree
LeetCode 100. Same Tree 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 and the nodes原创 2016-05-17 22:54:35 · 348 阅读 · 0 评论 -
LeetCode 237. Delete Node in a Linked List
LeetCode 237. Delete Node in a Linked List 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原创 2016-05-17 22:23:48 · 415 阅读 · 0 评论 -
LeetCode 283. Move Zeroes
LeetCode 283. Move Zeroes 题目Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12],原创 2016-05-17 13:08:25 · 347 阅读 · 0 评论 -
LeetCode 292. Nim Game
LeetCode 292. Nim Gam You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last原创 2016-05-14 23:12:40 · 414 阅读 · 0 评论 -
LeetCode 258. Add Digits
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.原创 2016-05-14 23:10:14 · 461 阅读 · 0 评论 -
LeetCode 104. Maximum Depth of Binary Tree
LeetCode 104. Maximum Depth of Binary Tree Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node原创 2016-05-15 15:06:46 · 437 阅读 · 0 评论 -
LeetCode 235. Lowest Common Ancestor of a Binary Search Tree
LeetCode 235. 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原创 2016-05-22 23:02:17 · 518 阅读 · 0 评论