- 博客(16)
- 收藏
- 关注
原创 leetcode中等.数组(1-20)python
15. 3Sum(m-1)Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.class Solution(object...
2018-10-28 14:03:21 489
原创 python 排序
数据结构常见排序性能比较插入排序直接插入排序的核心思想就是:将数组中的所有元素依次跟前面已经排好的元素相比较,如果选择的元素比已排序的元素小,则交换,直到全部元素都比较过。因此,从上面的描述中我们可以发现,直接插入排序可以用两个循环完成:第一层循环:遍历待比较的所有数组元素第二层循环:将本轮选择的元素(选定)与已经排好序的元素(ordered)相比较。如果:选择&g...
2018-10-27 12:22:11 256
原创 leetcode简单(201-220)python
852. Peak Index in a Mountain Array(e-201)Let's call an array A a mountain if the following properties hold:A.length >= 3 There exists some 0 < i < A.length - 1 such that A[0] < A[1] ...
2018-10-24 11:17:00 627
原创 leetcode简单(181-200)python
762. Prime Number of Set Bits in Binary Representation(e-181)Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary r...
2018-10-22 14:41:22 523
原创 leetcode简单(161-180)python
690. Employee Importance(e-161)You are given a data structure of employee information, which includes the employee's unique id, his importance value and his direct subordinates' id.For example, em...
2018-10-18 12:49:39 522
原创 自定数据,求Weights和Biases
自己构建一些数据,来求Weights和Biases#create dataimport tensorflow as tfimport numpy as npx_data = np.random.rand(100).astype(np.float32)y_data = x_data*0.1 + 0.3#create tensorflow structureWeights...
2018-10-17 15:04:11 328
原创 leetcode简单(141-160)python
606. Construct String from Binary Tree(e-141)---------You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way.The null node needs to...
2018-10-16 16:08:37 357
原创 leetcode(121-140)简单题python
532. K-diff Pairs in an Array(121)Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j...
2018-10-14 11:12:21 1662
原创 leetcode简单题101-120(python)
455. Assign Cookies(e-101)Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which ...
2018-10-12 15:56:07 611
原创 leetcode简单题81-100(python)
387. First Unique Character in a String(e-81)-----------Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.389. Find the Difference(...
2018-10-11 15:45:06 678
原创 leetcode简单61-80(python)
242. Valid Anagram(e-61)Given two strings s and t , write a function to determine if t is an anagram of s.class Solution(object): def isAnagram(self, s, t): """ :type s: str ...
2018-10-06 16:04:28 387
原创 leetcode简单41-60(python)
171. Excel Sheet Column Number(e-41)Given a column title as appear in an Excel sheet, return its corresponding column number.class Solution(object): def titleToNumber(self, s): """ ...
2018-10-05 17:07:52 299
原创 leetcode简单题21-40(python)
100. Same Tree(e-21)Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the...
2018-10-04 23:26:29 462
原创 leetcode 简单题目(python)1-20
1. Two Sum(e-1)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 ...
2018-10-03 23:42:20 497
原创 python基础练习25-39
26.求100之内的素数。for i in range(2,101): for j in range(2,i): if i % j==0: break else: print(i)27.对10个数进行排序。这里用的是冒泡法if __name__ == "__main__": N = 10 # i...
2018-10-03 00:47:18 477
原创 python基础练习1-25
1.有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少?for i in range(1,5): for j in range(1,5): for k in range(1,5): if( i != k ) and (i != j) and (j != k): print (i,j,k...
2018-10-02 14:53:26 1299
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人