- 博客(20)
- 问答 (1)
- 收藏
- 关注
原创 刷题的日常[Leetcode]——5)Longest Palindromic Substring
题目描述:求一个字符串里最长的回文字串解答:首先,每个字符本身都是一个长度为1的回文字串;以这个字符向两边判断得到的回文子串长度为奇数。其次,对于长度为偶数的回文子串,要从形如AA的字符串向两边判断。因此
2017-03-28 18:50:12
286
原创 Service生命周期
1、通过startService开启服务onCreate->onStartCommand2、通过stopService关闭服务onDestroy说明:如果在未stopService的情况下,再去startService,只会onStartCommand________________________________________________________________
2017-03-20 17:19:38
232
原创 安卓activity生命周期
1、从first_activity单击按钮跳转到second_activity①first_activity:onCreate->onStart->onResume②单击按钮:first_activity:onPause③second_activity:onCreate->onStart->onResume④first_activity:onStop⑤单击返回:second_a
2017-03-20 10:59:08
229
原创 安卓面试
1、Activity的生命周期oncreate->onstart->onresume->onpause->onstop->ondestroy2、onNewIntent调用时机3、Activity的lanchmode,onrestoreInstance的加载时机standard,singletop,singletask,singleinstance4、Android的View
2017-03-15 20:52:07
568
原创 python如何向sqlite3中插入中文字符串
问题描述:将中文词组从txt中读出,再将中文词组插入数据库表中解决:①python默认用unicode来处理sqlite3中的text类型数据,所以会出现OperationalErrorconn=sqlite3.connect(Database)conn.text_factory=str②读出的中文词组编码方式为gbk,所以要对数据进行decode再encodeitem=it
2017-03-13 17:16:21
6652
原创 刷题的日常[Leetcode]——16)3 Sum Closet
题目描述:从一个list里找出三个数,和与target最接近注意:和15题一样,不过题目规定了有唯一解重点是返回值是和,判断条件应该是和与target的差值class Solution(object): def threeSumClosest(self, nums, target): nums.sort() i=0 smin=2147483647 whi
2017-03-09 18:58:33
220
原创 刷题的日常[Leetcode]——15)3 Sum
题目描述:从一个list里找出和为0的三个数,结果不能包含重复值注意:①开始想到的都是从头开始匹配,时间复杂度为O(n^3),就超时了解决:从两头来找②从两头来找就可以固定两个数不变,只有一个数在变,就很好控制没有重复值这个条件③第一个数的index循环的时候,要保证第一个数在之前的计算中未出现过,就是说如果nums[index]==nums[index-1],就继续ind
2017-03-09 16:06:33
234
转载 python的GIL
文章欢迎转载,但转载时请保留本段文字,并置于文章的顶部 作者:卢钧轶(cenalulu) 本文原文地址:http://cenalulu.github.io/python/gil-in-python/GIL是什么首先需要明确的一点是GIL并不是Python的特性,它是在实现Python解析器(CPython)时所引入的一个概念。就好比C++是一套语言(语法)标准,但是可以用不同的编译
2017-03-07 19:56:56
266
原创 安装caffe的问题汇总
1、fatal error: google/protobuf/stubs/common.h: 没有那个文件或目录解决:sudo apt-get install libprotobuf-dev2、 fatal error: hdf5.h: 没有那个文件或目录解决:sudo apt-get install libhdf5-serial-dev
2017-03-02 15:37:16
603
原创 刷题的日常[Leetcode]——344)reverse string
题目描述:把str反转注意:s[::-1]可以倒置字符串class Solution(object): def reverseString(self, s): """ :type s: str :rtype: str """ return s[::-1]if __name__=="__main__
2017-03-02 13:07:27
234
原创 刷题的日常[Leetcode]——500)Keyboard Row
题目描述:判断单词的字母是否都在键盘同一行注意:str="Hello"str.lower()是开了一块新空间,并不是把原有的str覆盖,与list的sort()不一样class Solution(object): def findWords(self, words): """ :type words: List[str]
2017-03-02 12:13:55
212
原创 刷题的日常[Leetcode]——27)Remove Element
题目描述:从一个List中删除所有等于val的数据注意:del (a)会把后面的数据往前移一个,所以下次要判断是否等于val的数据index还是原来的值class Solution(object): def removeElement(self, nums, val): l=len(nums) f=0 i=0 while i<l-f: if nums[i]=
2017-03-02 09:05:25
184
原创 刷题的日常[Leetcode]——9)Palindrom Number
题目描述:判断一个整数是否是回文数(限制:不可开新空间存这个整数)class Solution(object): def isPalindrome(self, x): if x<0: return False t=0 p=x while p>9: t=10*t+p%10 p=p/10 return
2017-03-02 09:01:22
327
原创 刷题的日常[Leetcode]——7)Reverse Integer
题目描述:把123转成321,把-123转成-321class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ sx=str(x) res="" i=len(sx)-1
2017-03-02 08:57:30
143
原创 刷题的日常[Leetcode]——1)Two Sum
题目描述:从一个List里找出相加等于target的两个数,返回这两个数的索引(输入保证存在唯一解)class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: Li
2017-03-02 08:54:22
239
原创 刷题的日常[Leetcode]——461)Hamming Distance and 476)Number complement
都是十进制和二进制的转换461)class Solution(object): def hammingDistance(self, x, y): """ :type x: int :type y: int :rtype: int """ count=0 a=[]
2017-03-02 08:50:29
248
原创 刷题的日常[Leetcode]——8)String to Integer(atoi)
题目描述:实现atoi函数要注意的问题:①atoi会自动去除字符串前面的空格②遇到不是数字和加减号的字符就截断③注意有多个正负号的情况④ord函数可以把字符转成ascii码class Solution(object): def myAtoi(self, str): INT_MAX = 2147483647 INT_MIN = -2147483648 num
2017-02-27 16:28:39
235
原创 刷题的日常[Leetcode]——4)median of two sorted arrays
题目描述:从两个排好序的数组里找到中间值要注意的问题:① 时间复杂度的要求需要用折半查找② 考虑nums1或nums2为空的情况考虑nums2中数值比nums1第一个小或者最后一个大的情况class Solution(object): def findMedianSortedArrays(self, nums1, nums2): if len(nums1
2017-02-27 15:04:55
173
原创 刷题的日常[Leetcode]——2)Add Two Numbers
要注意的问题:① 返回的值是要包含第一个val=0的节点的解决:直接从l1和l2的构造时第一个val=0的节点开始做加法② 要注意l1和l2长度不一致的情况解决:取l1和l2节点值的时候要判断是否为空③ 要注意最后一个节点数值>9的情况解决:循环要加上商值的判断,如果商值不为0,应继续循环;要给取l1和l2的变量赋初值# Definition for singly-li
2017-02-27 15:01:50
227
空空如也
如何将索引结构写入外存,并能实现再次读取
2013-07-10
TA创建的收藏夹 TA关注的收藏夹
TA关注的人