随笔分类 - leetCode题解记录
摘要:1、题目描述 2、分析 使用一个map将字母和数字对应起来,方便后续使用。 3、代码
阅读全文
摘要:1、题目描述 2、分析 按照题目要求,主要就是对数组进行排序 3、代码
阅读全文
摘要:1、题目描述 2、题目分析 简单题目,只要挨个判断该数是不是满足条件即可。 3、代码
阅读全文
摘要:1、题目描述 2、分析 之前使用的大循环再向两边寻找的算法是 O(n^2)复杂度的,可以利用 multimap降低其复杂度。 3、代码
阅读全文
摘要:1、题目描述 2、分析 最简单的方案,对每一个字符,向两边寻找。 3、代码
阅读全文
摘要:1、题目描述 2、使用栈实现难度大于使用递归实现 3、代码
阅读全文
摘要:1、题目描述 2、分析 对于树来说,由于其结构是递归定义的,所以对二叉树很多算法使用递归是最容易的。反倒是使用循环方式需要借助特殊的数据结构来实现。 3、代码
阅读全文
摘要:1、题目描述 2、题目分析 二叉树的层序遍历主要算法思想是使用 队列这一数据结构实现,这个数据结构多应用在和 图相关的算法。例如图的广度优先遍历就可以使用队列的方法实现。本题的关键在于如何识别出一层已经打印完毕。解决思路是在每一层结束时加入一个特殊字符如NULL. 访问到 NULL 时 就知道一层访
阅读全文
摘要: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
阅读全文
摘要: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.
阅读全文
摘要: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
阅读全文
摘要:1、题目描述 经典的反转二叉树,就是将二叉树中每个节点的左、右儿子交换。 2、题目分析 3、代码
阅读全文
摘要:1、题目描述 Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. 计算二叉树每一层的节点的数据域的平均值。 2、题目分析 使用广度优先遍
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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 -
阅读全文
摘要: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",
阅读全文

浙公网安备 33010602011771号