
leetcoding in python
accumulate_zhang
我好像什么都不会,真的!!!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
500 keyboard row
one day an cannon!!! or one week five cannons!!! 500 keyboard row 题目说明: Given a List of words, return the words that can be typed using letters of alphabet on only one row'原创 2017-02-16 20:42:57 · 565 阅读 · 0 评论 -
leetcode 530. Minimum Absolute Difference in BST
leetcode 530. Minimum Absolute Difference in BST #coding=utf-8 ''' Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nod原创 2017-04-04 22:46:53 · 889 阅读 · 0 评论 -
leetcode 506. Relative Ranks
leetcode 506. Relative Ranks #coding=utf-8 '''Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: "Gold Medal",原创 2017-04-04 23:16:33 · 638 阅读 · 0 评论 -
leetcode 350. Intersection of Two Arrays II
python leetcode 求两个数组的交集350. Intersection of Two Arrays II Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2],原创 2017-04-18 12:15:58 · 315 阅读 · 0 评论 -
leetcode 383. Ransom Note
Python leetcode leetcode 383. Ransom Note Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ran原创 2017-04-14 18:58:52 · 506 阅读 · 0 评论 -
leetcode 453. Minimum Moves to Equal Array Elements
Python leetcode 453. Minimum Moves to Equal Array Elements Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a原创 2017-04-14 19:01:30 · 422 阅读 · 0 评论 -
leetcode 404. Sum of Left Leaves
Python leetcode 404. Sum of Left Leaves Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two left leaves in原创 2017-04-15 09:35:20 · 769 阅读 · 0 评论 -
leetcode 387. First Unique Character in a String
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. Examples:原创 2017-04-15 10:24:32 · 697 阅读 · 0 评论 -
leetcode 122. Best Time to Buy and Sell Stock II
python leetcode 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 maximu原创 2017-04-15 12:00:36 · 602 阅读 · 0 评论 -
leetcode 242. Valid Anagram
Python leetcode 242. Valid Anagram 242. Valid Anagram Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = "anagram", t = "nagaram"原创 2017-04-16 10:54:47 · 392 阅读 · 0 评论 -
leetcode 504. Base 7
python leetcode 504. Base 7 Given an integer, return its base 7 string representation. 将十进制转为7进制,其他进制的转换类似。 记住几个常见的内置函数。bin(),hex(),oct()....分别是十进制数转二进制,十六机制,和八进制。 Example 1:原创 2017-04-16 12:25:49 · 411 阅读 · 0 评论 -
leetcode 409. Longest Palindrome
409. Longest Palindrome 求给定一个字符串的最长回文字符串的长度。 Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with th原创 2017-04-16 14:12:48 · 385 阅读 · 0 评论 -
leetcode 447. Number of Boomerangs
Python leetcode 447. Number of Boomerangs 给定n个二维坐标点,存在这样的坐标点三元组(i,j,k),就是i到j的距离等于i到k的距离,其中i,j,k都是坐标点。同时,i到k的距离等于i到j的距离,那么就有两种形式[i,j,k]和[i,k,j],都表示这样特点的三元组。那么根据题意,这就是boomerang。每个符合的三个原创 2017-04-20 10:05:35 · 617 阅读 · 0 评论 -
561. Array Partition I
Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large a原创 2018-01-29 22:40:42 · 251 阅读 · 0 评论 -
leetcode 226. Invert Binary Tree
226. Invert Binary Tree Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 #coding=utf-8原创 2017-03-27 07:53:23 · 469 阅读 · 0 评论 -
LeetCode 371(Sum of Two Integers)
371. Sum of Two Integers Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example: Given a = 1 and b = 2, return 3. 首先水一波,自己写的牛头不对马嘴,原创 2017-03-26 23:04:19 · 303 阅读 · 0 评论 -
476Number Complement
one day one cannon or one week five connon #coding=utf-8 ''' Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representatio原创 2017-02-17 16:16:53 · 447 阅读 · 0 评论 -
496Next Greater Element
one day one cannon or one week five cannons 496 Next Greater Element I You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all原创 2017-02-19 20:12:33 · 362 阅读 · 0 评论 -
412. Fizz Buzz
one day one cannon or one week five cannons 412. Fizz Buzz Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output原创 2017-02-19 21:51:15 · 540 阅读 · 0 评论 -
python leetcode461 汉明距离
one day a cannon or one week five cannons leetcode 461 hamming distance (Source) The Hamming distance between two integers is the number of positions at which the corresponding bits are diffe原创 2017-02-15 22:03:50 · 2225 阅读 · 0 评论 -
leetcode 258 Add Digits
简单来说就是求给定一个数的每个位置数值的相加 #coding=utf-8 ''' Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process原创 2017-03-27 16:57:45 · 676 阅读 · 0 评论 -
leetcode 283. Move Zeroes
#coding=utf-8 ''' Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, given nums = [0, 1, 0, 3, 12], aft原创 2017-03-28 20:07:15 · 358 阅读 · 0 评论 -
leetcode 463. Island Perimeter
很难坚持啊,一题要好长时间....... 不搞什么虚的了,还是尽量坚持下去..... You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontal原创 2017-03-25 16:50:09 · 464 阅读 · 0 评论 -
leetcode 485. Max Consecutive Ones
485. Max Consecutive Ones Given a binary array, find the maximum number of consecutive 1s in this array. 就是让你求一个二进制数组中字符1的最大长度..... Example 1: Input: [1,1,0,1,1,1] Output: 3 Explanation:原创 2017-03-25 18:31:12 · 483 阅读 · 0 评论 -
leetcode 136. Single Number
Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using e原创 2017-03-26 08:48:09 · 716 阅读 · 0 评论 -
448. Find All Numbers Disappeared in an Array
448. Find All Numbers Disappeared in an Array Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of原创 2017-03-26 09:45:33 · 370 阅读 · 0 评论 -
leetcode 520. Detect Capital
#coding=utf-8 ''' Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of the following cases hold原创 2017-03-26 17:56:00 · 396 阅读 · 0 评论 -
leetcode 104. Maximum Depth of Binary Tree
leetcode 104. Maximum Depth of Binary Tree #coding=utf-8 ''' Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root原创 2017-03-26 19:47:29 · 343 阅读 · 0 评论 -
leetcode 389. Find the Difference
389. Find the Difference Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at a random positi原创 2017-03-26 20:41:56 · 361 阅读 · 0 评论 -
766. Toeplitz Matrix
A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element. Now given an M x N matrix, return True if and only if the matrix is Toeplitz. Example 1: Input: m原创 2018-01-30 14:00:46 · 244 阅读 · 0 评论