- 博客(9)
- 收藏
- 关注
原创 牛客网笔试 python 读取多行输入
import sysnum = sys.stdin.readline().strip()list = []try: while True: line = sys.stdin.readline().strip() if line == '': break lines = line.split() #...
2019-03-16 09:51:49
12473
原创 217. Contains Duplicate
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is...
2018-03-23 14:31:39
199
原创 189. Rotate Array
Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. Note:Try to come up as many solutions as you can, ther...
2018-03-23 12:02:17
231
原创 122. Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one an...
2018-03-23 11:43:25
243
原创 26.Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifying the ...
2018-03-23 11:28:52
182
原创 leet code2 Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i...
2018-03-15 13:42:53
296
原创 leetcode 9 Palindrome Number
判断一个整形变量是否是回文数。class Solution(object): def isPalindrome(self, x): """ :type x: int :rtype: bool """ a = str(x) return(a==a[::-1])//str[a:-b:c]表示输出字符串从a位置开始...
2018-03-05 10:36:41
205
原创 leetcode 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: 21//给出一个32位有符号整形变量,对这个整形变量进行反转//由于我把整形转为字符...
2018-03-05 10:09:01
206
原创 leetcode 1 Two Sum
Given nums = [2, 7, 11, 15], target = 9,Because nums[0] + nums[1] = 2 + 7 = 9,return [0, 1]//给定一个数组与目标值,使列表中两数相加等于目标值,返回值为两数在列表中的位置。class Solution(object): def twoSum(self, nums, target): ...
2018-03-05 09:19:25
316
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人