Number of Islands, variation

利用MATLAB 4f光学系统,在Python中进行弗劳恩霍夫衍射和傅里叶面滤波——用镜头模拟光学图像处理。.zip 1.版本:matlab2014a/2019b/2024b 2.附赠案例数据可直接运行。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。 立即下载
/*
  Given a matrix, find the value area which correponde to the given value.
  For example;

  0 0 0 0 1 1 1 1
  1 0 0 0 1 0 0 0
  0 0 0 0 1 1 1 1
  1 1 1 1 0 0 0 0

  if the given position is (0, 4), the value is 1, return area 9.
  if the given position is (0, 0), the value is 0, return 11.
*/
// Requirement: using two ways
// first using dfs.
#include <vector>
#include <queue>
#include <iostream>
using namespace std;
struct pos {
    int x;
    int y;
    pos(int i, int j) : x(i), y(j) {}
};
int surroundAreaII(vector< vector<int> >& matrix, int i, int j) {
  int count = 0;
  queue<pos> position;
  int target = matrix[i][j];
  int cnt = 1;
  matrix[i][j] = -1;
  pos curr(i, j);
  position.push(curr);
  vector< vector<int> > dir {
  {0, 1},
  {0, -1},
  {-1, 0},
  {1, 0}};
  while(!position.empty()) {
    pos tmp = position.front();
    position.pop();
    for(auto kir : dir) {
      int next_x = kir[0] + tmp.x;
      int next_y = kir[1] + tmp.y;
      if(next_x >= 0 && next_x < matrix.size() && next_y >= 0 && next_y < matrix[0].size() && (matrix[next_x][next_y] == target)) {
        pos nextPos(next_x, next_y);
        position.push(nextPos);
        cnt++;
        matrix[next_x][next_y] = -1;
      }
    }
  }
  return cnt;
}

// use -1 to mark the node as visited.
void dfs(vector< vector<int> >& matrix, int i, int j, int& count, int value) {
  if(i < 0 || i >= matrix.size() || j < 0 || j >= matrix[i].size() || (matrix[i][j] == -1)) {
    return;
  } else {
  if(matrix[i][j] == value) {
    count = count + 1;
    matrix[i][j] = -1;
    dfs(matrix, i - 1, j, count, value);
    dfs(matrix, i + 1, j, count, value);
    dfs(matrix, i, j + 1, count, value);
    dfs(matrix, i, j - 1, count, value);
    }
  }
}
int surroundArea(vector< vector<int> >& matrix, int i, int j) {
  int count = 0;
  dfs(matrix, i, j, count, matrix[i][j]);
  return count;
}

int main(void) {
  vector< vector<int> > matrix {
  {0, 0, 0, 0, 1, 1, 1, 1},
  {1, 0, 0, 0, 1, 0, 0, 0},
  {0, 0, 0, 0, 1, 1, 1, 1},
  {1, 1, 1, 1, 0, 0, 0, 0}};
  cout << surroundAreaII(matrix, 0, 0) << endl;
}

2: Largest Area the island has:

#include "header.h"
using namespace std;

/*
  1, 1, 0, 0, 1
  1, 1, 1, 0, 0
  1, 1, 0, 0, 0
  0, 0, 0, 0, 1
  Find the largest area of the island.
*/
void dfs(vector< vector<int> >& matrix, int i, int j, int& maxArea, int leftX, int rightX, int upY, int downY) {
  if(i < 0 || i >= matrix.size() || j < 0 || j >= matrix[0].size() || matrix[i][j] == -1 || matrix[i][j] == 0) return;
  leftX = min(leftX, i);
  rightX = max(rightX, i);
  upY = min(upY, j);
  downY = max(downY, j);
  maxArea = max(maxArea, (abs(rightX - leftX) + 1) * (abs(upY - downY) + 1));
  matrix[i][j] = -1;
  dfs(matrix, i - 1, j , maxArea, leftX, rightX, upY, downY);
  dfs(matrix, i + 1, j, maxArea, leftX, rightX, upY, downY);
  dfs(matrix, i, j - 1, maxArea, leftX, rightX, upY, downY);
  dfs(matrix, i, j + 1, maxArea, leftX, rightX, upY, downY);
}


