
leetcode
pl在之心
立足当下
展开
-
Length of Last Word
Length of Last Word Total Accepted: 56328 Total Submissions: 203851My SubmissionsQuestion Solution Given a string s consists of upper/lower-case alphabets and empty space charact原创 2015-08-01 21:09:06 · 455 阅读 · 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, the原创 2015-08-03 20:57:51 · 326 阅读 · 0 评论 -
leetcode题后感-01
今天双11,断断续续的节日,望断天涯路!明年就要参加工作了,作为即将入职的菜鸟,倍感压力。得提前做好准备,刷刷算法题,让自己对java的理解有所提升,而且需要仔细体味java怎么才能高效,推荐Effective Java这本书,虽然我没看,但是我也即将加入学习大军中。对于链表的算法题,找工作的时候问的非常频繁,现在回顾一下。第一题是链表反转。链表反转有两种方法:一种是借助于栈来实现,遍原创 2015-11-11 21:03:00 · 391 阅读 · 0 评论 -
141. 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?Subscribe to see which companies asked this question/** * Definition fo原创 2016-03-18 20:42:48 · 316 阅读 · 0 评论 -
203. Remove Linked List Elements
Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5Credits:Special thanks原创 2016-03-13 11:24:13 · 416 阅读 · 0 评论 -
83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.Subscribe to see wh原创 2016-03-13 11:38:56 · 351 阅读 · 0 评论 -
234. Palindrome Linked List
Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?Subscribe to see which companies asked this question解析:1.链表分为两段,不管是奇数还原创 2016-03-14 10:27:52 · 302 阅读 · 0 评论 -
328. Odd Even Linked List
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in原创 2016-03-14 11:16:31 · 358 阅读 · 0 评论 -
21. 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.Subscribe to see which companies asked this questio原创 2016-03-14 11:25:24 · 347 阅读 · 0 评论 -
Implement Queue using Stacks
Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.peek() -- Get the front element.empty(原创 2015-08-03 17:52:20 · 371 阅读 · 0 评论 -
Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get原创 2015-08-03 17:23:21 · 334 阅读 · 0 评论 -
Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the原创 2015-08-03 17:18:39 · 353 阅读 · 0 评论 -
Basic Calculator II
Implement a basic calculator to evaluate a simple expression string.The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer division should原创 2015-07-31 17:12:58 · 427 阅读 · 0 评论 -
Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total nu原创 2015-08-01 21:45:02 · 361 阅读 · 0 评论 -
Reverse Words in a String
Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Update (2015-02-12):For C programmers: Try to solve it in-place in原创 2015-08-01 22:09:50 · 407 阅读 · 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.思路:1.了解罗马字符与阿拉伯数字之间的关系; String[] str = new String[] { "M", "CM", "原创 2015-08-02 14:30:18 · 320 阅读 · 0 评论 -
Compare Version Numbers
Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.You may assume that the version strings are non-empty and co原创 2015-08-02 15:07:48 · 345 阅读 · 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 vali原创 2015-08-02 13:23:27 · 315 阅读 · 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 a原创 2015-08-02 14:03:43 · 429 阅读 · 0 评论 -
Implement Stack using Queues
Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the top element.empty() -- Return whet原创 2015-08-03 17:42:05 · 454 阅读 · 0 评论 -
160. 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 ↘原创 2016-03-15 09:29:25 · 316 阅读 · 0 评论