2015年11月3日

LeetCode--Linked List Cycle

摘要: 题目: Given a linked list, determine if it has a cycle in it. 代码: /** * Definition for singly-linked list. * struct ListNode { * int val; * L... 阅读全文

posted @ 2015-11-03 19:31 小二杰 阅读(96) 评论(0) 推荐(0) 编辑

LeetCode--Missing Number

摘要: 题目: Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example, Given num... 阅读全文

posted @ 2015-11-03 17:25 小二杰 阅读(117) 评论(0) 推荐(0) 编辑

LeetCode--Binary Tree Inorder Traversal

摘要: 题目: Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 ... 阅读全文

posted @ 2015-11-03 14:40 小二杰 阅读(97) 评论(0) 推荐(0) 编辑

LeetCode--Binary Tree Preorder Traversal

摘要: 题目: Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 ... 阅读全文

posted @ 2015-11-03 13:44 小二杰 阅读(115) 评论(0) 推荐(0) 编辑

LeetCode--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 assum... 阅读全文

posted @ 2015-11-03 13:42 小二杰 阅读(123) 评论(0) 推荐(0) 编辑

LeetCode--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 =... 阅读全文

posted @ 2015-11-03 13:40 小二杰 阅读(95) 评论(0) 推荐(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, t... 阅读全文

posted @ 2015-11-03 13:37 小二杰 阅读(83) 评论(0) 推荐(0) 编辑

LeetCode--Excel Sheet Column Number

摘要: 题目: Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For e... 阅读全文

posted @ 2015-11-03 11:38 小二杰 阅读(100) 评论(0) 推荐(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 .... 阅读全文

posted @ 2015-11-03 11:33 小二杰 阅读(87) 评论(0) 推荐(0) 编辑

LeetCode--Single Number III

摘要: 题目: Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two ... 阅读全文

posted @ 2015-11-03 11:29 小二杰 阅读(130) 评论(0) 推荐(0) 编辑

LeetCode--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 ... 阅读全文

posted @ 2015-11-03 11:23 小二杰 阅读(92) 评论(0) 推荐(0) 编辑

LeetCode--Best Time to Buy and Sell Stock II

摘要: 题目: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You m... 阅读全文

posted @ 2015-11-03 11:21 小二杰 阅读(106) 评论(0) 推荐(0) 编辑

LeetCode--Invert Binary Tree

摘要: 题目: Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9 to 4 / \ 7 2 / \ / \9 6 3 1 Trivia: This problem was in... 阅读全文

posted @ 2015-11-03 11:16 小二杰 阅读(105) 评论(0) 推荐(0) 编辑

LeetCode--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 ex... 阅读全文

posted @ 2015-11-03 11:10 小二杰 阅读(88) 评论(0) 推荐(0) 编辑

LeetCode--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 id... 阅读全文

posted @ 2015-11-03 11:08 小二杰 阅读(107) 评论(0) 推荐(0) 编辑

LeetCode--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 ->... 阅读全文

posted @ 2015-11-03 11:06 小二杰 阅读(92) 评论(0) 推荐(0) 编辑

LeetCode--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 f... 阅读全文

posted @ 2015-11-03 11:02 小二杰 阅读(80) 评论(0) 推荐(0) 编辑

LeetCode--Single Number

摘要: 题目: Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runt... 阅读全文

posted @ 2015-11-03 10:54 小二杰 阅读(72) 评论(0) 推荐(0) 编辑

LeetCode--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 i... 阅读全文

posted @ 2015-11-03 10:45 小二杰 阅读(94) 评论(0) 推荐(0) 编辑

LeetCode--Nim Game

摘要: 题目: 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 ... 阅读全文

posted @ 2015-11-03 10:32 小二杰 阅读(125) 评论(0) 推荐(0) 编辑

导航