Two Point
candy_crush
胡编乱写
展开
-
3Sum
15. 3Sum 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原创 2016-08-18 16:48:07 · 173 阅读 · 0 评论 -
Palindrome Linked List 回文链表
Given a singly linked list, determine if it is a palindrome.题意: 判断一个链表是否是回文链表,回文链表就是无论从左读还是从右读都一样例如 1->2->3->2->1 需要注意的是空链表和只有一个节点的链表都是回文链表解题思路:反转链表,将链表后半段原地翻转,再将前半段、后半段依次比较,判断是否相等该方法时间复杂度为原创 2016-09-05 16:42:15 · 188 阅读 · 0 评论 -
Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.Follow up:Can you solve it without using extra space? 题原创 2016-09-07 22:33:04 · 189 阅读 · 0 评论 -
Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of原创 2016-09-07 09:55:40 · 220 阅读 · 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?题意:判断链表中是否有环思路:采用快慢指针的方法,快指针走两步,慢指针走一步,如果有环,则总有相遇的时候即快慢指针相等的时候/** * Definitio原创 2016-09-04 23:36:19 · 142 阅读 · 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原创 2016-09-04 13:46:42 · 180 阅读 · 0 评论 -
4Sum
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: The solution原创 2016-08-18 19:42:09 · 206 阅读 · 0 评论 -
3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact原创 2016-08-18 18:28:11 · 176 阅读 · 0 评论 -
Container With Most Water容器盛水
11. Container With Most Water Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints o原创 2016-08-18 10:18:43 · 442 阅读 · 0 评论 -
合并有序数组
88. Merge Sorted Array Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater o原创 2016-08-17 10:44:59 · 183 阅读 · 0 评论 -
移除元素
27. Remove Element Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in plac原创 2016-08-17 09:56:45 · 738 阅读 · 0 评论 -
清除重复元素
26. 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 f原创 2016-08-17 09:44:57 · 188 阅读 · 0 评论 -
Sort Colors 三色排序
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers原创 2016-08-23 13:22:32 · 534 阅读 · 0 评论 -
Valid Palindrome
题目:判断字符串是否是回文字符串,只考虑字符串中的数字和字符,不考虑标点符号例如:"A man, a plan, a canal: Panama"是回文字符串"race a car" 不是回文字符串方法1:使用额外的内存空间 注意:测试时输入的字符串是带""引号的public class Solution { public boolean isPalindrome(S原创 2016-10-06 14:55:49 · 245 阅读 · 0 评论