随笔分类 - Leetcode
The description of question
摘要:原始教程来源: 链接 代码 class Solution: def sort_heap(self,nums): # 对heap进行排序 self.build_heap(nums) for i in range(len(nums)-1,-1,-1): # i 和 头 互换,此时头是最大 nums[i]
阅读全文
摘要:数组类型 编号 名称 链接 思路 3 无重复字符的最长子串 点击 橡皮筋,左端的情况会影响到最右端的位置,如果左端进步,右端的长度可能继续拉长。右端开始为-1位 5 最长回文子串 点击 最外面俩数是一样得,如果里面是回文,那么外面一定也是回文,动态规划 链表 编号 名称 链接 思路 328 奇数偶数
阅读全文
摘要:原题链接 https://leetcode-cn.com/problems/word-search-ii/ 原题描述 给定一个 m x n 二维字符网格 board 和一个单词(字符串)列表 words,找出所有同时在二维网格和字典中出现的单词。 单词必须按照字母顺序,通过 相邻的单元格 内的字母构
阅读全文
摘要:问题描述 Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2
阅读全文
摘要:题目描述 Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains
阅读全文
摘要:题目描述 Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return
阅读全文
摘要:题目描述 Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: Example 2: 参考答案 答案分析 分成三部分: 1. 链接首尾 2. 移动 3. 拆
阅读全文
摘要:题目描述 Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Exa
阅读全文
摘要:题目描述 Reverse a singly linked list. Example: 参考答案 补充说明 term 1: temp = 2 3 4 5 null head = 1 null = 1 2 3 4 5 null + null cur = 1 null head = 2 3 4 5 nu
阅读全文
摘要:题目描述 Given a linked list, return the node where the cycle begins. If there is no cycle, return null. To represent a cycle in the given linked list, we
阅读全文
摘要:题目描述 Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The an
阅读全文
摘要:题目描述 144. Binary Tree Preorder Traversal 94. Binary Tree Inorder Traversal 145. Binary Tree Postorder Traversal 前序排列 :根-左-右 中序排列: 左-根-右 后序排列:左-右-根 参考答
阅读全文
摘要:题目描述 Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings. You need
阅读全文
摘要:题目介绍 Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would ha
阅读全文
摘要:问题描述 Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive i
阅读全文
摘要:题目描述 Given two arrays, write a function to compute their intersection. Example 1: Example 2: Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] Output: [9,4]
阅读全文
摘要:问题描述 Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets
阅读全文
摘要:问题描述 Given a binary tree, return the inorder traversal of its nodes' values. (左 - 根 - 右) Example: Follow up: Recursive solution is trivial, could you
阅读全文
摘要:问题描述 You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should cho
阅读全文
摘要:题目 Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in b
阅读全文

浙公网安备 33010602011771号