产品设计协作平台/关键词优化如何做

产品设计协作平台,关键词优化如何做,java成熟,做企业网站价格在 C# 中,有多种集合类可供使用,它们分别适用于不同的场景,部分代码示例提供了LeetCode相关的代码应用。 1. 数组(Array) 特点 固定大小:在创建数组时需要指定其长度,之后无法动态改变。连续存储&#xf…

在 C# 中,有多种集合类可供使用,它们分别适用于不同的场景,部分代码示例提供了LeetCode相关的代码应用。

1. 数组(Array)

  • 特点
    • 固定大小:在创建数组时需要指定其长度,之后无法动态改变。
    • 连续存储:数组元素在内存中是连续存储的,因此可以通过索引快速访问元素,访问时间复杂度为 O(1)。
    • 类型固定:数组中的所有元素必须是相同类型。
  • 示例代码
  int[] numbers = new int[5] { 1, 5, 2, 3, 4 };numbers[0] = 1;//updateint firstNumber = numbers[0];int lastNumber = numbers[numbers.Length - 1];Array.Sort(numbers);//排序

LeetCode: 106. 从中序与后序遍历序列构造二叉树 - 力扣(LeetCode)

public TreeNode BuildTree(int[] inorder, int[] postorder)
{if (inorder.Length == 0 || postorder.Length == null) return null;int rootValue = postorder.Last();TreeNode root = new TreeNode(rootValue);int delimiterIndex = Array.IndexOf(inorder, rootValue);root.left = BuildTree(inorder.Take(delimiterIndex).ToArray(), postorder.Take(delimiterIndex).ToArray());root.right = BuildTree(inorder.Skip(delimiterIndex + 1).ToArray(), postorder.Skip(delimiterIndex).Take(inorder.Length - delimiterIndex - 1).ToArray());return root;
}

2. 动态数组(List<T>)

  • 特点
    • 动态大小:可以根据需要动态添加或删除元素,无需预先指定大小。
    • 连续存储:内部使用数组实现,元素在内存中连续存储,支持通过索引快速访问,访问时间复杂度为 O(1)。
    • 类型安全:泛型集合,只能存储指定类型的元素。
  • 示例代码
List<int> numberList = new List<int>();
numberList.Add(1);
int firstElement = numberList[0];

3. 链表(LinkedList<T>)

  • 特点
    • 动态大小:可以动态添加或删除元素。
    • 非连续存储:元素在内存中不连续存储,每个元素包含一个指向前一个元素和后一个元素的引用。
    • 插入和删除效率高:在链表的任意位置插入或删除元素的时间复杂度为 O(1),但随机访问效率低,时间复杂度为O(n) 。
  • 示例代码
            LinkedList<int> numberLinkedList = new LinkedList<int>();numberLinkedList.AddLast(1);numberLinkedList.AddFirst(2);numberLinkedList.AddFirst(3);numberLinkedList.Remove(1);numberLinkedList.RemoveFirst();numberLinkedList.RemoveLast();int count=numberLinkedList.Count;bool isContains= numberLinkedList.Contains(3);

4. 栈(Stack<T>)

  • 特点
    • 后进先出(LIFO):最后添加的元素最先被移除。
    • 动态大小:可以动态添加或删除元素。
    • 插入和删除操作快:入栈(Push)和出栈(Pop)操作的时间复杂度为O(1) 。
  • 示例代码
            Stack<int> numberStack = new Stack<int>();numberStack.Push(1);// Removes and returns the object at the top of the System.Collections.Generic.Stack`1.int topElement = numberStack.Pop();// Returns the object at the top of the System.Collections.Generic.Stack`1 without removing it.topElement = numberStack.Peek(); int count = numberStack.Count;

LeetCode: 144. 二叉树的前序遍历

/*** Definition for a binary tree node.* public class TreeNode {*     public int val;*     public TreeNode left;*     public TreeNode right;*     public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) {*         this.val = val;*         this.left = left;*         this.right = right;*     }* }*/
public class Solution {public IList<int> PreorderTraversal(TreeNode root) {var result = new List<int>();if (root == null) return result;Stack<TreeNode> treeNodes = new Stack<TreeNode>();// 栈是先进后出。 中序遍历是:中--》 左--》右treeNodes.Push(root);while (treeNodes.Count > 0){TreeNode current = treeNodes.Pop();result.Add(current.val);// 中if (current.right != null)// 右{treeNodes.Push(current.right);}if (current.left != null)// 左{treeNodes.Push(current.left);}}return result;}
}

5. 队列(Queue<T>)

