LeetCode
文章平均质量分 52
淡淡的一抹
晚霞易逝,生命易折,虽然是淡淡的一抹,与我足以。
展开
-
Intersection of Two Linked Lists
题目描述Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists: A: a1 → a2 ↘原创 2015-01-15 17:04:07 · 338 阅读 · 0 评论 -
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: A -> 1 B -> 2 C -> 3 ..原创 2015-01-12 16:42:52 · 403 阅读 · 0 评论 -
ZigZag Conversion
题目描述 The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L原创 2014-12-25 09:51:52 · 245 阅读 · 0 评论 -
Balanced Binary Tree
题目描述Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never dif原创 2014-12-25 09:50:08 · 196 阅读 · 0 评论 -
Merge Two Sorted Lists
题目描述Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.解题思路对比两个表头的元素,将较小者插入新的链表中。源代码package leetcode;原创 2014-12-25 09:49:57 · 187 阅读 · 0 评论 -
Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? 1 自己的代码:运行并不成功,相对于对每个小于n的元素进行了两倍原创 2014-12-25 09:49:19 · 170 阅读 · 0 评论 -
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.1 自己的代码class TreeNode { int原创 2014-12-25 09:47:58 · 260 阅读 · 0 评论 -
String 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原创 2014-12-25 09:52:09 · 263 阅读 · 0 评论 -
Binary Tree Level Order Traversal II
题目描述Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree {3,9,20,#,#,15,7}原创 2014-12-25 09:50:52 · 200 阅读 · 0 评论 -
Minimum Depth of Binary Tree
题目描述Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.解题思路本题是二叉树的遍历题,但是在深度优先和广度优先上需要进行原创 2014-12-25 09:51:08 · 160 阅读 · 0 评论 -
Remove Duplicates from Sorted Array
题目描述 Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place原创 2014-12-25 09:50:14 · 207 阅读 · 0 评论 -
CSS选择器的常用规则
CSS选择器的常用规则(1) 组规则语法:选择符1,选择符2,...,选择符n{属性1:值1; 属性2:值2;...;属性n:值n;}示例:/*定义H1的格式*/H1 { font-weight: bold;/*字体的粗细,bold指粗体*/ font-size: 12pt;/*字体尺寸,现在一般使用px,并不使用pt*/ font-family:原创 2014-12-25 09:49:52 · 336 阅读 · 0 评论 -
Single Number II
Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using原创 2014-12-25 09:49:14 · 222 阅读 · 0 评论 -
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 runtime complexity. Could you implement it without using e原创 2014-12-25 09:47:41 · 252 阅读 · 0 评论 -
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 have the same value.1 自己的代码原创 2014-12-25 09:48:03 · 222 阅读 · 0 评论 -
Valid Palindrome
题目描述 Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not原创 2014-12-25 09:51:58 · 214 阅读 · 0 评论 -
Valid Sudoku
题目描述Determine if a Sudoku is valid, according to:The Sudoku board could be partially filled, where empty cells are filled with the character '.'.Note:A valid Sudoku board (partially filled) is n原创 2014-12-25 09:51:30 · 223 阅读 · 0 评论 -
Add Binary
题目描述Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100". 解题思路本题考查对字符串和容器的使用。主要思想是将a,b转化为列表处理,然后从低位到高位一次进行进位操作。相关知识点(1)对一个容器进行逆序操作Coll原创 2014-12-25 09:51:36 · 264 阅读 · 0 评论 -
Length of Last Word
题目描述Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is原创 2014-12-25 09:51:14 · 224 阅读 · 0 评论 -
Remove Nth Node From End of List
题目描述Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end,原创 2014-12-25 09:51:03 · 210 阅读 · 0 评论 -
Maximum Subarray
题目描述 Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1]原创 2014-12-25 09:49:41 · 170 阅读 · 0 评论 -
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 / 3return [1,3,2]. 思路:二叉树的中序遍历package leetcode;impo原创 2014-12-25 09:48:52 · 201 阅读 · 0 评论 -
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 / 3return [1,2,3]. 思路:二叉树的前序遍历package leetcode;impor原创 2014-12-25 09:48:46 · 159 阅读 · 0 评论 -
Linked List Cycle
题目描述:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?1自己的代码class ListNode { int val; ListNode next; ListNode(int原创 2014-12-25 09:48:41 · 184 阅读 · 0 评论 -
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 may complete as many transactions as you like (ie, buy原创 2014-12-25 09:48:30 · 248 阅读 · 0 评论 -
Path Sum
题目描述 Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and原创 2014-12-25 09:50:57 · 221 阅读 · 0 评论 -
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 ele原创 2015-01-14 16:37:40 · 313 阅读 · 0 评论 -
Factorial Trailing Zeroes
题目描述Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.文章出处:https://oj.leetcode.com/problems/factorial-trailing-zeroes/原创 2015-01-14 20:50:09 · 283 阅读 · 0 评论 -
Binary Tree Level Order Traversal
题目描述Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20原创 2014-12-25 09:50:47 · 207 阅读 · 0 评论 -
Merge Sorted Array
题目描述Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements fro原创 2014-12-25 09:50:25 · 206 阅读 · 0 评论 -
Populating Next Right Pointers in Each Node
[size=medium][/size]Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next原创 2014-12-25 09:48:57 · 201 阅读 · 0 评论 -
Reverse Integer
题目描述:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -3211 自己的代码public class ReverseInteger { public int reverse(int x) { String str = String.valueOf原创 2014-12-25 09:48:09 · 193 阅读 · 0 评论 -
Roman to Integer
题目Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.思路首先,学习一下罗马数字,参考罗马数字 罗马数字是最古老的数字表示方式,比阿拉伯数组早2000多年,起源于罗马 罗马数字有如下符号: 基本字符 I V X L C原创 2014-12-25 09:49:30 · 223 阅读 · 0 评论 -
Implement strStr()
题目描述 Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack. 解题思路本题最经典的算法是KMP算法,具体可以参考http://www.cnblogs.com/dolphin0520/ar原创 2014-12-25 09:52:03 · 218 阅读 · 0 评论 -
Valid Parentheses
题目描述Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all val原创 2014-12-25 09:51:25 · 192 阅读 · 0 评论 -
Pascal's Triangle II
题目描述Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space? 解题思路本题是在上一题Pa原创 2014-12-25 09:50:41 · 210 阅读 · 0 评论 -
Plus One
题目描述Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list解题思路本题是将一个十位数按位存储到数原创 2014-12-25 09:50:30 · 221 阅读 · 0 评论 -
Pascal's Triangle
题目描述Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]解题思路本题的目的是根据不同的数字,构建不同的三角形原创 2014-12-25 09:50:36 · 232 阅读 · 0 评论 -
Symmetric Tree
题目描述Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the follo原创 2014-12-25 09:50:19 · 248 阅读 · 0 评论 -
Remove Element
题目描述Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new length.原创 2014-12-25 09:50:03 · 233 阅读 · 0 评论