随笔分类 -  LeetCode

记录LeetCode网站中已完成的题目
摘要:Description:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->... 阅读全文
posted @ 2015-06-14 20:36 Rosanne 阅读(156) 评论(0) 推荐(0)
摘要:Description: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 lis... 阅读全文
posted @ 2015-06-14 20:17 Rosanne 阅读(152) 评论(0) 推荐(0)
摘要:Description:Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321Code: 1 int reverse(int x) { 2 int p=0; 3... 阅读全文
posted @ 2015-06-14 19:57 Rosanne 阅读(210) 评论(0) 推荐(0)
摘要:Description:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices o... 阅读全文
posted @ 2015-06-14 13:19 Rosanne 阅读(169) 评论(0) 推荐(0)
摘要:Description:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes conta... 阅读全文
posted @ 2015-06-14 13:15 Rosanne 阅读(179) 评论(0) 推荐(0)
摘要:Description:A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right a... 阅读全文
posted @ 2015-06-14 10:17 Rosanne 阅读(168) 评论(0) 推荐(0)
摘要:Description:Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the l... 阅读全文
posted @ 2015-06-14 10:07 Rosanne 阅读(238) 评论(0) 推荐(0)
摘要:Description:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−2,1,... 阅读全文
posted @ 2015-06-14 09:57 Rosanne 阅读(151) 评论(0) 推荐(0)
摘要:Description:You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?Code: 1... 阅读全文
posted @ 2015-06-14 09:47 Rosanne 阅读(129) 评论(0) 推荐(0)
摘要:Description:Given a collection of numbers, return all possible permutations.For example,[1,2,3]have the following permutations:[1,2,3],[1,3,2],[2,1,3]... 阅读全文
posted @ 2015-06-14 09:36 Rosanne 阅读(309) 评论(0) 推荐(0)
摘要:Description: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... 阅读全文
posted @ 2015-06-14 09:11 Rosanne 阅读(189) 评论(0) 推荐(0)
摘要:Description:Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in ... 阅读全文
posted @ 2015-06-14 09:02 Rosanne 阅读(165) 评论(0) 推荐(0)
摘要:问题描述Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For example: Given bi... 阅读全文
posted @ 2015-06-13 16:12 Rosanne 阅读(157) 评论(0) 推荐(0)
摘要:Given preorder and inorder traversal of a tree, construct the binary tree.Note: You may assume that duplicates do not exist in the tree.class ... 阅读全文
posted @ 2015-05-19 13:37 Rosanne 阅读(151) 评论(0) 推荐(0)
摘要:Description:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents... 阅读全文
posted @ 2015-05-07 13:31 Rosanne