摘要:
一、若二叉树为搜索二叉树 原题链接:https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/#/description Given a binary search tree (BST), find th 阅读全文
摘要:
Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two n 阅读全文
摘要:
Given an index k, return the k th row of the Pascal's triangle. For example, given k = 3,Return[1,3,3,1]. Note: Could you optimize your algorithm to u 阅读全文
摘要:
Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return 题意:给定行数构建帕斯卡三角。 思路:注意行数和该行中列数的关系,还有每行中非首尾元素时,该元素 阅读全文
摘要:
Divide two integers without using multiplication, division and mod operator. 题意:两数相除不能用乘法、除、取余运算。 思路:直观的想法是相减,使用计算器p记下相减的次数n,这样时间复杂度为O(n)(n代表相减次数)。这是如 阅读全文
摘要:
Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example:Given"25525511135", return["255 阅读全文
摘要:
Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example,[1,1,2]have the following unique per 阅读全文
摘要:
Given a collection of numbers, return all possible permutations. For example,[1,2,3]have the following permutations:[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3 阅读全文