随笔分类 - LeetCode
摘要:题目描述:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stoppi...
阅读全文
摘要:题目描述: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:...
阅读全文
摘要:题目描述: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,−...
阅读全文
摘要:题目描述:Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat",...
阅读全文
摘要:题目描述:Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space? 这题思路就是把单链表的前半部分或后半部分反转,然后比较。s...
阅读全文
摘要:题目描述:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipe...
阅读全文
摘要:题目描述: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 s...
阅读全文
摘要:题目描述:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: ...
阅读全文
摘要:题目描述:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum eleme...
阅读全文
摘要:题目描述:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in th...
阅读全文
摘要:题目描述:Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit ...
阅读全文
摘要:题目描述:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive in...
阅读全文
摘要:题目描述:Divide two integers without using multiplication, division and mod operator.If it is overflow, return INT_MAX. 提示中谈到Binary Search,由此可想到解决方案。solu...
阅读全文
摘要:题目描述:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02):T...
阅读全文
摘要:题目描述:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn'...
阅读全文
摘要:题目描述:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space ...
阅读全文
摘要:题目描述:Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen l...
阅读全文
摘要:题目描述:Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.You...
阅读全文
摘要:题目描述:Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity. 因为之前做过Merge Two Sorted Lists,所以这道题也就显得不那么难了。sol...
阅读全文
摘要:题目描述: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. 直接...
阅读全文

浙公网安备 33010602011771号