leetcode记录
l_ling00
这个作者很懒,什么都没留下…
展开
-
[leetcode]283. Move Zeroes[facebook]
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], after calling you原创 2017-12-11 05:12:55 · 136 阅读 · 0 评论 -
[leetcode]88. Merge Sorted Array[facebook](10)
Reverse a singly linked list.Hint:A linked list can be reversed either iteratively or recursively. Could you implement both?我的做法:我不会链表at all,so to save time,直接看的答案。solution:先说iterative原创 2017-12-14 09:03:29 · 196 阅读 · 0 评论 -
[leetcode]88. Merge Sorted Array[facebook](9)
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold addit原创 2017-12-11 12:55:25 · 164 阅读 · 0 评论 -
[leetcode]125. Valid Palindrome[facebook]
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" is not a原创 2017-12-11 12:54:04 · 154 阅读 · 0 评论 -
[leetcode]543. Diameter of Binary Tree[facebook]
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may n原创 2017-12-11 12:07:37 · 135 阅读 · 0 评论 -
[leetcode]257. Binary Tree Paths[facebook](todo)
Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]我的做原创 2017-12-11 11:37:33 · 134 阅读 · 0 评论 -
[leetcode]121. Best Time to Buy and Sell Stock[facebook]
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), d原创 2017-12-11 11:09:51 · 126 阅读 · 0 评论 -
[leetcode]1. Two Sum[facebook]
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 sam原创 2017-12-11 09:40:22 · 182 阅读 · 0 评论 -
[leetcode]278. First Bad Version[facebook]
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the原创 2017-12-11 09:12:35 · 221 阅读 · 0 评论 -
[leetcode]67. Add Binary[facebook]
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".我的做法:先把两个字符都转换成数字,然后把数字加起来,然后再转换回二进制缺点:慢改进:利用了py原创 2017-12-11 05:50:58 · 229 阅读 · 0 评论 -
[leetcode] 13. Roman to Integer[facebook](11)
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.我的做法:首先要知道罗马数字表示法:I(代表1)、V(代表5)、X(代表10)、L(代表50)、C代表100)、D(代表500)、M(代表1,000)原创 2017-12-14 09:21:35 · 143 阅读 · 0 评论