随笔分类 -  leetcode

摘要:Question Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. Solution 这道题用穷举法求解,时间复杂度为O(n^2)。但是要注意几个细节 阅读全文
posted @ 2017-06-27 22:35 清水汪汪 阅读(495) 评论(0) 推荐(0) 编辑
摘要:Question Given a binary tree containing digits from0 9only, each root to leaf path could represent a number. An example is the root to leaf path1 2 3w 阅读全文
posted @ 2017-06-26 17:32 清水汪汪 阅读(157) 评论(0) 推荐(0) 编辑
摘要:Question 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 id 阅读全文
posted @ 2017-06-26 16:42 清水汪汪 阅读(104) 评论(0) 推荐(0) 编辑
摘要:Question 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 阅读全文
posted @ 2017-06-26 16:30 清水汪汪 阅读(176) 评论(0) 推荐(0) 编辑
摘要:Question Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a 阅读全文
posted @ 2017-06-26 15:26 清水汪汪 阅读(141) 评论(0) 推荐(0) 编辑
摘要:Question Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. F 阅读全文
posted @ 2017-06-26 15:11 清水汪汪 阅读(121) 评论(0) 推荐(0) 编辑
摘要:Question There are N gas stations along a circular route, where the amount of gas at station i isgas[i]. You have a car with an unlimited gas tank and 阅读全文
posted @ 2017-06-26 13:57 清水汪汪 阅读(126) 评论(0) 推荐(0) 编辑
摘要:Question Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? Solution 判断一个链表是否有环,可以采用slow f 阅读全文
posted @ 2017-06-25 16:10 清水汪汪 阅读(152) 评论(0) 推荐(0) 编辑
摘要:Question Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up: Can you solve it without using ext 阅读全文
posted @ 2017-06-25 15:59 清水汪汪 阅读(156) 评论(0) 推荐(0) 编辑
摘要:LeetCode——Insertion Sort List Question Sort a linked list using insertion sort. Solution 我的解法,假设第一个节点都比其他节点小,这样感觉好移动指针一些,所以添加了一个额外的最小的节点。 Code 阅读全文
posted @ 2017-06-25 14:32 清水汪汪 阅读(108) 评论(0) 推荐(0) 编辑
摘要:LeetCode— Sort List Question Sort a linked list in O(n log n) time using constant space complexity. Solution 看到对链表的排序,时间复杂度O(n log n),首先想到的就是归并排序。 但是这 阅读全文
posted @ 2017-06-25 12:29 清水汪汪 阅读(151) 评论(0) 推荐(0) 编辑
摘要:LeetCode——Longest Consecutive Sequence Question Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For 阅读全文
posted @ 2017-06-07 23:59 清水汪汪 阅读(140) 评论(0) 推荐(0) 编辑
摘要:LeetCode——single number系列 Question 1 Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorith 阅读全文
posted @ 2017-06-07 21:53 清水汪汪 阅读(106) 评论(0) 推荐(0) 编辑
摘要:LeetCode——Word Break Question Given a non empty string s and a dictionary wordDict containing a list of non empty words, determine if s can be segment 阅读全文
posted @ 2017-06-07 16:25 清水汪汪 阅读(120) 评论(0) 推荐(0) 编辑
摘要:LeetCode——Move Zeroes Question 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 阅读全文
posted @ 2017-04-03 16:04 清水汪汪 阅读(141) 评论(1) 推荐(1) 编辑
摘要:LeetCode——Construct the Rectangle Question For a web developer, it is very important to know how to design a web page's size. So, given a specific rec 阅读全文
posted @ 2017-04-03 12:02 清水汪汪 阅读(188) 评论(1) 推荐(1) 编辑
摘要:LeetCode——Add Digits Question Given a non negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given 阅读全文
posted @ 2017-04-03 10:16 清水汪汪 阅读(118) 评论(0) 推荐(1) 编辑
摘要:LeetCode—— Invert Binary Tree Question invert a binary tree. Trivia: This problem was inspired by this original tweet by Max Howell: Google: 90% of ou 阅读全文
posted @ 2017-04-03 09:44 清水汪汪 阅读(200) 评论(0) 推荐(1) 编辑
摘要:LeetCode——Sum of Two Integers Question Calculate the sum of two integers a and b, but you are not allowed to use the operator + and . Example: Given a 阅读全文
posted @ 2017-04-03 09:33 清水汪汪 阅读(136) 评论(0) 推荐(1) 编辑
摘要:LeetCode——Find the Difference Question Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling st 阅读全文
posted @ 2017-04-02 12:02 清水汪汪 阅读(180) 评论(0) 推荐(1) 编辑