Python & JAVA Solutions for Leetcode. Contribute to liujinstat/leetcode development by creating an account on GitHub.
[leetcode 004] 寻找两个有序数组的中位数 题目:给定两个有序数组,找出它们合并后所得数组的中位数。 例如: nums1=[1,3] nums2=[2] 中位数为2; nums1=[1,2] nums2=[3,4] 中位数为: (2+3)/2=2.5. classSolution(object):deffindMedianSortedArrays(self, nums1, nums2):""":type nums1...
参考链接:https://github.com/qiyuangong/leetcode/blob/master/python/008_String_to_Integer(atoi).py
[leetcode 001] 两数之和 给定一个整数数组nums和一个目标值target,在该数组中找出和为目标值的两个整数,并返回他们的数组下标。 classSolution(object):deftwo_sum:""" :type nums: List[int] :type target: int :rtype: List[int] """n=len(nums)forxinrange(n):foryinrange(x+1,n):ifnums[y...
[leetcode 005] 最长回文字符串 给定一个字符串s,在其中寻找它的最长回文字符串,可以假设s的最长长度为1000。 例如: 输入:babad 输出:bab (或aba) 代码 classSolution(object):deflongestPalindrome(self, s):""":type s: str :rtype: str"""n=len(s)ifn == 1:returns...