  • 特点
    • 先进先出(FIFO):最先添加的元素最先被移除。
    • 动态大小:可以动态添加或删除元素。
    • 插入和删除操作快:入队(Enqueue)和出队(Dequeue)操作的时间复杂度为 O(1)。
  • 示例代码
          Queue<int> numberQueue = new Queue<int>();numberQueue.Enqueue(1);// Removes and returns the object at the beginning of the System.Collections.Generic.Queue`1.int firstElement = numberQueue.Dequeue();//Returns the object at the beginning of the System.Collections.Generic.Queue`1 without removing it.numberQueue.Peek();int count = numberQueue.Count;

LeetCode: 102. 二叉树的层序遍历 - 力扣(LeetCode) 

/*** Definition for a binary tree node.* public class TreeNode {*     public int val;*     public TreeNode left;*     public TreeNode right;*     public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) {*         this.val = val;*         this.left = left;*         this.right = right;*     }* }*/
public class Solution {public IList<IList<int>> LevelOrder(TreeNode root) {var result = new List<IList<int>>();Queue<TreeNode> queue = new ();if (root != null) queue.Enqueue(root);while (queue.Count>0){var row=new List<int>();int count=queue.Count;// 需要事先记录Queue的Count,不能直接依靠Queue本身for (int i=0; i < count; i++){var currentNode=queue.Dequeue();row.Add(currentNode.val);if (currentNode.left != null) queue.Enqueue(currentNode.left);if (currentNode.right != null) queue.Enqueue(currentNode.right);}result.Add(row);}return result;}
}

6. 哈希集合(HashSet<T>)

  • 特点
    • 唯一元素:集合中不允许有重复的元素。
    • 无序:元素在集合中没有特定的顺序。
    • 快速查找:插入、删除和查找操作的平均时间复杂度为O(1) 。
  • 示例代码
      HashSet<int> numberHashSet = new HashSet<int>();numberHashSet.Add(1);bool isAddSuccess = numberHashSet.Add(1);// falsebool containsOne = numberHashSet.Contains(1);// true

如LeetCode:491. 非递减子序列

public class Solution {public IList<IList<int>> FindSubsequences(int[] nums) {var result = new List<IList<int>>();var path = new List<int>();if(nums==null || nums.Length == 0) return result;BackTacking(nums,result,path,0);return result;}private void BackTacking(int[] nums,List<IList<int>> result, List<int> path,int startIndex){if (path.Count>=2) result.Add(new List<int>(path));HashSet<int> used =new HashSet<int>();for (int i=startIndex;i<nums.Length;i++){if(path.Count>0 && nums[i]<path[path.Count-1]) continue;bool isUsed=used.Add(nums[i]);// true-添加成功;false-添加失败,证明已经有元素存在了if(!isUsed) continue;// 同一层重复使用path.Add(nums[i]);BackTacking(nums,result,path,i+1);path.RemoveAt(path.Count-1);}}
}

7. 字典(Dictionary<TKey, TValue>)

  • 特点
    • 键值对存储:通过唯一的键来关联对应的值。
    • 快速查找:根据键查找值的平均时间复杂度为  O(1)。
    • 键唯一:字典中的键必须是唯一的,但值可以重复。
  • 示例代码
Dictionary<string, int> scores = new Dictionary<string, int>();
scores.Add("Alice", 90);
int aliceScore = scores["Alice"];

LeetCode: 105. 从前序与中序遍历序列构造二叉树 - 力扣(LeetCode)

/*** Definition for a binary tree node.* public class TreeNode {*     public int val;*     public TreeNode left;*     public TreeNode right;*     public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) {*         this.val = val;*         this.left = left;*         this.right = right;*     }* }*/
public class Solution {public TreeNode BuildTree(int[] preorder, int[] inorder){if (preorder == null || inorder == null){return null;}/*前序遍历   根   左子树 右子树中序遍历   左子树 根   右子树*/if (preorder.Length != inorder.Length){return null;}Dictionary<int, int> keyMap = new Dictionary<int, int>();for (int i = 0; i < inorder.Length; i++){keyMap.Add(inorder[i], i);}return BuildTree(preorder: preorder, keyMap, preleft: 0, preRight: preorder.Length - 1, inLeft: 0, inRight: inorder.Length - 1);}/// <summary>/// /// </summary>/// <param name="preorder"></param>/// <param name="keyMap">用于确定pIndex。Root的Index</param>/// <param name="preleft"></param>/// <param name="preRight"></param>/// <param name="inLeft"></param>/// <param name="inRight"></param>/// <returns></returns>private TreeNode BuildTree(int[] preorder, Dictionary<int, int> keyMap, int preleft, int preRight, int inLeft, int inRight){if (preleft > preRight || inLeft > inRight){return null;}int rootValue = preorder[preleft];TreeNode treeNode = new TreeNode(rootValue);int pIndex = keyMap[rootValue];treeNode.left = BuildTree(preorder, keyMap, preleft: preleft + 1, preRight: pIndex + preleft - inLeft, inLeft, inRight: pIndex - 1);//根据PreOrder去取Left nodetreeNode.right = BuildTree(preorder, keyMap, preleft: pIndex + preleft - inLeft + 1, preRight: preRight, inLeft: pIndex + 1, inRight);//根据inOrder去取Right nodereturn treeNode;}
}

8. 排序集合(SortedSet<T>)

