随笔分类 -  leetcode

上一页 1 ··· 4 5 6 7 8
摘要:仅供自己学习 题目: Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to 阅读全文
posted @ 2021-02-04 22:11 Mrsdwang 阅读(36) 评论(0) 推荐(0)
摘要:仅供自己学习 题目: Invert a binary tree. Example: Input: 4 / \ 2 7 / \ / \1 3 6 9Output: 4 / \ 7 2 / \ / \9 6 3 1 思路: 这就是直接交换数据就可以了,可以前序遍历,后序遍历,中序遍历的交换 代码: 前序 阅读全文
posted @ 2021-02-03 12:03 Mrsdwang 阅读(46) 评论(0) 推荐(0)
摘要:仅供自己学习 题目: Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. You may return the answer in any order. Example 1 阅读全文
posted @ 2021-02-03 11:07 Mrsdwang 阅读(57) 评论(0) 推荐(0)
摘要:仅供自己学习 题目: Given a string s, return the longest palindromic substring in s. 思路: 1.暴力求解,每个元素都遍历一遍,获得的每个子串都逆向遍历一边比较是否相等,RT为O(n^3) 2.中心扩展法。每个元素从两侧扩展,如果左右 阅读全文
posted @ 2021-01-25 16:41 Mrsdwang 阅读(67) 评论(0) 推荐(0)
摘要:仅供自己学习 题目: Given an unsorted array of integers nums, return the length of the longest continuous increasing subsequence (i.e. subarray). The subsequen 阅读全文
posted @ 2021-01-24 11:56 Mrsdwang 阅读(66) 评论(0) 推荐(0)
摘要:仅供自己学习,有借鉴成分。 题目: Given a string s, find the length of the longest substring without repeating characters. 思路: 1.下意识想到暴力是可以求解的,把所有无重复字母子串记录下来再来比较。但从每个 阅读全文
posted @ 2021-01-23 22:57 Mrsdwang 阅读(56) 评论(0) 推荐(0)
摘要:仅供自己学习 题目: 给你两个 非空 的链表,表示两个非负的整数。它们每位数字都是按照 逆序 的方式存储的,并且每个节点只能存储 一位 数字。 请你将两个数相加,并以相同形式返回一个表示和的链表。 你可以假设除了数字 0 之外,这两个数都不会以 0 开头。 思路: 这道题把题目弄清楚思路就会比较清晰 阅读全文
posted @ 2021-01-23 11:40 Mrsdwang 阅读(72) 评论(0) 推荐(0)
摘要:仅供自己学习,有借鉴。 题目: 给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 的那 两个 整数,并返回它们的数组下标。 思路: 1.第一想法两个嵌套for循环暴力求解,时间复杂度为O(n^2) 2.考虑到唯一问题是如何快速查找到对应的数之和为target 阅读全文
posted @ 2021-01-23 10:09 Mrsdwang 阅读(60) 评论(0) 推荐(0)

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