leetcode
文章平均质量分 69
DinnerHowe
这个作者很懒,什么都没留下…
展开
-
leetcode: 1 Two Sum
最近开始刷leetcode, 这是第一题,没什么复杂的直接上代码好了题目是: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 sol...原创 2017-02-27 14:40:41 · 668 阅读 · 0 评论 -
leetcode: string_compress
突然想到一个题目,有一组字符串s='aaaabbbccccabsdsdaaadddddd' 要求对该字符串进行压缩,并且空间复杂度最小例如:s的压缩结果是:‘a4b3c4absdsda3d6’代码如下:class Solution: def str_compress(self, s): result = temp = seg = '' cout = 1 ...原创 2017-03-04 17:22:40 · 477 阅读 · 0 评论 -
leetcode: 2 Add_Two_Numbers
第二题,没什么复杂的直接上代码好了,简单说就是首先两个链表相加,然后反向存储,最后转化成list输出#!/usr/bin/env python # -*- coding:utf-8 -*- """ Copyright (c) 2017 Xu Zhihao (Howe). All rights reserved. This program is free software; you can re...原创 2017-02-27 18:47:31 · 443 阅读 · 0 评论 -
leetcode:3 Longest_Substring_Without_Repeating_Characters
Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "b", with the l...原创 2017-03-04 18:37:07 · 385 阅读 · 0 评论