LeetCode刷题笔录Word Search

在实战中学AI-车流量统计项目-YOLOV11车辆检测-YOLOV11模型的部署 考虑实际落地中部署推理资源消耗,速度与模型精度之间的均衡,同时,车辆属于比较通用场景的目标检测,我们将YOLOV11作为最终的模型选择,目前官方开源的模型基于coco数据集训练,里面已经包含了车辆相关类别,经测试,在监控视角下效果基本可用,所以,在落地过程中,我们先用这个模型来打通部署链路,后面再逐步优化模型性能。在Nvidia的硬件下做部署,部署框架优先选择官方框架TensorRT,下面重点讲述如何用TensorRT部署YOLOV11模型。 阅读详情

Given a 2D board and a word, find if the word exists in the grid.

The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once.

For example,
Given board =

[
  ["ABCE"],
  ["SFCS"],
  ["ADEE"]
]
word = "ABCCED", -> returns true,
word = "SEE", -> returns true,

word = "ABCB", -> returns false.

这题好像除了用DFS暴力搜索没什么别的好办法。

用两层循环,对每一个字符进行一个DFS,而且可以往4个方向走。

另外用一个boolean[][] visited来记录当前字符是否被visit过。注意在递归后要重置visited。

public class Solution {
	public boolean exist(char[][] board, String word) {
		int rowLimit = board.length;
		int colLimit = board[0].length;
		boolean[][] visited = new boolean[rowLimit][colLimit];
		for (int i = 0; i < rowLimit; i++) {
			for (int j = 0; j < colLimit; j++) {
				if (recursive(board, word, 0, i, j, rowLimit, colLimit, visited))
					return true;
			}
		}
		return false;
	}

	public boolean recursive(char[][] board, String word, int index, int row,
			int col, int rowLimit, int colLimit, boolean[][] visited) {
		if (index == word.length())
			return true;
		// out of bounds
		if (row < 0 || col < 0 || row >= rowLimit || col >= colLimit)
			return false;
		// at a visited node
		if (visited[row][col])
			return false;
		// the two chars do not match
		if (board[row][col] != word.charAt(index))
			return false;
		// dfs
		visited[row][col] = true;
		boolean result = recursive(board, word, index + 1, row + 1, col,
				rowLimit, colLimit, visited)
				|| recursive(board, word, index + 1, row - 1, col, rowLimit,
						colLimit, visited)
				|| recursive(board, word, index + 1, row, col + 1, rowLimit,
						colLimit, visited)
				|| recursive(board, word, index + 1, row, col - 1, rowLimit,
						colLimit, visited);
		visited[row][col] = false;
		return result;
	}
}


星光、黑光、全彩夜视摄像头技术解析与实战选型指南 本文深入解析了星光、黑光、全彩与红外等主流夜视摄像头技术的工作原理与核心差异。针对不同监控场景与预算,提供了实战选型指南,帮助用户在安防项目中做出明智决策,实现夜间监控效果最大化。 阅读详情

相关推荐

开源浏览器插件开发实战:从零搭建多平台内容分发工具

浏览器扩展(Browser Extension)是运行在浏览器上层、通过标准Web技术增强浏览器能力的轻量级程序,其核心价值在于对页面内容的读取、操作与跨应用信息流转。在内容创作与分发场景中,创作者频繁需要在公众号、知乎、优快云、头条等平台间搬运同一篇文章,而传统SaaS分发工具往往受限于免费额度、授权托管和平台适配滞后等问题。基于Manifest V3规范,开发者可以构建一款100%开源、永久免费的浏览器插件,利用content script完成从源文章页提取标题、正文与图片,通过消息通信机制将结构化数

weixin_29882269的博客 293

Largest BST in a Binary Tree

