随笔分类 - leetcode
摘要:1.问题描述 Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. ...
阅读全文
摘要:1.题目描述 Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which g...
阅读全文
摘要:1.题目描述 Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the...
阅读全文
摘要:1.题目分析 Given a linked list, remove the nth node from the end of list and return its head. For example, ...
阅读全文
摘要:1.题目分析 Write a function to find the longest common prefix string amongst an array of strings. 2.解法分析 最近的几个leetcod...
阅读全文
摘要:1.题目描述 Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If yo...
阅读全文
摘要:1.题目描述 Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could ...
阅读全文
摘要:1.题目描述 Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 ...
阅读全文
摘要:1.题目描述Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.2.解法分析拿到题目的一瞬间,我就想到了两个办法,但都看起来不是那么好的方法,方法一是求出输入串和输入串逆置串(就是将输入串逆序)的最长公共字串,这个算法很容易实现,但是时间复杂度过高,还有一种就是后缀数组的方法,求出最长后缀即可,但是这种
阅读全文
摘要:1.题目描述 You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes c...
阅读全文
摘要:1.题目描述 Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repe...
阅读全文
摘要:1.题目描述 There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity sh...
阅读全文
摘要:1.题目描述 Given an array of integers, find two numbers such that they add up to a specific target number. The functi...
阅读全文
摘要:1.题目描述 Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Give...
阅读全文
摘要:1.题目描述 Given a string containing only digits, restore it by returning all possible valid IP address combinations. ...
阅读全文
摘要:1.题目描述 Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example, ...
阅读全文
摘要:1.题目描述 Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example, Gi...
阅读全文
摘要:昨天临近要睡觉的时候做了一个leetcode题目,“Recover BST”,算法很容易就想到了,直接找出两个异常点就好了,但是我写的算法是用栈实现的非递归遍历,空间复杂度是O(N),虽然比递归的要好点,但是题目说明里面那句“如果能用constant space ”却让我百思不得其解。难道我的解法不是最精简的? 我的解法说白了就是个preorder traversal,难道有可以不用traver...
阅读全文
摘要:1.题目描述 Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its s...
阅读全文
摘要:1.题目描述 Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follo...
阅读全文

浙公网安备 33010602011771号