
Leetcode
文章平均质量分 56
Pango_lulu
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321原创 2014-11-16 20:29:14 · 477 阅读 · 0 评论 -
4Sum
Given an array S of n integers, are there elementsa, 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:Eleme原创 2014-12-11 00:33:17 · 396 阅读 · 0 评论 -
3Sum Closest
Given an array S of n integers, find three integers inS 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 ex原创 2014-12-11 00:31:02 · 410 阅读 · 0 评论 -
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 w原创 2015-02-16 21:06:36 · 555 阅读 · 0 评论 -
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.原创 2015-02-16 21:18:29 · 572 阅读 · 0 评论 -
Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "原创 2015-02-13 00:25:49 · 419 阅读 · 0 评论 -
Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Tag:使用优先队列,时间复杂度为n*log(k),其中n为所有元素个数,k为已排好序的链表,如果k很小的话,实现复杂度近乎为线性。#include #include #include us原创 2015-02-13 23:13:22 · 581 阅读 · 0 评论 -
Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked listk at a time and return its modified list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as i原创 2015-02-15 23:15:32 · 536 阅读 · 0 评论 -
Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant spac原创 2015-02-14 00:41:39 · 488 阅读 · 0 评论 -
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.Tag:两路归并struct ListNode { int val; ListNode *nex原创 2015-04-10 22:31:34 · 515 阅读 · 0 评论 -
Implement strStr()
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02):The signature of the function had been updat原创 2015-04-10 22:37:42 · 493 阅读 · 0 评论 -
Divide Two Integers
Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.Tag: 二分求解,相当于每次除数都乘以2,注意考虑负数的情况和整数溢出的情况。int divide(int dividend, int divisor)原创 2015-04-15 15:02:33 · 478 阅读 · 0 评论 -
3Sum
Given an array S of n integers, are there elementsa, b, c in S such that a + b +c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b原创 2014-12-11 00:18:36 · 383 阅读 · 0 评论 -
Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit原创 2014-12-11 00:39:44 · 584 阅读 · 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 va原创 2014-12-23 23:10:33 · 401 阅读 · 0 评论 -
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原创 2014-11-16 20:24:28 · 356 阅读 · 0 评论 -
String to Integer (atoi)
Implement atoi to convert a string to an integer.原创 2014-11-20 15:53:47 · 426 阅读 · 0 评论 -
Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.原创 2014-11-20 15:56:26 · 388 阅读 · 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.原创 2014-11-22 00:07:28 · 452 阅读 · 0 评论 -
Median of Two Sorted Arrays
问题:There are two sorted arrays A and B 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)).原创 2014-10-21 13:20:29 · 621 阅读 · 0 评论 -
Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, w原创 2014-10-21 13:19:40 · 523 阅读 · 0 评论 -
Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.原创 2014-11-22 13:50:27 · 424 阅读 · 0 评论 -
Add Two Numbers
问题:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it原创 2014-10-21 13:36:03 · 550 阅读 · 0 评论 -
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 leng原创 2014-10-21 03:52:10 · 551 阅读 · 0 评论 -
Integer to Roman
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.原创 2014-11-22 00:04:41 · 418 阅读 · 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原创 2014-12-23 23:07:53 · 443 阅读 · 0 评论 -
Substring with Concatenation of All Words
You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without原创 2015-04-15 15:06:04 · 586 阅读 · 0 评论