上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 26 下一页
摘要: Question 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。 Solution 首先先序遍历的第一个数字是 阅读全文
posted @ 2017-06-29 19:59 清水汪汪 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 1. Question 求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。 2. Solution 1. 利用构造函数求解 可以用构造函数求解,每次创建一个对象的时候都会去调用一次构造函数,那么我们就把静态变 阅读全文
posted @ 2017-06-28 17:19 清水汪汪 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 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, 阅读全文
posted @ 2017-06-28 14:47 清水汪汪 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 背景 来看一道leetcode题目: Implement strStr(). Returns the index of the first occurrence of needle in haystack, or 1 if needle is not part of haystack. 让我们找到第 阅读全文
posted @ 2017-06-28 10:50 清水汪汪 阅读(530) 评论(0) 推荐(0) 编辑
摘要: 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)。但是要注意几个细节 阅读全文
posted @ 2017-06-27 22:35 清水汪汪 阅读(495) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2017-06-26 17:32 清水汪汪 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2017-06-26 16:42 清水汪汪 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2017-06-26 16:30 清水汪汪 阅读(176) 评论(0) 推荐(0) 编辑
摘要: Question Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a 阅读全文
posted @ 2017-06-26 15:26 清水汪汪 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2017-06-26 15:11 清水汪汪 阅读(121) 评论(0) 推荐(0) 编辑
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 26 下一页