• LeetCode题解——Longest Palindromic Substring

    时间:2023-11-25 12:20:41

    题目:给定一个字符串S,返回S中最长的回文子串。S最长为1000,且最长回文子串是唯一。解法:①遍历,对于每个字符,计算以它为中心的回文子串长度(长度为奇数),同时计算以它和右边相邻字符为中心的回文子串长度(长度为偶数)。时间为O(N2)。②另外,有一个很奇妙的算法,称为Manacher算法,参考 ...

  • 【题解】【排列组合】【素数】【Leetcode】Unique Paths

    时间:2023-11-24 19:51:31

    A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any po...

  • C++版 - 剑指offer 面试题16:反转链表(Leetcode 206: Reverse Linked List) 题解

    时间:2023-11-22 12:27:32

    面试题16:反转链表提交网址: http://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca?tpId=13&tqId=11168或 https://leetcode.com/problems/reverse-linked...

  • LeetCode Database题解

    时间:2023-11-15 17:14:36

    175. Combine Two Tables使用外连接即可。# Write your MySQL query statement belowselect FirstName, LastName, City, State from Person left outer join Address on ...

  • LeetCode题解——Reverse Integer

    时间:2023-11-11 14:35:46

    题目:数字翻转,即输入123,返回321;输入-123,返回-321。代码: class Solution { public: int reverse(int x) { int result = , sign = ; if(x < ) //负数...

  • LeetCode题解之Binary Tree Tilt

    时间:2023-11-11 08:21:32

    1、题目描述2、分析利用递归实现。3、代码 int findTilt(TreeNode* root) { if (root == NULL) return ; int ans = ; nodesTilt(root,ans); ...

  • LeetCode题解之Binary Tree Level Order Traversal II

    时间:2023-11-11 08:19:43

    1、题目描述2、题目分析先遍历,再反转。3、代码 vector<vector<int>> levelOrderBottom(TreeNode* root) { vector<vector<int>> ans; if (r...

  • LeetCode题解之Binary Tree Paths

    时间:2023-11-11 08:14:55

    1、题目描述2、分析使用递归。3、代码 vector<string> ans; vector<string> binaryTreePaths(TreeNode* root) { if (root == NULL) return ans; ...

  • leetcode题解:Construct Binary Tree from Preorder and Inorder Traversal (根据前序和中序遍历构造二叉树)

    时间:2023-11-11 08:13:02

    题目:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.说明:1)二叉树可空2)...

  • leetcode 题解:Binary Tree Inorder Traversal (二叉树的中序遍历)

    时间:2023-11-11 08:10:25

    题目:Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,...

  • LeetCode题解之Binary Tree Right Side View

    时间:2023-11-11 08:04:56

    1、题目描述2、问题分析使用层序遍历3、代码 vector<int> v; vector<int> rightSideView(TreeNode* root) { if (root == NULL) return v; ...

  • [LeetCode]题解(python):140-Word Break II

    时间:2023-08-30 18:26:26

    题目来源:https://leetcode.com/problems/word-break-ii/题意分析:给定一个字符串s和一个字典dict(set),将所有将s有字典dict组成的结果输出。比如s = "catsanddog",dict = ["cat", "cats", "and", "san...

  • leetcode 题解: Length of Last Word

    时间:2023-08-11 14:33:38

    leetcode:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the l...

  • LeetCode题解之Squares of a Sorted Array

    时间:2023-08-09 12:35:44

    1、题目描述2、问题分析使用过两个计数器。3、代码 class Solution { public: vector<int> sortedSquares(vector<int>& A) { int left = , right = A.size(...

  • C#版 - Leetcode 65. 有效数字 - 题解

    时间:2023-07-11 19:53:26

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm。Leetcode 65. 有效数字Leetcode 65. Valid Number在线提交: Leetcode ...

  • [LeetCode]题解(python):143-Reorder List

    时间:2023-04-20 17:21:02

    题目来源:https://leetcode.com/problems/reorder-list/题意分析:给定一个链表L:L0→L1→…→Ln-1→Ln,改变链表的排序为: L0→Ln→L1→Ln-1→L2→Ln-2→…,要求时间复杂度为O(n),不能改变节点的值。题目思路:题目思路是把链表拆成两个...

  • 《LeetBook》leetcode题解(6): ZigZag Conversion[E]

    时间:2023-04-01 00:00:32

    我现在在做一个叫《leetbook》的免费开源书项目,力求提供最易懂的中文思路,目前把解题思路都同步更新到gitbook上了,需要的同学可以去看看 书的地址:https://hk029.gitbooks.io/leetbook/006.ZigZag Conversion[E]题目The stri...

  • 《LeetBook》leetcode题解(8): String to Integer (atoi) [E]——正负号处理

    时间:2023-03-19 11:36:20

    我现在在做一个叫《leetbook》的免费开源书项目,力求提供最易懂的中文思路,目前把解题思路都同步更新到gitbook上了,需要的同学可以去看看 书的地址:https://hk029.gitbooks.io/leetbook/008. String to Integer (atoi) [E]题...

  • [LeetCode]题解(python):047-Permutations II

    时间:2023-03-17 09:35:38

    题目来源https://leetcode.com/problems/permutations-ii/Given a collection of numbers that might contain duplicates, return all possible unique permutations...

  • [LeetCode]题解(python):120 Triangle

    时间:2023-02-25 23:25:32

    题目来源https://leetcode.com/problems/triangle/Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers ...