
LeetCode
镜光止凄水
喵!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode #1 Two Sum C# Solution
LeetCode #1 Problem 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. Ex原创 2016-04-03 14:00:12 · 1300 阅读 · 0 评论 -
LeetCode #22 Generate Parentheses C# Solution
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.这题如果不要输出各个结果的话那答案就是卡特兰数。但是他要你输出了= =可以注意到一点,就是在第n个括号放下的时候,1到n总体而言,左括号的数量大于或等于右括号。然后通过这原创 2016-07-02 16:10:09 · 621 阅读 · 0 评论 -
LeetCode #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: Elements in a triplet (a,b,原创 2016-05-30 19:33:09 · 246 阅读 · 0 评论 -
LeetCode #21 Merge Two Sorted Lists C# Solution
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.一道简单的链表题,然而我用了太久list<>已经忘记链表怎么做了= = 总而言之非常感谢http://www.cnb原创 2016-06-27 13:56:03 · 484 阅读 · 0 评论 -
LeetCode #17 Letter Combinations of a Phone Number C# Solution
Given a digit string, return all possible letter combinations that the number could represent. ex: Input:Digit string “23” Output: [“ad”, “ae”, “af”, “bd”, “be”, “bf”, “cd”, “ce”, “cf”].回溯算法原创 2016-06-01 21:19:00 · 641 阅读 · 0 评论 -
LeetCode #14 Longest Common Prefix C# Solution
Write a function to find the longest common prefix string amongst an array of strings. 题目只有一句话,意思是求出一个字符串数组的公共最长前缀。 求出第一个和第二个字符串的前缀,然后用这个前缀和之后的字符串进行匹配。如果发现strs中有空串则直接返回。C# Code public class Solut原创 2016-05-30 07:56:03 · 355 阅读 · 0 评论 -
LeetCode #11 Container With Most Water C# Solution
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 of line i is at (i, ai) and (i, 0). Find two lin原创 2016-05-05 15:17:42 · 559 阅读 · 0 评论 -
LeetCode #12 Integer to Roman C# Solution
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.最开始的我还是太天真了。我甚至以为罗马符号只有X,V,I 我还是图simple啊…… “M”,”CM”,”D”,”CD”,”C”,”XC”,”L”,”XL”,”X”,”IX原创 2016-05-05 15:39:38 · 402 阅读 · 0 评论 -
LeetCode #9 Palindrome Number C# Solution
Determine whether an integer is a palindrome. Do this without extra space.题目只有很简单的一句话,然而提示又是一大堆 Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of converti原创 2016-04-16 10:43:54 · 437 阅读 · 0 评论 -
LeetCode #8 String to Integer (ATOI) C# Solution
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 input c原创 2016-04-16 10:37:44 · 619 阅读 · 0 评论 -
LeetCode #7 Reverse Integer C# Solution
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 题目本身不难,主要是要注意很多情况。 Have you thought about this? Here are some good questions to ask before co原创 2016-04-16 10:28:59 · 353 阅读 · 0 评论 -
LeetCode #6 ZigZag Conversion C# Solution
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)可能有人不知道ZigZag是什么意思,其实就是给一个字符原创 2016-04-16 10:25:17 · 462 阅读 · 0 评论 -
LeetCode #5 Longest Palindromic Substring C# Solution
LeetCode #5 Problem Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.这题是原创 2016-04-15 09:00:47 · 400 阅读 · 0 评论 -
LeetCode #4 Median of Two Sorted Arrays C# Solution
LeetCode #4 Problem 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)).这道题应该是原创 2016-04-14 09:19:59 · 622 阅读 · 0 评论 -
LeetCode #3 Longest Substring Without Repeating Characters C# Solution
LeetCode #3 Problem 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原创 2016-04-13 07:35:24 · 513 阅读 · 0 评论 -
LeetCode #2 Add Two Numbers Cpp Solution
LeetCode #2 Problem 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 a原创 2016-04-04 11:54:52 · 458 阅读 · 0 评论 -
LeetCode #20 Valid Parentheses C# Solution
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原创 2016-06-18 21:50:42 · 562 阅读 · 0 评论