  • 特点
    • 唯一元素:集合中不允许有重复的元素。
    • 有序:元素会根据元素的自然顺序或指定的比较器进行排序。
    • 查找和插入操作:插入、删除和查找操作的时间复杂度为 O(logn)。
  • 示例代码
SortedSet<int> sortedNumbers = new SortedSet<int>();
sortedNumbers.Add(3);
sortedNumbers.Add(1);
// 元素会自动排序,遍历输出为 1, 3
foreach (int number in sortedNumbers)
{Console.WriteLine(number);
}

9. 排序字典(SortedDictionary<TKey, TValue>)

  • 特点
    • 键值对存储:通过唯一的键来关联对应的值。
    • 有序:元素会根据键的自然顺序或指定的比较器进行排序。
    • 查找和插入操作:根据键查找值、插入和删除操作的时间复杂度为  O(logn)。
  • 示例代码
SortedDictionary<string, int> sortedScores = new SortedDictionary<string, int>();
sortedScores.Add("Evan", 38);
sortedScores.Add("Alice", 30);
// 会根据键排序,遍历输出 Alice: 30, Evan: 38
foreach (KeyValuePair<string, int> pair in sortedScores)
{Console.WriteLine($"{pair.Key}: {pair.Value}");
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/70679.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

2025年信息科学与工程学院科协机器学习介绍——机器学习基本模型介绍

机器学习 目录 机器学习一.安装基本环境conda/miniconda环境 二.数据操作数据预处理一维数组二维数组以及多维数组的认识访问元素的方法torch中tenson的应用张量的运算张量的广播 三.线性代数相关知识四.线性回归SoftMax回归问题&#xff08;分类问题&#xff09;什么是分类问题…

计算机毕业设计Hadoop+Spark+DeepSeek-R1大模型民宿推荐系统 hive民宿可视化 民宿爬虫 大数据毕业设计(源码+文档+PPT+讲解)

温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 作者简介&#xff1a;Java领…

山东大学软件学院nosql实验一环境配置

环境&#xff1a;前端vue后端springboot 软件环境&#xff1a; MongoDB MongoDBCompass 实验步骤与内容&#xff1a; 在官网下载安装包&#xff08;最新版&#xff09; 配置环境环境变量 在“高级系统设置-环境变量”中&#xff0c;可以将MongoDB添加到环境变量Path中(D:\…

《计算机视觉》——图像拼接

图像拼接 图像拼接是将多幅有重叠区域的图像合并成一幅全景或更大视角图像的技术&#xff0c;以下为你详细介绍&#xff1a; 原理&#xff1a;图像拼接的核心原理是基于图像之间的特征匹配。首先&#xff0c;从每幅图像中提取独特的特征点&#xff0c;如角点、边缘点等&#x…

后台管理系统-园区管理

功能演示和模版搭建 <template><div class"building-container"><!-- 搜索区域 --><div class"search-container"><div class"search-label">企业名称&#xff1a;</div><el-input clearable placeholde…

【Deepseek高级使用教程】Deepseek-R1的5种高级进阶玩法,5分钟教会你Deepseek+行业的形式进行工作重构的保姆级教程

AI视频生成&#xff1a;小说文案智能分镜智能识别角色和场景批量Ai绘图自动配音添加音乐一键合成视频https://aitools.jurilu.com/ 最近&#xff0c;有各行各业的小伙伴问我&#xff0c;到底应该怎么将deepseek融入进他们自身的工作流呢&#xff1f;其实这个问题很简单。我就以…

selenium爬取苏宁易购平台某产品的评论

目录 selenium的介绍 1、 selenium是什么&#xff1f; 2、selenium的工作原理 3、如何使用selenium&#xff1f; webdriver浏览器驱动设置 关键步骤 代码 运行结果 注意事项 selenium的介绍 1、 selenium是什么&#xff1f; 用于Web应用程序测试的工具。可以驱动浏览…

[实现Rpc] 客户端 | Requestor | RpcCaller的设计实现

目录 Requestor类的实现 框架 完善 onResponse处理回复 完整代码 RpcCaller类的实现 1. 同步调用 call 2. 异步调用 call 3. 回调调用 call Requestor类的实现 &#xff08;1&#xff09;主要功能&#xff1a; 客户端发送请求的功能&#xff0c;进行请求描述对服务器…

ONNX转RKNN的环境搭建和部署流程

将ONNX模型转换为RKNN模型的过程记录 工具准备 rknn-toolkit:https://github.com/rockchip-linux/rknn-toolkit rknn-toolkit2:https://github.com/airockchip/rknn-toolkit2 rknn_model_zoo:https://github.com/airockchip/rknn_model_zoo ultralytics_yolov8:https://github…

20250221 NLP

1.向量和嵌入 https://zhuanlan.zhihu.com/p/634237861 encoder的输入就是向量&#xff0c;提前嵌入为向量 二.多模态文本嵌入向量过程 1.文本预处理 文本tokenizer之前需要预处理吗&#xff1f; 是的&#xff0c;文本tokenizer之前通常需要对文本进行预处理。预处理步骤可…

AWS - Redshift - 外部表读取 Parquet 文件中 timestamp 类型的数据

问题&#xff1a; 通过 Redshift Spectrum 功能可以读取 S3 中的文件&#xff0c;当读取 Parquet 文件时&#xff0c;如果列格式设置为 timestamp&#xff0c; 通过 psql 客户端读取会出现以下错误&#xff1a; testdb# select * from myspectrum_schema_0219.test_ns; ERROR…

Pretraining Language Models with Text-Attributed Heterogeneous Graphs

Pretraining Language Models with Text-Attributed Heterogeneous Graphs EMNLP 推荐指数&#xff1a;#paper/⭐⭐#​ 贡献&#xff1a; 我们研究了在更复杂的数据结构上预训练LM的问题&#xff0c;即&#xff0c;TAHG。与大多数只能从每个节点的文本描述中学习的PLM不同&…

重新求职刷题DAY18

1.513. 找树左下角的值 给定一个二叉树的 根节点 root&#xff0c;请找出该二叉树的 最底层 最左边 节点的值。 假设二叉树中至少有一个节点。 示例 1: 外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传 输入: root [2,1,3] 输出: 1思路&#xff1a; 这…

B站pwn教程笔记-2

这次是栈溢出基础。 栈基础知识 栈帧结构概览 看上图的高地址和低地址。arguments是子函数的形参。蓝色的是上一个栈的ebp值&#xff0c;用于在子函数执行完毕之后&#xff0c;返回到正确的ebp. heap的占的内存大大的超过stack。 下面看看调用栈的详细过程。 一个函数都是以…

tableau之人口金字塔、漏斗图、箱线图

一、人口金字塔 人口金字塔在本质上就是成对的条形图 人口金字塔是一种特殊的旋风图 1、数据处理 对异常数据进行处理 2、创建人口金字塔图 将年龄进行分桶 将男女人数数据隔离开 分别绘制两个条形图 双击男性条形图底部&#xff0c;将数据进行翻转&#xff08;倒序&a…

首次使用WordPress建站的经验分享(一)

之前用过几种内容管理系统(CMS),如:dedeCMS、phpCMS、aspCMS,主要是为了前端独立建站,达到预期的效果,还是需要一定的代码基础的,至少要有HTML、Css、Jquery基础。 据说WordPress 是全球最流行的内容管理系统CMS,从现在开始记录一下使用WordPress 独立建站的步骤 选购…

【Viewer.js】vue3封装图片查看器

效果图 需求 点击图片放大可关闭放大的 图片 下载 cnpm in viewerjs状态管理方法 stores/imgSeeStore.js import { defineStore } from pinia export const imgSeeStore defineStore(imgSeeStore, {state: () > ({showImgSee: false,ImgUrl: ,}),getters: {},actions: {…

人工智能 阿里云算力服务器的使用

获取免费的阿里云服务器 阿里云免费使用地址&#xff1a; https://free.aliyun.com/ 选择 人工智能平台 PAI 选择交互式建模 再选建立实例。 选择对应的GPU 和镜像&#xff0c;点击确认。 注意&#xff1a;250个小时&#xff0c;用的时候开启&#xff0c;不用的时候关闭&…

大语言模型(LLM)微调技术笔记

图1&#xff1a;大模型进化树2 大模型微调 在预训练后&#xff0c;大模型可以获得解决各种任务的通用能力。然而&#xff0c;越来越多的研究表明&#xff0c;大语言模型的能力可以根据特定目标进一步调整。 这就是微调技术&#xff0c;目前主要有两种微调大模型的方法1&…

deepseek清华大学第二版 如何获取 DeepSeek如何赋能职场应用 PDF文档 电子档(附下载)

deepseek清华大学第二版 DeepSeek如何赋能职场 pdf文件完整版下载 https://pan.baidu.com/s/1aQcNS8UleMldcoH0Jc6C6A?pwd1234 提取码: 1234 或 https://pan.quark.cn/s/3ee62050a2ac