一到面试题,挺有意思的。 简单做法是对于每个node都进行一遍isBST的测试,找出最大的那个。 public static int largestBSTNaive(TreeNode root){ if(isBST(root)){ return size(root); } return Math.max(largestBSTNaive(root.left), largestB

likecool21的专栏 1969

DICOM三维重建:基于VTK实现三种面绘制算法

版本:VS2019、VTK9.0.1 #define vtkRenderingCore_AUTOINIT 3(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingOpenGL2) #define vtkRenderingVolume_AUTOINIT 1(vtkRenderingVolumeOpenGL2) #include "vtkDICOMImageReader.h" #include "vtkRenderWindowInteractor.h" #i

一直在笑的博客 5922

LeetCode刷题笔录Letter Combinations of a Phone Number

Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit st

likecool21的专栏 1134

Zemax热分析实战:5分钟搞定双胶合透镜温度漂移优化(附操作数详解)

本文详细解析了使用Zemax进行光学系统热分析的全流程,以双胶合透镜为例,重点阐述了如何通过多重结构编辑器模拟温度变化,并利用关键操作数优化系统以抵抗温度漂移。文章提供了从基础设置到高级优化的实战技巧,帮助工程师快速掌握无热化设计方法,确保系统在宽温范围内保持稳定成像性能。

n4o5p6q7r的博客 396

手把手教你用GD32F407VET6的EXMC驱动外部SRAM,搞定大内存需求

本文详细介绍了如何使用GD32F407VET6的EXMC外设驱动外部SRAM,解决嵌入式开发中的大内存需求问题。通过硬件连接方案、EXMC时序配置与初始化步骤,以及软件集成与内存管理技巧,帮助开发者快速实现内存扩展。特别适合需要处理图形显示缓冲、音频处理等大内存场景的GD32F407开发者。

weixin_30752699的博客 346

LeetCode刷题笔录Subsets

自己总是写不出递归的方法,只能用f

likecool21的专栏 1121

rk3576 适配以太网(百兆)

百兆以太网,也常被称为快速以太网,是一种在1990年代中期推出的计算机网络技术标准。它相当于把当时主流的10兆以太网速度提升了10倍,最高能提供 100 Mbps 的传输速率,让文件共享、视频传输等网络应用变得流畅许多。它在数据链路层面完全保留了传统以太网的帧格式和MAC机制,这意味着现有的网络软件可以无缝对接,用户从10兆网络升级到百兆网络时,通常只需要更换网卡和集线器/交换机即可,非常方便。 在rk3576平台上,原生以太网接口支持百兆、千兆,还有pcie转换的2.5G。

weixin_35723192的博客 203

LeetCode刷题笔录Unique Binary Search Trees

这里有个讲解(印度人口音真难懂)

likecool21的专栏 1043

如何通过单步调试的方法,找到 SAP Gateway 到底把 Fiori 应用发送的 OData 请求,投递到哪一台 ABAP 后台服务器了?

这是一个 Count 请求,得到服务器响应的数据是 204,这个 204 会以数字的形式,显示在 Fiori Launchpad tile 上。那如果当前 Gateway 系统可以连接到多台 ABAP 后台服务器,比如下图所示,可以连接 SAP S/4HANA,ERP 或者 SAP CRM,我怎么知道 SAP UI5 应用上显示的数据,到底来自哪一台 ABAP 后台服务器呢?,就是上图 ABAP 调试器里断点停留的位置,即 SAP Frontend 服务器,通过 RFC 将 OData 请求投递给。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 640

SAP-ABAP:SAP库存管理核心增强:IF_EX_MB_DOCUMENT_BADI 深度解析

SAP库存管理核心增强:IF_EX_MB_DOCUMENT_BADI 深度解析

baidu_35680696的博客 1446

LeetCode刷题笔录Unique Binary Search Trees II

Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example, Given n = 3, your program should return all 5 unique BST's shown below. 1 3

likecool21的专栏 1016

AEJoy —— 最受欢迎的 5 个 Ae 表达方式

NOTE] 原文作者我意识到表达式可能令人生畏,有些人宁愿复制粘贴有用的代码,而不愿学习这门语言。对此我完全理解。因此,我想与您分享我的。这些是我几乎在每个项目中都会使用的表达式,我认为它们极大地提升了工作流程。

ShaderJoy 的兴趣技术杂货铺 363

LeetCode刷题笔录Word Break II

Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences. For example, given s = "

likecool21的专栏 923

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

LeetCode刷题笔录Sum Root to Leaf Numbers

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the tota

likecool21的专栏 878

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

LeetCode刷题笔录Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the f

likecool21的专栏 865

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

LeetCode刷题笔录Path Sum II

Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example: Given the below binary tree and sum = 22, 5 / \

likecool21的专栏 864

LeetCode刷题笔录Convert Sorted Array to Balanced Binary Search Tree

Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 这题可以kan'chu'lai

likecool21的专栏 855

LeetCode刷题笔录Construct Binary Tree from Preorder and Inorder Traversal

Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree.

likecool21的专栏 786

LeetCode刷题笔录 Same Tree

public class Solution { public boolean isSameTree(TreeNode p, TreeNode q) { if(p == null && q == null) return true; else if(p == null || q == null) return f

likecool21的专栏 775

LeetCode刷题笔录Combinations

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example, If n = 4 and k = 2, a solution is: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ]

likecool21的专栏 760

LeetCode刷题笔录 Pow(x,n)

Implement pow(x, n). z

likecool21的专栏 752

LeetCode刷题笔录Recover Binary Search Tree

Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Note: A solution using O(n) space is pretty straight forward. Could you devis

likecool21的专栏 750

求集合的交集/差集

先利用外部排序使两个磁盘文件有序,然后顺序读取两个文件,使用双指针求交集。在进阶 1 中,我们是通过双指针去做的,最坏情况下我们需要完整遍历。时,O(n log m) 可能明显优于 O(n + m)。的,这就使得我们可以通过从 1~1000 遍历来确定交集。,它们已经按非降序排序,请你返回两个数组的。和上一题的区别在于,这里需要找到重复的元素。返回一个数组,数组中的每个元素在。的每个字符串中都出现的共用字符(**注意:**列表中的整数可以按。较小,可以完整加载到内存,而。正整数组成的一个非空数组,按。

jyyyyx的算法之旅 112

LeetCode Hot 100 二叉树专题(二)3 题(Java)

本篇文章共 3 题:543. 二叉树的直径、102. 二叉树的层序遍历、108. 将有序数组转换为二叉搜索树。 每道题都统一按「① 题目分析 & 解题思路 → ② 常见解法(附代码)及讲解 → ③ 知识点总结」的顺序组织;代码使用 Java 编写,节点定义沿用 LeetCode 默认的 TreeNode。

2401_88612756的博客 365

LeetCode 面试经典 150_多维动态规划_交错字符串(97_C++_中等)

LeetCode 面试经典 150_多维动态规划_交错字符串(97_C++_中等) 题目描述: 给定三个字符串 s1、s2、s3,请你帮忙验证 s3 是否是由 s1 和 s2 交错 组成的。 两个字符串 s 和 t 交错 的定义与过程如下,其中每个字符串都会被分割成若干 非空 子字符串: - s = s1 + s2 + ... + sn - t = t1 + t2 + ... + tm - |n - m| <= 1 - 交错 是 s1 + t

huayimenghan的博客 205
上一篇: LeetCode刷题笔录3Sum
下一篇: LeetCode刷题笔录Binary Tree Post Order Traversal
likecool21
博客等级 码龄14年 14粉丝 123原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值