随笔分类 -  leetCode题解记录

上一页 1 ··· 3 4 5 6 7 8 下一页
摘要:1、题目描述 2、分析 使用一个map将字母和数字对应起来,方便后续使用。 3、代码 阅读全文
posted @ 2018-04-24 13:06 山里的小勇子 阅读(339) 评论(0) 推荐(0)
摘要:1、题目描述 2、分析 按照题目要求,主要就是对数组进行排序 3、代码 阅读全文
posted @ 2018-04-24 11:19 山里的小勇子 阅读(171) 评论(0) 推荐(0)
摘要:1、题目描述 2、题目分析 简单题目,只要挨个判断该数是不是满足条件即可。 3、代码 阅读全文
posted @ 2018-04-24 10:45 山里的小勇子 阅读(175) 评论(0) 推荐(0)
摘要:1、题目描述 2、分析 之前使用的大循环再向两边寻找的算法是 O(n^2)复杂度的,可以利用 multimap降低其复杂度。 3、代码 阅读全文
posted @ 2018-04-24 10:28 山里的小勇子 阅读(442) 评论(0) 推荐(0)
摘要:1、题目描述 2、分析 最简单的方案,对每一个字符,向两边寻找。 3、代码 阅读全文
posted @ 2018-04-24 09:27 山里的小勇子 阅读(242) 评论(0) 推荐(0)
摘要:1、题目描述 2、使用栈实现难度大于使用递归实现 3、代码 阅读全文
posted @ 2018-04-14 17:52 山里的小勇子 阅读(495) 评论(0) 推荐(0)
摘要:1、题目描述 2、分析 对于树来说,由于其结构是递归定义的,所以对二叉树很多算法使用递归是最容易的。反倒是使用循环方式需要借助特殊的数据结构来实现。 3、代码 阅读全文
posted @ 2018-04-14 17:30 山里的小勇子 阅读(235) 评论(0) 推荐(0)
摘要:1、题目描述 2、题目分析 二叉树的层序遍历主要算法思想是使用 队列这一数据结构实现,这个数据结构多应用在和 图相关的算法。例如图的广度优先遍历就可以使用队列的方法实现。本题的关键在于如何识别出一层已经打印完毕。解决思路是在每一层结束时加入一个特殊字符如NULL. 访问到 NULL 时 就知道一层访 阅读全文
posted @ 2018-04-12 21:16 山里的小勇子 阅读(211) 评论(0) 推荐(0)
摘要:1、题目描述 Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurall 阅读全文
posted @ 2018-04-08 18:47 山里的小勇子 阅读(194) 评论(0) 推荐(0)
摘要:1、题目描述 Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements. 阅读全文
posted @ 2018-04-08 13:25 山里的小勇子 阅读(195) 评论(0) 推荐(0)
摘要:1、题目描述 A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetc 阅读全文
posted @ 2018-04-03 20:13 山里的小勇子 阅读(430) 评论(0) 推荐(0)
摘要:1、题目描述 经典的反转二叉树,就是将二叉树中每个节点的左、右儿子交换。 2、题目分析 3、代码 阅读全文
posted @ 2018-04-01 15:26 山里的小勇子 阅读(173) 评论(0) 推荐(0)
摘要:1、题目描述 Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. 计算二叉树每一层的节点的数据域的平均值。 2、题目分析 使用广度优先遍 阅读全文
posted @ 2018-04-01 15:10 山里的小勇子 阅读(1122) 评论(0) 推荐(0)
摘要:1、题目描述 Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). Yo 阅读全文
posted @ 2018-04-01 14:27 山里的小勇子 阅读(419) 评论(0) 推荐(0)
摘要:1、问题描述 Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime c 阅读全文
posted @ 2018-03-29 17:06 山里的小勇子 阅读(532) 评论(0) 推荐(0)
摘要:1、问题描述 Search Insert Position Given a sorted array and a target value, return the index if the target is found. If not, return the index where it woul 阅读全文
posted @ 2018-03-29 15:57 山里的小勇子 阅读(179) 评论(0) 推荐(0)
摘要:1、题目描述 Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the far 阅读全文
posted @ 2018-03-29 14:26 山里的小勇子 阅读(629) 评论(0) 推荐(0)
摘要:1、问题描述 Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a plan, a can 阅读全文
posted @ 2018-03-29 14:09 山里的小勇子 阅读(340) 评论(0) 推荐(0)
摘要:1、问题描述 Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 - 阅读全文
posted @ 2018-03-29 12:53 山里的小勇子 阅读(3604) 评论(0) 推荐(0)
摘要:1、问题描述 Reverse Vowels of a String Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Given s = "hello", 阅读全文
posted @ 2018-03-29 10:37 山里的小勇子 阅读(432) 评论(0) 推荐(0)

上一页 1 ··· 3 4 5 6 7 8 下一页