摘要:
Question 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。 Solution 首先先序遍历的第一个数字是 阅读全文
摘要:
1. Question 求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。 2. Solution 1. 利用构造函数求解 可以用构造函数求解,每次创建一个对象的时候都会去调用一次构造函数,那么我们就把静态变 阅读全文
摘要:
Question 给定一个数组和滑动窗口的大小,找出所有滑动窗口里数值的最大值。例如,如果输入数组{2,3,4,2,6,2,5,1}及滑动窗口的大小3,那么一共存在6个滑动窗口,他们的最大值分别为{4,4,6,6,6,5}; 针对数组{2,3,4,2,6,2,5,1}的滑动窗口有以下6个: {[2, 阅读全文
摘要:
背景 来看一道leetcode题目: Implement strStr(). Returns the index of the first occurrence of needle in haystack, or 1 if needle is not part of haystack. 让我们找到第 阅读全文
摘要:
Question Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. Solution 这道题用穷举法求解,时间复杂度为O(n^2)。但是要注意几个细节 阅读全文
摘要:
Question Given a binary tree containing digits from0 9only, each root to leaf path could represent a number. An example is the root to leaf path1 2 3w 阅读全文
摘要:
Question Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally id 阅读全文
摘要:
Question Given a binary tree, determine if it is height balanced. For this problem, a height balanced binary tree is defined as a binary tree in which 阅读全文
摘要:
Question Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a 阅读全文
摘要:
Question Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. F 阅读全文