【LeetCode】解题63:Unique Paths II

为YOLOv11引入自适应特征融合模块(ASFF) 本文探讨了在YOLOv11中引入ASFF(自适应空间特征融合)模块以解决多尺度目标检测性能不均衡的问题。作者分析了传统FPN固定融合策略的缺陷,详细介绍了ASFF模块的实现原理,包括动态权重生成网络设计和特征融合机制。通过将ASFF集成到YOLOv11颈部网络,实现了特征在双向流动时的自适应融合,在复杂场景下mAP提升1.2%而推理时间仅增加3-5ms。文章还分享了训练调参技巧和部署注意事项,指出ASFF特别适合交通监控等目标尺度变化大的场景,但强调需根据实际需求平衡模型复杂度与性能。最后提供了工程实践建议 阅读详情

Problem 63: Unique Paths II [Medium]

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 point in time. The robot is trying to reach the bottom-right corner of the grid (marked ‘Finish’ in the diagram below).

Now consider if some obstacles are added to the grids. How many unique paths would there be?


An obstacle and empty space is marked as 1 and 0 respectively in the grid.

Note: m and n will be at most 100.

Example:

Input:
[
[0,0,0],
[0,1,0],
[0,0,0]
]
Output: 2
Explanation:
There is one obstacle in the middle of the 3x3 grid above.
There are two ways to reach the bottom-right corner:

  1. Right -> Right -> Down -> Down
  2. Down -> Down -> Right -> Right

来源:LeetCode

解题思路

动态规划题,解题思路与Problem 62 Unique Paths类似。

状态方程:
s t e p [ i , j ] = ( s t e p [ i , j − 1 ] + s t e p [ i − 1 , j ] ) ∗ ( 1 − o b s t a c l e G r i d [ i , j ] ) step[i, j] = (step[i, j-1] + step[i-1, j])*(1 - obstacleGrid[i, j]) step[i,j]=(step[i,j−1]+step[i−1,j])∗(1−obstacleGrid[i,j])
每一格可以通过左边格/上边格到达,因此到达的方法个数为左边一格的方法个数与上边一格的方法个数之和,如果当前格子有障碍(obstacleGrid[i, j] = 1),则不能到达,方法个数为0。

具体思路:

  • 由上一篇Unique Paths题解可知,实现该状态方程只需要创建一个长度为n的一维数组:step[n]。
  • 初始化:step[0] = 1,step[1~n-1] = 0.
  • 双重循环:
    a. 第一重循环:计算每行首列的值,即step[0]。由于第一列只能由上边一格到达,因此只要上边某格有障碍,下面所有的第一列格子都无法到达,更新公式为:step[0] = step[0] * (1 - obstacleGrid[i, 0])。
    b. 第二重循环:计算每行当前格方法个数公式:step[j] = (step[j-1] + step[j]) * (1 - obstacleGrid[i, j]),当前格有障碍时step[j] = 0。

整个算法时间复杂度为 O ( m ∗ n ) O(m*n) O(m∗n),空间复杂度为 O ( n ) O(n) O(n)。

运行结果:
在这里插入图片描述

Solution (Java)

