- 博客(12)
- 收藏
- 关注
原创 Leetcode-Algorithms Median of Two Sorted Arrays
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)).Example 1: nums1 = [1, 3] num
2017-02-28 05:28:27
215
原创 Leetcode-Algorithms Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it
2017-02-27 07:33:56
247
原创 Python 备忘
有时候会忘一些基础的知识,写一篇作为备忘不定时更新。运算符:算术: / - 除法: 1/3 = 0.333333333, 6/3 = 2.0 // - 取整除: 1//3 = 0, 4//3 = 1 % - 取模(取余): 2%5 = 5, 10%5 = 0, 3%5 = 3, 1%5 = 1, 4%5 = 4 ** - 次方: 5**2 = 10, 3**3 = 27比较: <>:不等于
2017-02-26 12:53:11
284
原创 Leetcode-Algorithms 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 extra me
2017-02-26 12:26:07
208
原创 Leetcode-Algorithms Reverse String
Write a function that takes a string as input and returns the string reversed.Example: Given s = “hello”, return “olleh”.就是return一个反过来的string。class Solution(object): def reverseString(self, s):
2017-02-26 12:02:16
187
原创 Leetcode-Algorithms Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the
2017-02-26 11:44:09
216
原创 Leetcode-Algorithms 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, and you may not use the same ele
2017-02-26 11:13:52
561
原创 Leetcode-Algorithms Next Greater Element I
You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1’s elements in the corresponding places of nums2.The
2017-02-20 12:45:05
192
原创 Leetcode-Algorithms Nested List Weight Sum
Given a nested list of integers, return the sum of all integers in the list weighted by their depth.Each element is either an integer, or a list – whose elements may also be integers or other lists.Exa
2017-02-20 05:04:18
279
原创 Leetcode-Algorithms Keyboard Row
Given a List of words, return the words that can be typed using letters of alphabet on only one row’s of American keyboard like the image below.Example 1: Input: [“Hello”, “Alaska”, “Dad”, “Peace”] O
2017-02-20 01:51:28
262
原创 Leetcode-Algorithms Number Complement(数字补码)
Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note: The given integer is guaranteed to fit within the range of a 32-b
2017-02-20 01:36:54
247
原创 Leetcode-Algorithms Hamming Distance(汉明距离)
从今天开始每天用python做几道leetcode的题目练手,从easy到hard递进。The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the
2017-02-19 13:07:22
507
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人