leetcode - python实现
peerless_me
这个作者很懒,什么都没留下…
展开
-
【python】【leetcode】【算法题目338—Counting Bits】
一、题目描述题目原文:Given a non negative integer numbernum. For every numbersiin the range0 ≤ i ≤ numcalculate the number of 1's in their binary representation and return them as an array.(给出一个非负整数n原创 2020-04-07 15:35:20 · 136 阅读 · 0 评论 -
【python】【leetcode】【算法题目2—Add Two Numbers】
一、题目描述题目原文:You are given two linked lists representing two non-negative numbers.The digits are stored in reverse order and each of their nodes contain a single digit.Add the two numbers an...原创 2016-11-21 12:05:45 · 5764 阅读 · 9 评论 -
【python】【leetcode】【算法题目64—Minimum Path Sum】
题目描述题目原文:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either d原创 2017-09-12 09:45:12 · 1032 阅读 · 0 评论 -
【python】【leetcode】【算法题目167—Two Sum II - Input array is sorted】
一、题目描述题目原文:Given an array of integers that is alreadysorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indi原创 2016-12-04 14:51:39 · 452 阅读 · 0 评论 -
【python】【leetcode】【算法题目387—First Unique Character in a String】
一、题目描述题目原文:Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.(输入一个字符串,给出此串中非重复的字符,并返回其下标,若不存在则返回-1)二、题目分析原创 2016-12-04 14:18:57 · 1078 阅读 · 0 评论 -
【python】【leetcode】【算法题目12—Integer to Roman】
一、题目描述题目原文:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.(给出数字1~3999中的一个数字,把它转化为罗马数字输出)二、题目分析思路:建立一个字典,将原创 2016-12-04 13:14:55 · 720 阅读 · 0 评论 -
【python】【leetcode】【算法题目383—Ransom Note】
一、题目描述题目原文:Given an arbitrary ransom note string and another string containing letters from all the magazines, write a functionthat will return true if the ransom note can be construct原创 2016-12-04 12:35:39 · 619 阅读 · 0 评论 -
【python】【leetcode】【算法题目283—Palindrome Number】
一、题目描述题目原文:Given an arraynums, write a function to move all0's to the end of it while maintaining the relative order of the non-zero elements.(输入一个数字列表,我们要把所有的0元后置,并要保持非0元的原顺序)举例原创 2016-12-04 12:23:49 · 268 阅读 · 0 评论 -
【python】【leetcode】【算法题目389—Find the Difference】
一、题目描述题目原文:Given two stringssandtwhich consist of only lowercase letters.Stringtis generated by random shuffling stringsand then add one more letter at a random position.Find原创 2016-12-04 12:03:33 · 662 阅读 · 0 评论 -
【python】【leetcode】【算法题目412—Fizz Buzz】
一、题目描述题目原文:Write a program that outputs the string representation of numbers from 1 ton.But for multiples of three it should output “Fizz” instead of the number and for the multiples of原创 2016-12-04 11:24:31 · 1395 阅读 · 0 评论 -
【python+Java】【leetcode】【算法题目344—Reverse String】
一、题目描述题目原文:Write a function that takes a string as input and returns the string reversed.(反转输出字符串)举例:Given s = "hello", return "olleh".二、题目分析思路1:用python中切片的原创 2016-11-28 17:18:01 · 298 阅读 · 0 评论 -
【python】【leetcode】【算法题目6—ZigZag Conversion】
一、题目描述题目原文:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this:(you may want to display this pattern in a fixed font for better legibility)原创 2016-11-26 15:44:31 · 1523 阅读 · 0 评论 -
【python】【leetcode】【算法题目4—Median of Two Sorted Arrays】
一、题目描述题目原文:There are two sorted arraysnums1andnums2of 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-11-23 09:21:40 · 415 阅读 · 0 评论 -
【python】【leetcode】【算法题目7—Reverse Integer】
一、题目描述题目原文:Reverse digits of an integer.(将一个整数反转输出)举例:Example1:x = 123, return 321Example2:x = -123, return -321注意:If the integer's last digit is 0,原创 2016-11-21 13:34:22 · 405 阅读 · 0 评论 -
【python】【leetcode】【算法题目9—Palindrome Number】
题目原文:Determine whether an integer is a palindrome. Do this without extra space.(不用额外的空间来判断一个整形数字是不是回文数)Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integer to string, note the restriction of using ex原创 2016-11-28 11:37:37 · 579 阅读 · 0 评论 -
【python】【leetcode】【算法题目1—Two Sum】
【python】【leetcode】【算法题目1—Two Sum】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.输入一个整型列表,以及一个目标值,返回该列表中加和为目标值的两个数的下标原创 2016-11-21 09:22:43 · 311 阅读 · 0 评论