- 博客(23)
- 收藏
- 关注
转载 20. Valid Parentheses
题意判断输入的字符串是否合法。输入的字符串只包含“()[]{}”要求所有的括号都被正确的关闭。另外,空字符串也是合法的。Example 1:Input: "()"Output: trueExample 2:Input: "()[]{}"Output: trueExample 3:Input: "(]"Output: false...
2019-03-29 14:17:00
87
转载 19. Remove Nth Node From End of List
移除链表倒数第n个节点。Example:Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the linked list becomes 1->2->3->5.另外,题目要求遍历一遍完成。我的思路...
2019-03-29 11:26:00
71
转载 18. 4Sum
有了前面的基础这道题的思路也很清晰了,无非是把4Sum转换为3Sum解决。这里实现Nsum完成对此类题的通用解法。 1 class Solution: 2 def twoSum(self, nums, target, index): 3 left, right = index, len(nums) - 1 4 result ...
2018-12-24 18:46:00
72
转载 17. Letter Combinations of a Phone Number
Given a string containing digits from2-9inclusive, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) i...
2018-12-24 18:23:00
79
转载 16. 3Sum Closest
Given array nums = [-1, 2, 1, -4], and target = 1.The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).N sum系列。寻找与目标最相近的三数之和。因为不用处理重复的问题,所以这道题反而更简单点要注意的是在求和的值与目标相等时,就可以直接返回了 1...
2018-12-24 17:30:00
59
转载 15. 3Sum
Given array nums = [-1, 0, 1, 2, -1, -4],A solution set is:[ [-1, 0, 1], [-1, -1, 2]]先排序,再用三个指针协同操作,最后再考虑处理重复数据。 1 class Solution: 2 def threeSum(self, nums): 3 ...
2018-12-02 21:08:00
65
转载 14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string "".查找一组字符串中的最长前缀。这道题解起来很简单,方法也很多,记录一下比较容易想到的两种方...
2018-12-02 20:58:00
70
转载 13. Roman to Integer
把12题反了过来,不多说了随便写写 1 public class Solution { 2 public int RomanToInt(string s) { 3 int i = 0, result = 0; 4 while (i < s.Length) 5 { 6 if (...
2018-12-02 20:39:00
62
转载 12. Integer to Roman
Roman numerals are represented by seven different symbols:I,V,X,L,C,DandM.Symbol ValueI 1V 5X 10L 50C 100D ...
2018-11-12 17:24:00
50
转载 11. Container With Most Water
给定n个非负整数a1,a2,...,an,每个数代表坐标中的一个点(i,ai) 。在坐标内画n条垂直线,垂直线i的两个端点分别为(i,ai) 和 (i, 0)。找出其中的两条线,使得它们与x轴共同构成的容器可以容纳最多的水。说明:你不能倾斜容器,且n的值至少为 2图中垂直线代表输入数组 [1,8,6,2,5,4,8,3,7]。在此情况下,容...
2018-11-12 16:49:00
58
转载 10. Regular Expression Matching
Given an input string (s) and a pattern (p), implement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more of the preceding elem...
2018-11-12 14:09:00
68
转载 9. Palindrome Number
Determine whether an integer is a palindrome. An integerisapalindrome when itreads the same backward as forward.Example 1:Input: 121Output: trueExample 2:Input: -121Output: fals...
2018-11-07 18:48:00
57
转载 8. String to Integer (atoi)
这题无聊到我都懒得把题目复制过来。。造轮子,实现atoi函数。没什么技术含量,就是考虑各种边界情况。 1 public class Solution { 2 public int MyAtoi(string str) { 3 bool isNega = false; 4 bool hasSignal = fals...
2018-11-06 00:01:00
77
转载 7. Reverse Integer
Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:Assume we ...
2018-11-05 23:58:00
68
转载 6. 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 N...
2018-11-05 23:50:00
72
转载 5.Longest Palindromic SubString
Given a strings, find the longest palindromic substring ins. You may assume that the maximum length ofsis 1000.Example 1:Input: "babad"Output: "bab"Note: "aba" is also a valid answer....
2018-11-05 23:28:00
71
转载 4.Median of Two Sorted Arrays
There are two sorted arraysnums1andnums2of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).You may assumenums1...
2018-11-05 23:19:00
55
转载 3.Longest Substring Without Repeating Characters
Given a string, find the length of thelongest substringwithout repeating characters.Example 1:Input: "abcabcbb"Output: 3 Explanation: The answer is "abc", with the length of 3. Ex...
2018-11-02 11:35:00
68
转载 2.Add Two Numbers
You are given twonon-emptylinked lists representing two non-negative integers. The digits are stored inreverse orderand each of their nodes contain a single digit. Add the two numbers and ret...
2018-11-01 15:02:00
58
转载 1.Two Sum
Given an array of integers, returnindicesof the two numbers such that they add up to a specific target.You may assume that each input would haveexactlyone solution, and you may not use the...
2018-11-01 14:57:00
57
转载 Git常用命令
#最近Git用的相对较少,一些命令在用的时候经常会想不起来,这里针对常用命令做一个记录#(图片来源自网络)一、添加/删除文件# 添加指定文件到暂存区$ git add <file># 添加指定目录及子目录到暂存区$ git add <dir># 把工作区所有文件添加到暂存区$ git add .# 删除指定文件,并将本次删除添...
2018-04-17 17:24:00
67
转载 简述WPF中的Binding
Data Binding机制可以说是WPF实现MVVM的关键,与之配套的Dependency Property和DataTemplate共同完成了数据到UI的通路,让逻辑层与UI分离。本文主要基于个人的理解,针对Data Binding简要概括其主要用法、特性及注意事项等。------------------------------------------------------...
2017-12-15 14:06:00
213
转载 用最小二乘法线性拟合
先上代码: 1 /// <summary> 2 /// 最小二乘法线性拟合 3 /// </summary> 4 /// <param name="x">横坐标集合</param> 5 /// <param name="y">纵坐标集合</param>...
2017-08-31 16:42:00
344
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人