hard-leetcode leetcode hard 25

LeetCode —— 二分查找

33. 搜索旋转排序数组 翻转点在前半部分 nums[mid]<=nums[low] 而后半部分是单调递增的,比较好判断。可以判断 nums[mid] < target <= nums[high] 去后半部分 else 去后半部分 翻转点在后半部分 nums[mid]<=nums[low] 而前半部 ......
LeetCode

LeetCode 周赛上分之旅 #40 结合特征压缩的数位 DP 问题

> ⭐️ **本文已收录到 AndroidFamily,技术和职场问题,请关注公众号 \[彭旭锐] 和 [BaguTree Pro](https://www.mdnice.com/writing/85b28c4e60354865a423728e668fc570) 知识星球提问。** > > 学习数据 ......
数位 LeetCode 特征 之旅 问题

《Lua程序设计第四版》 第三部分22~25章自做练习题答案

Lua程序设计第四版第三部分编程实操自做练习题答案,带:star:为重点。 ## 22.1 > 本章开始时定义的函数getfield,由于可以接收像math?sin或string!!!gsub这样的字段而不够严谨。请将其进行重写,使得该函数只能支持点作为名称分隔符。 ```lua function ......
练习题 程序设计 答案 部分 程序

LeetCode -- 第 359 场周赛

本题我们只需要将所有首字母取出来,并与s比较即可。 class Solution { public: bool isAcronym(vector<string>& words, string s) { string res; for(auto &it: words) { res += it[0]; ......
LeetCode 359

IDEA 刷题工具 leetcode editor

突然有一天不好用了,然后抓取新的 cookie 后也登陆不上 https://github.com/shuzijun/leetcode-editor/issues/402 ![](https://img2023.cnblogs.com/blog/2171496/202308/2171496-2023 ......
leetcode 工具 editor IDEA

3.你所不知道的go语言控制语句——Leetcode习题69

[TOC] # 本篇前瞻 好的,现在你已经来到一个新的小结,在这里你将学习到go语言的重要内容,习得go 25个关键字中的12个:var, const, if, else, switch, case, default, fallthrough, for, break, goto, continue, ......
习题 语句 Leetcode 语言

LeetCode

# 字符串 #### 左旋转字符串 [剑指 Offer 58 - II. 左旋转字符串](https://leetcode.cn/problems/zuo-xuan-zhuan-zi-fu-chuan-lcof/description/?envType=study-plan-v2&envId=cod ......
LeetCode

leetcode: TC of top-down memorization

example to explain how to calculate Time Complexity the memo size means each state will be calculated only once how about the TC in each state? class ......
memorization leetcode top-down down top

CSP模拟25

> 炒币、凑数、同构、最近公共祖先 ## A. 炒币 举个栗子,对于序列 $$1,4,5$$ 在 $1$ 处买进,在 $5$ 处卖出是最优的选择。 为什么不选择在 $4$ 处买,因为 $4$ 处成本更高,所以我们可以把一段递增或递减的序列缩成几个互不相同的点。 例如 $$1,3,5,3,2,7$$ ......
CSP

【leetcode】剑指-68.1 二叉搜索树的最近公共祖先

## 思路 首先保证传入的p.valroot.val`: goto right tree ## 代码 第一版,递归法 ``` class Solution { public: TreeNode* get_ancestor(TreeNode* root, TreeNode* p, TreeNode* ......
祖先 leetcode 68.1 68

【25.0】路飞支付相关

# 【一】订单相关表设计 - Order 订单表 - OrderDetail 订单详情表 ```python from django.db import models from luffyCity.apps.course.models import Course from luffyCity.app ......
25.0 25

leetcode2235 两整数相加

题目描述:(这第一种方法我就不多说了,肯定是有手就行) 给你两个整数 num1 和 num2,返回这两个整数的和。 示例 1: 输入:num1 = 12, num2 = 5 输出:17 解释:num1 是 12,num2 是 5 ,它们的和是 12 + 5 = 17 ,因此返回 17 。 示例 2: ......
整数 leetcode 2235

Leetcode 146 LRUCache

```c /* * * Copyright (C) 2023-08-18 13:51 zxinlog * */ #include #define N 1000 // 普通Node typedef struct Node { int key; int value; struct Node *prev; ......
Leetcode LRUCache 146

【LeetCode1384. 按年度列出销售总额】MySQL使用with recursive根据开始日期和结束日期展开为多行

# 题目地址 https://leetcode.cn/problems/total-sales-amount-by-year/description/ # 代码 ``` WITH RECURSIVE DateSeries AS ( SELECT product_id, period_start AS ......
日期 总额 recursive LeetCode 年度

【LeetCode2199. 找到每篇文章的主题】字符串处理题,使用MySQL里的group_concat和LOCATE函数完成

# 题目地址 https://leetcode.cn/problems/finding-the-topic-of-each-post/description/ # 代码 ``` with t1 as( select p.*, k.* from Posts p left join Keywords k ......

Leetcode 142. 环形链表II(Linked list cycle ii)

[题目链接](https://leetcode.cn/problems/linked-list-cycle-ii) 给定一个链表的头节点head, 返回链表开始入环的第一个节点。. 如果链表无环, 则返回 null. 如果链表中有某个节点, 可以通过连续跟踪next指针再次到达, 则链表中存在环. ......
环形 Leetcode Linked cycle list

【LeetCode2118. 建立方程】 group_concat指定分隔符,指定排序顺序

[TOC] # 题目地址 https://leetcode.cn/problems/build-the-equation/description/ # 题目描述 ``` Example 2: 输入: Terms 表: + + + | power | factor | + + + | 4 | -4 | ......

【LeetCode1225. 报告系统状态的连续日期】MySQL使用lag,lead得到连续段的:开始标志,结束标志,分组号,长度

[TOC] # 题目地址 https://leetcode.cn/problems/report-contiguous-dates/description/ # 题目描述 A system is running one task every day. Every task is independen ......
标志 长度 LeetCode 状态 日期

【LeetCode173. 最多连胜的次数】MySQL用户变量编程解法

[TOC] # 题目地址 https://leetcode.cn/problems/longest-winning-streak/description/ # 题目描述 选手的 连胜数 是指连续获胜的次数,且没有被平局或输球中断。 编写解决方案来计算每个参赛选手最多的连胜数。 结果可以以 任何顺序 ......
解法 变量 LeetCode 次数 用户

【LeetCode1454. 活跃用户】MySQL 用户自定义变量,面向过程编程解决"连续天数"的问题

[TOC] # 题目地址 https://leetcode.cn/problems/active-users/description/ # 题目描述 活跃用户 是指那些至少连续 5 天登录账户的用户。 编写解决方案, 找到 活跃用户 的 id 和 name。 返回的结果表按照 id 排序 。 # 代 ......
用户 天数 quot 变量 LeetCode

leetcode刷题日记

unordered_set散列哈希表:[C++ STL unordered_set容器完全攻略 (biancheng.net)](http://c.biancheng.net/view/7250.html) unordered_map:[详细介绍C++STL:unordered_map - 朤尧 - ......
leetcode 日记

Leetcode 160. 链表相交(Intersection of two linked lists lcci)

[题目链接](https://leetcode.cn/problems/intersection-of-two-linked-lists-lcci/description) 给定两个单链表的头节点headA和headB, 请找出并返回两个单链表相交的起始节点. 如果两个链表没有交点, 返回null. ......
Intersection Leetcode linked lists lcci

Leetcode 1388. 3n 块披萨

(本文只提供了解题思路的思考,[原文作者题解连接](https://leetcode.cn/problems/pizza-with-3n-slices/solutions/527304/dpjie-fa-yu-da-jia-jie-she-2-de-chai-bie-ihso/)) 先把题目粘贴在这 ......
Leetcode 1388 3n

leetcode1372dp求交错路径长

bfd+dp unordered_map<TreeNode* ,int>d,p; queue<pair<TreeNode* ,TreeNode*>>q; int dp(TreeNode* root){ d[root]=p[root]=0; q.push({root,nullptr}); while( ......
路径 leetcode 1372 dp

TFIDF改进版:BM25算法介绍及Lucene的实现

# 优化TF ## TF衰减 > 思考一个问题:一篇文档,里面有提到200次RedCap,一定是2倍相关于另一篇提到100次RedCap吗? $TF$对匹配度的贡献应该是有所衰减的。如何控制衰减曲线的陡峭程度?构造$TF$衰减的匹配度函数的一个trick是引入参数$k$: $$ {TF}^\prim ......
算法 Lucene TFIDF BM 25

[LeetCode][70]climbing-stairs

# Content You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can ......
climbing-stairs LeetCode climbing stairs 70

[LeetCode][53]maximum-subarray

# Content Given an integer array nums, find the subarray with the largest sum, and return its sum. Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Ou ......

[LeetCode][55]jump-game

# Content You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your ......
jump-game LeetCode jump game 55

[LeetCode][62]unique-paths

# Content There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the ......
unique-paths LeetCode unique paths 62

[LeetCode][42]trapping-rain-water

# Content Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raini ......