
OJ
徐九五
学生
展开
-
LeetCode OJ刷题历程——Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link原创 2016-03-02 12:00:04 · 397 阅读 · 0 评论 -
LeetCode OJ刷题历程——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 and the majority element alwa原创 2016-04-03 22:04:40 · 350 阅读 · 0 评论 -
LeetCode OJ刷题历程——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, and it should return false if every element is原创 2016-04-03 21:49:59 · 340 阅读 · 0 评论 -
LeetCode OJ刷题历程——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], after calling your f原创 2016-04-03 20:37:41 · 406 阅读 · 0 评论 -
LeetCode OJ刷题历程——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. Subscribe to see which companies asked原创 2016-04-03 20:31:44 · 399 阅读 · 0 评论 -
LeetCode OJ刷题历程——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原创 2016-04-03 20:28:45 · 454 阅读 · 0 评论 -
LeetCode OJ刷题历程——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 3 stones. The one who removes the last stone will be the原创 2016-04-03 20:22:12 · 290 阅读 · 0 评论 -
LeetCode OJ刷题历程——Remove Nth Node From End of List
Given a linked list, remove the nth node from the end of list and return its head. Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1原创 2016-03-06 14:12:44 · 277 阅读 · 0 评论 -
LeetCode OJ刷题历程——Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. 以上为题目要求。 首先说说这个题目我的解题思路,首先找出string数组中长度最短的任意一个string,以此作为基准来寻找最长的相同前缀。下面贴出代码: class Solution { public: s原创 2016-03-06 14:07:13 · 270 阅读 · 0 评论 -
LeetCode OJ刷题历程——Sting 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 possible input cases.原创 2016-03-06 13:59:42 · 333 阅读 · 0 评论 -
LeetCode OJ刷题历程——Reverse Integer
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 以上是题目要求。 本题较为Easy,但是值得注意的细节不少。下面贴上代码: class Solution { public: int reverse(int x) { long原创 2016-03-06 13:43:04 · 361 阅读 · 0 评论 -
LeetCode OJ刷题历程——Two Sum
Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1]. You may assume that each input would have exactly one solution. 以上是题目要求。 这是LeetCode的第一题,没什么难度,我选择原创 2016-03-01 10:09:33 · 366 阅读 · 0 评论