class Solution {
    public int uniquePathsWithObstacles(int[][] obstacleGrid) {
        int m = obstacleGrid.length;
        int n = obstacleGrid[0].length;
        int[] step = new int[n];
        step[0] = 1;
        for(int i = 0; i < m; i++){
            step[0] *= (1 - obstacleGrid[i][0]);
            for(int j = 1; j < n; j++){
                step[j] += step[j-1];
                step[j] *= (1 - obstacleGrid[i][j]);
            }
        }
        return step[n-1];
    }
}
闲鱼爬虫实战:模拟手机端破解反爬策略,爬取指定商品搜索数据,爬取闲鱼搜索指定商品(需手机端模拟)o 技术点:抓包分析、cookie与token 技术点作用抓取手机 App 请求,分析 API 结构、Header、参数加密情况requestsPython 中最常用的 HTTP 库,用于发送模拟请求Session 对象自动管理 Cookie,保持会话User-Agent & 设备特征模拟手机型号、系统版本,绕过服务端检测闲鱼部分接口存在签名,需要逆向或复用有效 Token多线程/异步提高爬取效率(需节制,避免封 IP)解析 HTML 或 JSON 数据注意:闲鱼的接口加密程度中等偏上,部分接口存在动态签名(如x-signx-mini-wua。 阅读详情

相关推荐

2.数字芯片时序正确的前提—Max-transition

芯片物理设计中最基本的Max-transition检查

weixin_43868998的博客 5418

leetcode——第63题——不同路径V2

题目: 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。 现在考虑网格中有障碍物。那么从左上角到右下角将会有多少条不同的路径? class Solution { // 这道题与上一题的思路基本一样,只不过就是在处理 dp 数组的时候 // 多了一个判断的条件,思路还是五步走,便不再详述 public: int uniquePathsWithObs

linping_的博客 254

【Konva】解决图形加入group后无法获取到绝对坐标,以及group内绘制新图形坐标偏移的问题

解决konva绘图开发时“图形加入group后坐标不会变动,无法获取到绝对坐标”的问题

近10年前端开发工作经验,为你分享日常经验所得 1498

leetcode-63-dp经典算法题笔记

此题和leetcode 62题状态转移方程是一样的,但是迁入了障碍物的概念,如果需要知道状态转移方程的思路,可以参考https://blog.youkuaiyun.com/qq_41936805/article/details/100179828 解出此题,我们必须知道对于障碍物的特点如下: 障碍处的dp值=0 我们已经知道了,动态转移方程为 dp[i][j]=dp[i][j-1]+dp[i-1][j] 接下来就要加入限制条件,如果检测到障碍,就把障碍坐标的dp初始化为0,如果起点dp[0][0]那么dp[1][1]=

0117 361

把“思考”塞进 1 KB:我用纯 C 语言给单片机手搓了一个微型 Transformer 推理引擎

摘要:本文探讨了在64KB SRAM的MCU(如STM32H743)上部署精简Transformer模型的技术方案。通过将6层Transformer压缩至1层(隐藏维度128)、4-bit KV-Cache量化等优化手段,实现了240KB Flash占用和59KB RAM峰值,推理延迟184ms(400MHz Cortex-M7),准确率96.1%。关键创新包括:手工优化矩阵乘(CMSIS-NN)、查表法Softmax/LayerNorm、权重按Tile重排提升Cache命中率(60%→94%)。

qq_74383080的博客 2921

C#实战:如何用HslCommunication快速搞定三菱FX5U PLC通讯(附完整代码)

本文详细介绍了如何利用HslCommunication库在C#环境中快速实现与三菱FX5U PLC的通讯。通过实战代码演示,从环境搭建、建立连接、核心数据读写到构建健壮的监控服务,系统讲解了如何高效完成数据采集与交互,大幅提升工业自动化项目的开发效率。

s4t5u6v的博客 1199

leetcode解题思路分析(九)57-63题

插入区间 给出一个无重叠的 ,按照区间起始端点排序的区间列表。 在列表中插入一个新的区间,你需要确保列表中的区间仍然有序且不重叠(如果有必要的话,可以合并区间)。 本质上和上一题是一个东西,但是因为给出的已经是无重叠并且排好序的,所以最简单的是一次遍历然后按情况插入新区间 class Solution { public: vector<vector<int>> ...

ty的博客 479

MATLAB极坐标伪彩色圆图绘制之polarPcolor函数

polarPcolor函数介绍 我们经常在论文或期刊上看到如下图这种以色调冷暖代表数值大小的极坐标圆图, 而function [varargout] = polarPcolor(R,theta,Z,varargin)可以很好的帮助我们快速绘制这类极坐标圆图。它非常适合雷达或激光雷达的平面位置指示器。使用polarPcolor函数时,我们只需根据手中数据构造相应的二维矩阵Z即可,十分便捷。varargin值为绘制模式选择。R值为半径坐标一维矩阵,theta值为角坐标一维矩阵。 代码示例 这里使用了海洋表面耀光

qq_19512613的博客 1万+

[leetcode][python]63. Unique Paths II

63. Unique Paths II 知识点:dynamic programming 1. 原题 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 ...

qq_40670635的博客 333

从零到一,打造你的无人机侦察兵!树莓派+Python+MQTT,实时目标检测全攻略

物联网、人工智能与计算机视觉三大前沿技术的深度融合。

u013558123的博客 1471

python点云可视化

Python三种点云可视化方案:mayavi、matplotlib、CloudCompare。

叶子的博客 1万+

63. **Unique Paths II

63. **Unique Paths II https://leetcode.com/problems/unique-paths-ii/description/ 题目描述 Follow up for 62. Unique Paths**: Now consider if some obstacles are added to the grids. How many unique paths wou...

珍妮的选择的博客 342

ROSTEA软件下载及情感分析详细操作教程(附网盘链接)

原ROST虚拟团队出品的ROST系列文本内容挖掘分析平台,是辅助人文社会科学研究的免费计算平台。该软件可以实现文本预处理、分字、分词、词性识别、特殊名词抽取、词频统计、英文词频统计、情感计算、分类算法、聚类算法等一系列文本挖掘,是人文社科研究和论文写作的一把利器。该软件用户量超过一万人,遍布海内外100多所大学,包括剑桥大学、日本北海道大学、北京大学、清华大学、香港城市大学、澳门大学等众多高校。关于ROSTCM6的安装介绍可以参考之前的文章ROSTCM6软件下载及语义网络分析详细操作教程ROST EA。

m0_64336780的博客 1万+

LeetCode 63. Unique Paths II(动态规划)

题目来源:https://leetcode.com/problems/unique-paths-ii/ 问题描述 63.Unique Paths II Medium A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below). The robot can ...

da_kao_la的博客 520

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

LeetCode刷题:62. Unique Paths 和 63. Unique Paths II

LeetCode刷题:62. Unique Paths Unique Paths 原题链接:https://leetcode.com/problems/unique-paths/description/ Unique Paths II 原题链接:https://leetcode.com/problems/unique-paths-ii/description/ 62. Unique P...

梅森上校的博客 业精于勤荒于嬉,形成于思毁于随。 449

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

【Leetcode】63. 不同的路径 II(Unique Paths II)

Leetcode - 63 Unique Paths II (Medium) 题目描述:和上一道题类似,只不过在路径中添加了障碍物,给定路径数组,1 表示障碍物,0 表示正常方块。 Input: [ [0,0,0], [0,1,0], [0,0,0] ] Output: 2 Explanation: There is one obstacle in the middle of the ...

厉兵秣码 206

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

[leetcode] 63. Unique Paths II 解题报告

题目链接:https://leetcode.com/problems/unique-paths-ii/ Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle an

小榕流光的专栏 653

LeetCode算法题之63. Unique Paths II(Medium)【Python3题解】

题目描述: 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 point in time. The robot is trying to reach the bottom-right corner of the grid (marked ‘Finish’ in t

DaMoWangZQ的博客 330

leetcode 63.不同路径ii(unique paths ii)c语言

leetcode 63.不同路径ii(unique paths ii)c语言1.description2.solution 1.description https://leetcode-cn.com/problems/unique-paths-ii/description/ 一个机器人位于一个 obstacleGridSize x *obstacleGridColSize 网格的左上角 (起始点在下图中标记为“Start” )。 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为

hsk6543210的博客 576

python写算法题:leetcode: 63. Unique Paths II

class Solution(object): def __init__(self): self.cnt={} self.cnt[(0,0)]=1 def uniquePathsWithObstacles(self, obstacleGrid): """ :type obstacleGrid: List[Lis...

178

【一天一道LeetCode】#63. Unique Paths II

一天一道LeetCode(一)题目 Follow up for “Unique Paths”: Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as 1 and 0

ZeeCoder 3526

【leetcode刷题】62 63 64 unique path & unique path II & minimum path sum

原题链接 https://leetcode.com/problems/unique-paths/ https://leetcode.com/problems/unique-paths-ii/ https://leetcode.com/problems/minimum-path-sum/ 解题思路 这三道题比较类似,都是利用动态规划。 其中,unique path只需要把走到每一个格子里的方法数目加...

Arwen的博客 250

Leetcode 62. Unique Paths & 63. Unique Paths II

好久没刷题了,今天来俩道简单题。 Leetcode 62. Unique Paths Leetcode 63. Unique Paths IIA 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

xindoo 1764

【LeetCode】 63. Unique Paths II 不同路径 II(Medium)(JAVA)

【LeetCode】 63. Unique Paths II 不同路径 II(Medium)(JAVA) 题目地址: https://leetcode-.com/problems/unique-paths-ii/ 题目描述: A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagra...

qq_16927853的博客 241

【LeetCode】63. Unique Paths II

63. Unique Paths II Description: 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 point in time....

Microstrong 1118

【LeetCode 面试经典150题】63. Unique Paths II 独特路径 II

You are given an integer array . There is a robot initially located at the top-left corner (i.e., ). The robot tries to move to the bottom-right corner (i.e., ). The robot can only move either down or right at any point in time.An obstacle and space are m

qq_43513394的博客 521
上一篇: 【LeetCode】解题62:Unique Paths
下一篇: 【LeetCode】解题64:Minimum Path Sum
Fayedy
博客等级 码龄11年 2粉丝 57原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值