- 博客(42)
- 收藏
- 关注
转载 141. Linked List Cycle
Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 1 # Definition for singly-linked list. 2 # class ListNode(object): 3 # d...
2017-03-20 19:44:00
68
转载 136. Single Number
Given an array of integers, every element appearstwiceexcept for one. Find that single one. Note:Your algorithm should have a linear runtime complexity. Could you implement it without using ex...
2017-03-20 19:38:00
67
转载 125. Valid Palindrome
Given a string, determine if it is a palindrome(回文), considering only alphanumeric(字母数字的) characters and ignoring cases. For example,"A man, a plan, a canal: Panama"is a palindrome."race a car"...
2017-03-20 19:00:00
60
转载 122. Best Time to Buy and Sell Stock II
Say you have an array for which theithelement is the price of a given stock on dayi. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy...
2017-03-18 20:02:00
58
转载 121. Best Time to Buy and Sell Stock
Say you have an array for which theithelement is the price of a given stock on dayi. If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stoc...
2017-03-18 19:43:00
54
转载 119. Pascal's Triangle II
Given an indexk, return thekthrow of the Pascal's triangle. For example, givenk= 3,Return[1,3,3,1]. 自己写的~~ 1 class Solution(object): 2 def getRow(self, rowIndex): 3 "...
2017-03-18 19:05:00
68
转载 118. Pascal's Triangle
GivennumRows, generate the firstnumRowsof Pascal's triangle. For example, givennumRows= 5,Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] 1 class Solution(o...
2017-03-18 17:09:00
61
转载 112. Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example:Given the below binary tree ands...
2017-03-18 16:59:00
52
转载 110. Balanced Binary Tree
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees ofeverynode never di...
2017-03-16 17:25:00
57
转载 108. Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 1 # Definition for a binary tree node. 2 # class TreeNode(object): 3 # def __init_...
2017-03-15 19:03:00
54
转载 107. Binary Tree Level Order Traversal II
Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For example:Given binary tree[3,9,20,null,null,...
2017-03-15 18:57:00
57
转载 111. Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 1 # Definition for a binary...
2017-03-15 18:08:00
50
转载 104. Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 1 # Definition for a binary...
2017-03-15 16:58:00
54
转载 101. Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree[1,2,2,3,4,4,3]is symmetric: 1 / \ 2 2 / \ / \ 3 4...
2017-03-15 16:37:00
40
转载 100. Same Tree
Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. 1 #...
2017-03-15 15:42:00
65
转载 88. Merge Sorted Array
Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array. Note:You may assume thatnums1has enough space (size that is greater or equal tom+n) to hold addi...
2017-03-15 15:22:00
44
转载 83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear onlyonce. For example,Given1->1->2, return1->2.Given1->1->2->3->3, return1->2->3. ...
2017-03-15 14:52:00
56
转载 70. Climbing Stairs
You are climbing a stair case. It takesnsteps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note:Givennwill be a pos...
2017-03-14 19:49:00
40
转载 69. Sqrt(x)
Implementint sqrt(int x). Compute and return the square root ofx. 1 class Solution(object): 2 def mySqrt(self, x): 3 """ 4 :type x: int 5 :rtype: int...
2017-03-14 19:22:00
45
转载 67. Add Binary
Given two binary strings, return their sum (also a binary string). For example,a ="11"b ="1"Return"100". 1 class Solution(object): 2 def addBinary(self, a, b): 3 """ 4 ...
2017-03-14 18:55:00
52
转载 66. Plus One
Given a non-negative integer represented as anon-emptyarray of digits, plus one to the integer. You may assume the integer do not contain any leading zero, except the number 0 itself. The dig...
2017-03-14 15:48:00
51
转载 58. Length of Last Word
Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string. If the last word does not exist, return 0. Note:A word is ...
2017-03-14 15:16:00
42
转载 53. Maximum Subarray
Find the contiguous(连续的) subarray within an array (containing at least one number) which has the largest sum. For example, given the array[-2,1,-3,4,-1,2,1,-5,4],the contiguous subarray[4,-1,2...
2017-03-14 14:52:00
40
转载 38. Count and Say
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ... 1is read off as"one 1"or11.11is read off as"two 1s"or21.21is read off as"one 2,...
2017-03-14 10:57:00
38
转载 35. Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the arr...
2017-03-13 10:55:00
71
转载 28. Implement strStr()
Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 1 class Solution(object): 2 def strStr(self, haystack, nee...
2017-03-13 10:26:00
46
转载 27. Remove Element
Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory. ...
2017-03-13 09:49:00
51
转载 26. Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length. Do not allocate extra space for another array, you must do this in place w...
2017-03-10 10:56:00
50
转载 21. Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 1 # Definition for singly-linked list. 2 # c...
2017-03-10 10:33:00
45
转载 20. Valid Parentheses
Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid. The brackets must close in the correct order,"()"and"()[]{}"are all val...
2017-03-06 13:58:00
43
转载 14. Longest Common Prefix
Write a function to find the longest common prefix(前缀) string amongst an array of strings. 1 class Solution(object): 2 def longestCommonPrefix(self, strs): 3 """ 4 ...
2017-03-02 10:02:00
46
转载 13. Roman to Integer
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 1 int romanToInt(char* s) { 2 int map[26] = {0}; 3 map['I'-'A'] = 1; ...
2017-02-28 21:48:00
39
转载 9. Palindrome Number
Determine whether an integer is a palindrome(回文). Do this without extra space. 1 bool isPalindrome(int x) { 2 if(x<0) return false; 3 4 int x1 = x; 5 int mirror = ...
2017-02-28 19:40:00
47
转载 7. Reverse Integer
Reverse digits of an integer. Example1:x = 123, return 321Example2:x = -123, return -321 Note:The input is assumed to be a 32-bit signed integer. Your function shouldreturn 0 when the revers...
2017-02-27 20:41:00
54
转载 1. Two Sum
Given an array of integers, returnindicesof the two numbers such that they add up to a specific target. You may assume that each input would haveexactlyone solution, and you may not use the...
2017-02-27 19:33:00
49
转载 Java入门
这一周简单学习了一下Java语言,汇总如下: 【输入】Scanner in = new Scanner(System.in); 【输出】System.out.printLn(in.nextline()); 【常量】final int amount = 10; 【判断两个浮点数】由于浮点数有精度问题,不能直接判断两个浮点数是否相等:abs(a-b)<le-6,如果满足这个条件...
2016-07-27 10:15:00
45
转载 安卓APP开发遇到的问题
应项目要求开始学习Java,目标是开发一个APP,其可调用蓝牙,周期搜索周围蓝牙的rssi并上传。 一开始学习遇到了许多问题,在这里总结一下: call requires api level 18 右键点击项目->Androidtools->ClearLinkMarkers.即可临时解决,但是如果调试用的模拟器是低版本的,则在调试完后还有这个错误。 ...
2016-07-26 09:40:00
175
转载 7月份学习C语言
7月份又看了视频学了学C语言: sizeof()为静态运算符,()中不会执行运算; 二进制负数:正数 = 原码, 负数 = 反码+1; %o 输出八进制,%x输出十六进制,%e输出科学计数法,%p输出指针; 短路:不要把赋值,包括复合赋值组合放进表达式; int *const q = &i; 指针是const,一旦得到了某个变量的地址,不能再指向其他变量; int c...
2016-07-18 11:14:00
82
转载 收取rssi
做的最顺利的。。。。找到语句。。一加就好使。。感天动地啊。。。。 在主节点上通知从节点要收他的RSSI啦: 1 if ( !simpleBLERssi ) 2 { 3 simpleBLERssi = TRUE; 4 GAPCentralRole_StartRssi( simpleBLEConnHandle[c...
2016-05-17 20:52:00
104
转载 该死的串口问题。。
蓝牙的串口出问题了,只能发不能收,本宝宝也不知道哪里出了原因。。每次改一丢丢,下到板子里发现不能用。。也不知道为什么。。傻不拉几的看程序,找问题。。看了快一周。。后来实验室的同学用万用表!!测出来是硬件的问题。。万用表在宝宝这里就是做实验才会想到的东西。。最后发现,原来是因为串口模块需要3.3伏的电,而供给电压是5伏的,所以不好使!!!我的天哪。。宝宝傻不拉几的看程序啊!!再怎么看也找不...
2016-05-17 10:53:00
54
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人