int largestArea(vector< vector<int> > matrix) {
  if(matrix.size() == 0 || matrix[0].size() == 0) return 0;
  int maxArea = 1;
  for(int i = 0; i < matrix.size(); ++i) {
    for(int j = 0; j < matrix[0].size(); ++j) {
      if(matrix[i][j] == 1) {
        int leftX = i, rightX = i, upY = j, downY = j;
        dfs(matrix, i, j, maxArea, leftX, rightX, upY, downY);
      }
    }
  }
  return maxArea;
}
int main(void) {
  vector< vector<int> > matrix {
    {1, 1, 0, 0, 1},
    {1, 1, 1, 0, 0},
    {1, 1, 0, 0, 0},
    {0, 0, 0, 0, 1}};
  cout << largestArea(matrix) << endl;
}


工业互联网工控安全与工业质检AI大模型建设方案.pptx 立即下载

相关推荐

通信行业CentOS 7内核网络栈优化:高并发连接下UDP/TCP性能调优与系统资源管理

内容概要:本文聚焦于CentOS 7系统在通信行业高并发场景下的性能调优实践,重点围绕内核网络栈优化展开,涵盖UDP/TCP缓冲区调整、文件句柄与连接跟踪表扩容、TIME_WAIT状态复用、软中断分布优化及tuned工具的自动化调优。通过具体配置参数和实际案例(如VoIP软交换系统)深入解析各项调优措施的设计原理与实施效果,有效解决高CPS下丢包、连接失败等问题,并展望了向云化、eBPF等动态智能调优方向的发展趋势。; 适合人群:从事通信系统运维、网络开发或Linux系统性能优化的技术人员,具备一定操作系统和网络基础知识,工作经验1年以上的中初级工程师。; 使用场景及目标:①应用于软交换、媒体网关、信令网关等高并发通信设备的系统调优;②解决UDP丢包、conntrack表满、TCP连接队列溢出等典型性能瓶颈;③提升系统在小包高频、低时延要求场景下的稳定性和吞吐能力。; 阅读建议:建议结合实际生产环境或测试平台同步验证文中配置,重点关注参数背后的物理意义(如BDP、softirq、conntrack机制),并配合ss、conntrack、dmesg等命令进行调优前后对比分析,确保安全可控地实施变更。

Add One

#include #include using namespace std; /* Given an integer, add its binary number by 1 without using '+'. */ int addOne(int number) { long long int a = number; if(a >= INT_MAX) return -1; /

ActiveCoder的博客 2079

2024 《计算机网络》实验教学指导书.doc

2024 《计算机网络》实验教学指导书.doc

LeetCode 91. Decode Ways

There are two ways to solve this problem. One is to solve it front-back, the other is back-front. I currently only wrote the back-front method: Suppose we have such a string:    a0, a1, a2.... ai, a

ActiveCoder的博客 954

不平衡电网下自抗扰顺序模型预测PWM整流器控制仿真模型(Simulink仿真实现)

内容概要:本文围绕面向城市空中交通的多无人机路径规划问题展开研究,提出了一套融合全局规划、动态避障与局部协同调整的综合路径规划方法。研究内容涵盖基于改进RRT算法与图论的全局路径规划、基于动态风险场和动态窗口法(DWA)的模型预测控制实现动态避障,以及基于分布式协同控制的多无人机局部路径协同策略。通过Matlab平台构建仿真环境,在多种典型城市交通场景下对所提方法进行了系统性验证,结果表明该方法在路径安全性、编队稳定性与任务效率方面表现优异。文章还深入探讨了算法的创新点与未来研究方向,为复杂城市环境下多无人机系统的自主协同提供了理论支撑与技术路径。; 适合人群:具备自动化、控制理论、计算机科学或相关领域基础知识,从事无人机系统、智能交通、路径规划、多智能体协同控制等方向研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①为城市空中交通系统中的多无人机安全、高效飞行提供可靠的路径规划解决方案;②支持在复杂、动态的城市场景中开展无人机自主导航、编队飞行与协同控制的技术研究与仿真验证。; 阅读建议:建议结合提供的Matlab代码进行实践操作,重点关注算法的具体实现细节、参数配置对性能的影响以及不同仿真场景下的实验设计,以深入理解各模块的集成逻辑与实际应用效果。

