随笔分类 - LeetCode
摘要:原题描述Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see bel
阅读全文
摘要:原题描述You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes co
阅读全文
摘要:题目描述 Note: This is an extension of House Robber. After robbing those houses on that street, the thief has found himself a new place for his thievery s
阅读全文
摘要:题目描述You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stoppin
阅读全文
摘要:题目描述Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeat
阅读全文
摘要:原题 Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level a
阅读全文
摘要:原题 Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree
阅读全文
摘要:原题 求二叉树的最大路径和 Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to
阅读全文
摘要:原题 Given a binary tree, flatten it to a linked list in-place. For example,Given The flattened tree should look like: Hints: If you notice carefully in
阅读全文
摘要:原题 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 neares
阅读全文
摘要:原题 Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains o
阅读全文
摘要:原题 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
阅读全文
摘要:原题 Description: Count the number of prime numbers less than a non-negative number, n. 求小于n(非负数)的所有质数(素数)。 思路 埃拉托色尼筛选法——用于求一定范围内的质数(效率高,推荐) 详戳这里百度or维基
阅读全文
摘要:原题 Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 click to show spoilers. Have you thought about this? Her
阅读全文
摘要:原题 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
阅读全文
摘要:原题 Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: begin to
阅读全文
摘要:原题 Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. For example, given n =
阅读全文
摘要:原题 You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you
阅读全文
摘要:原题 Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the h
阅读全文
摘要:原题 A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. T
阅读全文