自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(13)
  • 资源 (1)
  • 收藏
  • 关注

原创 leetcode-05- Longest Palindromic Substring-python

求最大回文子串。回文子串即为对称的字符串。 本能笨思路:遍历所有元素当作中心元素,左右移位判断是否相等。注意边界问题,还有就是按照是否有中心元素分为两种情况。 代码如下,理所当然没通过。。vs下自己测试了一些应该算法应该没问题。class Solution(object): def longestPalindrome(self,s): maxlen=0 i

2016-03-31 16:46:02 719 1

原创 leetcode04-Median of Two Sorted Arrays-python

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-03-31 15:11:13 1688

原创 leetcode-03-Longest Substring Without Repeating Characters-python

找出一串字符中最常不重复的字符个数。 o(n*n)的方法class Solution(object): def lengthOfLongestSubstring(self,s): b=[] if len(s)==0: return 0 else: for index,i in enumerate

2016-03-30 15:25:56 416

原创 leetcode-001-two sum-python

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.Example: Given nums = [2, 7, 11,

2016-03-29 14:39:47 343 1

原创 checkio--

checkio进不去,代码vs测试通过应该没问题。暂且保留记录。import copy def checkio(price, denominations): l=len(denominations) a=denominations b=[price] p=1 k=0 while(max(b)>=min(denominations)):

2016-03-29 09:03:23 2118

原创 checkio min and max

自己写的代码和下面这个思路很像,但是测试没通过。iter和next没用到。用的是赋值比较。然后有个编程的思想就是never repeat yourself。显然这个代码做的不够好。但是由于是对应的函数所以也没什么关系。def min(*args, **kwargs): key = kwargs.get("key", lambda x: x) length = len(args)

2016-03-25 11:47:18 983 2

原创 checkio the most frequent weekdays

Input: Year as an int. Output: The list of most frequent days sorted by the order of days in week (from Monday to Sunday). 找出一年中最多的那个星期几。from datetime import * from datetime import timedelta def most

2016-03-25 11:38:08 1054

原创 primitive calculator

Problem Description Task. Given an integer n, compute the minimum number of operations needed to obtain the number n starting from the number 1. Input Format. The input consists of a single inte

2016-03-21 09:26:32 797

原创 checkio-how to find friends

寻找朋友。 想法是找到所有和first有关系的朋友(包括1跳关系及多跳关系)。问题是怎么找多跳关系的朋友加到列表里面。看别人的代码,解释。。。 第一个,by***StefanPochmann***def check_connection(network, first, second): team = {first} for _ in network: for ed

2016-03-10 16:51:01 789

原创 checkio-unlucky days

Friday 13th or Black Friday is considered as unlucky day. Calculate how many unlucky days are in the given year. Find the number of Friday 13th in the given year. Input: Year as an integer. Output:

2016-03-03 14:46:01 644 6

原创 checkio-pawn brotherhood

题目意思是给定一个8*8的棋盘,同时给定8个棋子的位置。如果某一个棋子的位置可以由其他棋子一步到达,则认为该棋子安全。判断8个棋子中安全的棋子的个数。 如图所示,左边的安全棋子个数为6,右边的位1。思路:遍历给定的集合(set)里面的所有元素,然后转换为list。然后利用ord 和chr 转换求出该棋子左下和右下的棋子的位置坐标。如果该坐标在原来的集合中,则num+1。最后返回num。 代码如下

2016-03-03 11:00:06 1621 4

原创 checkio-the flat dictionary

尼古拉喜欢对一切看到的东西进行分类。 有一次,斯蒂芬送了他一个标签机作为他的生日礼物, 机器人把在船上的每个面的标签撕了几个星期。 从那时起,他归类在他的实验室的所有试剂, 图书馆的书和在桌子上笔记。 但后来他得知 python 字典,并分类所有索菲亚的机器人的可能的配置。 现在,这些文件被组织在一个很深的嵌套结构, 但索菲亚并不喜欢这样。让我们帮助索菲亚扁平化这些字典。 Python字典是一种可

2016-03-02 11:23:54 771

原创 checkio-speech module

史蒂芬的语音模块坏了。该模块是负责他的数字发音的。他必须点击输入所有数字,因此当有大数字就要花费他很长的时间来输入。为他写一个新的语音模块帮助机器人正常说话并且增加他的数字的处理速度。字符串中的所有单词必须以一个空格字符分隔。请小心使用空格 – 如果你把两个空格当做一个,那是很难看到的。输入: 作为整数(int)的一个数字。输出: 代表数字的字符串。(str)范例:checkio(4)==’four

2016-03-02 09:49:26 393

linux-headers-3.18.5+_3.18.5+-2_armhf

linux-headers-3.18.5+_3.18.5+-2_armhf

2016-04-13

空空如也

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

TA关注的人

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