Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 题目…
分类:LeetCode题目解答汇总
LeetCode | Pascal's Triangle(杨辉三角)
Given numRows, generate the first numRows of Pascal’s triangle. For example, given n…
LeetCode | Sqrt(x)
Implement int sqrt(int x). 题目解析: 求开方根,只是求解整数,比较容易,如果求解double类型的,就要考虑精度问题。 题型一:求整数根 先讲解求解整数根的情况。 题目简单,可以直接…
LeetCode | Interleaving String(交叉字符串)
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and&n…
LeetCode | Validate Binary Search Tree(有效的二叉搜索树)
Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: …
LeetCode | Longest Palindromic Substring(最长回文子串)
题目: Given a string S, find the longest palindromic substring in S. You may assume that the maximum l…
LeetCode | Substring with Concatenation of All Words(链接所有单词的子串)
You are given a string, S, and a list of words, L, that are all of the same length. Find all startin…
LeetCode | Binary Tree Level Order Traversal(二叉树层序遍历)
Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to …
LeetCode | Add Binary(二进制相加)
Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Ret…
LeetCode | Palindrome Partitioning(将一个子串划分成回文子串)
Given a string s, partition s such that every substring of the partition is a palindrome. Retur…
LeetCode | Permutation Sequence(找到全排列中的第k个排列)
The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of …
LeetCode | Insertion Sort List(插入法排序链表)
Sort a linked list using insertion sort. 题目解析: 链表思路不难,但是指针比较麻烦,要细心才行。这道题让我调了半天,原来是一个指针赋错了,因为用的变量p和q,导致很长时间才发现……