
LeetCode
文章平均质量分 68
Johnny-Zhuang
爱摄影,爱阅读,爱编程。
每个人总有两条路可以走,
而我们总是需要走完需要走的那条路,
然后才能走想走的路。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode 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 S I I原创 2014-10-23 20:34:49 · 642 阅读 · 0 评论 -
LeetCode 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-10-28 12:52:36 · 668 阅读 · 0 评论 -
Leet Code Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".实现二进制数相加,算法很简单就是两个String每位去相加,然后判断是否要进位。一开始想到了一个不同的算法,即将两个String转为int型然后相加原创 2014-10-28 12:21:26 · 700 阅读 · 0 评论 -
LeetCode 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 from B原创 2014-10-29 12:17:29 · 529 阅读 · 0 评论 -
Leet Code Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For原创 2014-10-30 11:11:47 · 539 阅读 · 0 评论 -
LeetCode 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?每一次你可以爬一层或者两层,计算爬n层你原创 2014-10-29 21:46:25 · 541 阅读 · 0 评论 -
LeetCode Longest Palindromic Substring
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length ofS is 1000, and there exists one unique longest palindromic substring.输入一个字符串,返回最大回文串原创 2014-10-30 23:34:47 · 602 阅读 · 0 评论 -
leetcode 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 a pa原创 2014-11-24 00:52:10 · 461 阅读 · 0 评论 -
LeetCode Two Sum
Two SumTotal Accepted: 37848 Total Submissions: 206006 Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return原创 2014-10-21 19:30:35 · 663 阅读 · 0 评论 -
LeetCode Reverse Integer
Reverse IntegerTotal Accepted: 36405 Total Submissions: 91139Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.原创 2014-10-22 00:53:18 · 528 阅读 · 0 评论 -
LeetCode 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.题目描述:类似以前C语言做的输入两个链表,按照顺序大小将其连接。不过这次试着用JAVA做,原创 2014-10-27 17:08:32 · 533 阅读 · 0 评论 -
LeetCode 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 defi原创 2014-10-27 12:56:08 · 627 阅读 · 0 评论 -
LeetCode Roman to Integer
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.思路是蛮简单的,关键就是理解罗马数字的规则:羅馬數字共有7個,即I(1)、V(5)、X(10)、L(50)、C(100)、D(500)和M(原创 2014-10-25 13:28:11 · 673 阅读 · 0 评论 -
LeetCode Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear onlyonce and return the new length.Do not allocate extra space for another array, you must do this in place with原创 2014-10-26 20:26:37 · 378 阅读 · 0 评论 -
LeetCode 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-10-26 20:43:38 · 388 阅读 · 0 评论 -
LeetCode Implement strStr()
Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.输入两个字符串,如果第二个是第一个的字串返回该串在第一个字符串开始的的子串。比如abcd bc 则返回bcd原创 2014-10-26 22:16:42 · 392 阅读 · 0 评论 -
LeetCode 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-10-26 16:23:14 · 502 阅读 · 0 评论 -
LeetCode 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, the l原创 2014-10-26 20:08:30 · 369 阅读 · 0 评论 -
LeetCode String to Integer (atoi)
String to Integer (atoi)Total Accepted: 20984 Total Submissions: 145855Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a原创 2014-10-24 21:24:16 · 605 阅读 · 0 评论 -
LeetCode Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.这道题目就真的是比较水了,题目意思就是要我们找出最大的公共子序列。通过两个循环就可以解决了!详见代码:public class Solution { public String longestCo原创 2014-10-25 21:42:11 · 391 阅读 · 0 评论 -
[Java]Stack类
Java Stack类顾名思义,实现堆栈。具体方法如下: import java.util.Stack; public class StackTest { public static void main(String[] args) { Stack stack = new原创 2014-10-26 16:21:35 · 281 阅读 · 0 评论 -
LeetCode Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting th原创 2014-10-24 23:09:14 · 447 阅读 · 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 identical and the nodes have the same value.一直不太懂递归的写法原创 2014-10-29 22:02:38 · 531 阅读 · 0 评论