用 n8n 提取静态网页内容:从 HTTP Request 到 HTML 节点全解析

本文介绍了如何使用n8n的HTTP Request和HTML节点组合提取静态网页内容。首先通过HTTP Request节点获取网页HTML源码,然后使用HTML节点解析并提取所需数据。关键点包括:1)HTTP Request节点设置URL和GET方法;2)HTML节点配置Source Data为JSON并指定data字段;3)重点掌握Extraction Values参数,特别是CSS选择器(使用.和#定位元素)、Key命名、Return Value类型选择等。文章通过实例演示了标题和正文的提取方法,并提供

muyouking 4565

Find the Thief (Facebook Interview)

Suppose there is a thief and n rooms. We can only any door to check whether the thief is there or not. during the night, the theif can either move left one room or right one room. Given a sequence of

ActiveCoder的博客 728

java三角套利_三角对冲套利-EA原理全解析

它是两个直盘货币和一个交叉盘货币之间的相互对冲,交易员往往受到外界因素的影响无法严格执行造成亏损。该系统经过大量数据统计分析和严格的科学论证计算,并通过多年实盘交易验证可以达到稳定盈利。希望交易员严格按照交易规则执行。此策略利用交叉外汇对的市场价格与其合成价格的价差来实现套利,还以EUR/USD和GBP为例:1,我们关注三个外汇对:EUR/USD,GBP/USD,以及GBP/EUR2,计算GBP/...

weixin_29531897的博客 2417

LeetCode 273. Integer to English Words

I changed the integer into string. If the length is not multiple of 3, append "0" ahead. Then, deal three digits by chunks. #include #include #include using namespace std; /* Convert a non-ne

ActiveCoder的博客 641

miRNA测序数据生信分析——第一讲,总结概述

这里的miRNA测序指转录水平的测序。这里每一个数据库都可以在线访问,但是如果要本地使用,都需要进行数据库文件下载,整理。

weixin_44616693的博客 4950

PE启动盘结合360杀毒离线版:深度清除顽固病毒实战指南

在系统安全维护领域,离线查杀是一种在独立于宿主操作系统的环境下进行病毒扫描和清除的核心技术。其原理是通过一个预启动环境(如PE)加载杀毒软件,从而绕过可能已被感染或受保护的系统核心,直接访问和扫描磁盘文件。这项技术的核心价值在于能够彻底处理那些在正常系统运行时难以清除的深度隐藏病毒、Rootkit和驱动级木马。典型的应用场景包括应对勒索软件、顽固感染型病毒以及系统启动项被劫持等情况。本文以“PE启动盘”和“360杀毒离线版”这一经典组合为例,详细解析了从工具选型、环境部署到深度查杀策略的全流程,为系统维护人

weixin_29741447的博客 407

Subarray Sum to the given target value

Question: check if there is a subarray sum equals to the given target. This question should ask for clarifications. Whether the inputs are all positive, or it has negative numbers. 1: If all the num

ActiveCoder的博客 623

Ubuntu22.04 网络图标消失与连接故障排查指南(附实战修复流程)

本文详细介绍了Ubuntu22.04系统中网络图标消失与连接故障的排查与修复方法。通过ifconfig、dhclient等命令诊断问题,提供从紧急恢复网络连接到深度排查的完整解决方案,帮助用户快速恢复网络功能并预防类似问题再次发生。

weixin_28481133的博客 287

Task Arrangement -- incomplete

Task schedule: Given a sequence of task like A B C, and a coldtime, which means you need to wait for that much time to start next[same] task. Now--- Input: string , n Output: the best task finishing

ActiveCoder的博客 556

AI Agent的数据安全与隐私保护措施

AI Agent(人工智能代理)作为一种能够感知环境、做出决策并采取行动的智能实体,在现代社会的各个领域中得到了广泛的应用,如智能客服、自动驾驶、金融风险评估等。随着其应用的不断拓展,AI Agent处理和存储的数据量急剧增加,这些数据包含了大量的个人敏感信息和商业机密。因此,确保AI Agent的数据安全与隐私保护变得至关重要。本文的目的在于全面探讨AI Agent的数据安全与隐私保护措施,涵盖从数据的采集、存储、处理到传输的整个生命周期。

AGI×大数据,开启智能时代的认知跃迁;解码AGI,赋能数据驱动的智能革命。 2864

在轻量化与精度之间取得平衡:YOLOv8 + GhostNet 的设计与实验分析

摘要: GhostNet系列(GhostNet、GhostNetv2、GhostNeXt)通过“幽灵特征图”技术,以极低计算量生成丰富特征,为YOLOv8提供轻量化改造方案。该技术能在减少参数量与计算量的同时保持或提升检测精度,适用于边缘设备部署。实现时需替换YOLOv8的Backbone为GhostNet模块,并通过消融实验验证其有效性。实验数据表明,改造后的模型在参数量降低30%的同时,推理速度提升28.6%,mAP@0.5最高提升1.9个百分点,平衡了轻量化与精度,为毕设提供技术创新性与工程落地性的双

m0_64661770的博客 194

Facebook Phone Interview: Phone Number to Letter Combinations

Input: string of digits of arbitrary length output: print all possible letter combinations for those digits to screen. // This is a typical DFS algorithm. // Suppose we dont know the phone screen l

ActiveCoder的博客 517

手把手教你在飞牛 NAS 上部署自有图床,含Python调用接口

📸 想在飞牛 NAS 上部署图床?这篇教程超适合小白!从安装到使用,步骤清晰~

XiaoqiangClub的博客 2344

Facebook Phone Interview: 3, 4 Sum (Easy)

Facebook really usually has a high frequency of posting repetitive problems. This one is the typical 3Sum, 4Sum problem. Given an input array and a target value, find whether there are three/four

ActiveCoder的博客 450

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

LeetCode 28. Implement strStr()

Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. It is pretty hard to generalize KMP algorithm under stress and limited

ActiveCoder的博客 448

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

LeetCode 76. Minimum Window Substring

#include #include #include #include using namespace std; /* Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For

ActiveCoder的博客 413

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Maximum value's random index

#include #include #include #include #include using namespace std; // naive method // Go through the array once, find the max and the number of occurrences (n) // Generate a random number (r) bet

ActiveCoder的博客 408

LeetCode. 314 Binary Tree Vertical Order Traversal

The basic idea to attach each node a col number. When goes to node->left. col -1, goes to right, col + 1. It will make things easier using a hashmap to store the nodes and correpsonding col number.

ActiveCoder的博客 395

Three Sum Variation.

/* find three numbers that sums to 0, every number can be used repeatly. (Someone said it can be solved using hashMap?) Follow up: what if any K numbers. */ #include #include #include using nam

ActiveCoder的博客 389

LeetCode 145. Binary Tree Postorder Traversal

Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. Stack Problem, One example

ActiveCoder的博客 384

Remove Nested Comments.

Comments can be single line using //, or multiple line using /* */ We can use two flags to make the begin and end of two types of comments. string removeComments(string str) { string res; bool s

ActiveCoder的博客 379
上一篇: Flatten BST to Double Linked List
下一篇: Maximum value's random index
ActiveCoder
博客等级 码龄11年 4粉丝 345原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值