leetcode
mr_phy
这个作者很懒,什么都没留下…
展开
-
leetcode第二题<Add Two Numbers>
题目内容 You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and re原创 2017-02-27 15:17:33 · 315 阅读 · 0 评论 -
Leetcode 第四题< Median of Two Sorted Arrays>(Java)
题面: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).看题目是很简单的,就是在两个有序数组原创 2017-03-08 16:13:50 · 377 阅读 · 0 评论 -
Leetcode第一题<two sum>
从今天开始刷题啦。题目原文 Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you ma原创 2017-02-25 17:38:11 · 449 阅读 · 0 评论 -
leetcode 第八题<String to Integer (atoi)>(java)
题面 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 in原创 2017-03-11 19:05:40 · 292 阅读 · 0 评论 -
leetcode 第15题 <3Sum>(java)
题面 Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The solution set must not conta原创 2017-03-12 20:50:31 · 381 阅读 · 0 评论 -
leetcode 第20题<Valid Parentheses>(java)
题面 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原创 2017-03-13 15:06:02 · 300 阅读 · 0 评论 -
leetcode 第21题<Merge Two Sorted Lists>(java)
题面 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.审题linked list 考察链表结构 合并两个有序的链表,使之成为一个新(有序的)表。新表由先前的两个原创 2017-03-13 17:54:09 · 371 阅读 · 0 评论 -
leetcode100题< Same Tree >(java)
题目很简单,就是找出两个相同的树我首先就想到了树的遍历code1树的深度优先搜索 先声明一个栈,把头结点放进去。 然后把栈里第一个结点pop出来,接着把头结点的子节点push进去, 然后把栈里面的第一个结点pop出来,把他的子节点push进去。 直到栈为空。/** * Definition for a binary tree node. * public class TreeNode {原创 2017-03-15 00:50:04 · 282 阅读 · 0 评论 -
史上最好理解的KMP算法
KMP算法的解释很多,但是大多都晦涩难懂。 我看了好几篇,决定把其中讲得比较好的几篇归纳一下。 但是版权属于它们: The Knuth-Morris-Pratt Algorithm in my own words 字符串匹配的KMP算法 如果你看不懂KMP算法,那就看一看这篇文章暴力匹配算法首先,我假设你已经是一个已经懂暴力匹配算法的人了。 但是暴力匹配算法有一个问题:当你知道你的目标串原创 2017-03-13 22:08:09 · 292 阅读 · 0 评论