自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(20)
  • 收藏
  • 关注

原创 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 555

原创 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 425

原创 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 513

原创 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 586

原创 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 209

原创 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 319

原创 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 347

原创 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 516

原创 南京理工大学第八届程序设计大赛 #C Count_Prime Solution

Description 给定你一个数n,请你统计出在[a,b]这个区间中和n互质的数的个数。 两个数互质当且仅当他们除了1之外没有其他的公共因子或者他们最大的公共因子是1。1和任何数是互素的。 Input 第一行输入一个整数T(1 <= T <= 100),表示T组测试数据。 接下来T行,每行3个整数a,b,n(1 <= a <=b <=10^15, 1<= n <= 10^9),用空

2016-04-19 10:46:51 269

原创 南京理工大学第八届程序设计大赛 #J WATER1 Solution

Description 听说全球气候变暖,冰川融化,海水淹大地。着实好奇要融化多少冰川会淹没我的宿舍,哦不,淹没南京,反正NJUST应该总会是第一批被淹的。 现将问题简化成一个二维坐标系的模型。有N个矩形块区域,每个区域有海拔(H)和宽度(W),区域按照顺序给出,比如有3个区域,第一个区域宽度为1,海拔为2,第二个区域宽度为5,海拔为6,第三个区域宽度为3,海拔为4,从图像上看就是像这

2016-04-19 10:38:23 368

原创 南京理工大学第八届程序设计大赛 #A 偷吃糖果 Solution

Description 小鱼喜欢吃糖果。他有两盒糖果,两盒糖果分别仅由小写字母组成的字符串s和字符串t构成。其中’a’到’z’表示具体的某种糖果类别。 他原本打算送给他喜欢的女生,但是要送给女孩子的话两盒糖果不能有差别(即字符串s和t完全相同)。所以,他决定偷吃几块,他吃糖果的策略是每次选出一盒糖果中两个连续的同种类别的糖果,然后吃掉其中一块。该策略可以使用多次。 例如一盒糖果是’

2016-04-19 10:13:54 393

原创 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 387

原创 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 555

原创 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 307

原创 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 403

原创 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 351

原创 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 561

原创 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 450

原创 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 419

原创 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 1217

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除