-
基于51单片机的锯齿波&正弦波发生器系统设计 幅度频率可调
附锯齿波 正弦波程序&protues仿真原理图 幅度频率可调
- 2020-12-02下载
- 积分:1
-
资源分配算法
matlab中处理OFDMA的资源分配,包括子载波分配和功率分配.是LTE系统中的以最大化系统吞吐量为目的
- 2020-12-04下载
- 积分:1
-
模糊PID液位控制系统的设计与实现
水箱液位控制系统的模糊PID控制,介绍了建模,算法,仿真等,十分有用。
- 2020-12-10下载
- 积分:1
-
labview中波形图的游标坐标
labview中波形图的游标位置移动,实时显示坐标值。
- 2020-12-12下载
- 积分:1
-
java调用电脑摄像头拍照例子
Java调用电脑摄像头拍照实现例子,运用的是开源项目webcam-capture实现的;详情看这里:https://blog.csdn.net/qq_22078107/article/details/85927626
- 2020-12-05下载
- 积分:1
-
ansoft Maxwell 3d教程.pdf
ansoft Maxwell 3d 向导式的用户界面、精度驱动的自适应剖分技术和强大的后处理器时的Maxwell 3D成为业界最佳的高性能三维电磁设计软件。可以分析涡流、位移电流、集肤效应和邻近效应具有不可忽视作用的系统,得到电机、母线、变压器、线圈等电磁部件的整体特性。功率损耗、线圈损耗、某一频率下的阻抗(R和L)、力、转矩、电感、储能等参数可以自动计算。同时也可以给出整个相位的磁力线、B和H分布图、能量密度、温度分布等图形结果。本文件是软件使用教程.希望能帮助大家·Printing HistorNew editions of this manual include material up dated since theprevious edition. The manual printing date, indicating the manualscurrent edition, changes w hen a ncw edition is printed. Minorcorrections and updates incorporated al reprint do not cause the daleto changeUpdate packages may be issued betw een editions and containadditional and/ or rep lacement pages to be merged into the manualby the user Pages which are rearranged because of changes on aprevious page are not considered to be revised.EditionDateSoftwareRevisionFebruary 1991April 199212December 1993October 19964.1September 19995.06December 20006.0WWW⊥nmTypeface ConventionsComputerCter type is used fon promptsand messages, for field names, and for keyboard entries that must be ty ped in theirentirety exactly as shown. For example, thenstruction"copy filel"means to type the w ordcopy, to type a space. and then to type filelMenu/Command Computer type is also used to display the commands that are needed to perform a specifictask Menu levels are separated by forwardslashes (/) For example, the instructionhoose File/Open"means to choose the Opencommand under the file menuItalicsItalic type is used for emphasis and for thetitles of manuals and other publications. Italictype is also used for key board entries when aname or a variable must be typed in place ofthe words in italics. For example, the instruc-rion“ copy filename” means to type the wordcopy, to type a space, and then to type then amc of a filc. such as filelKeysHelvetica type is used for labeled keys on thecomputer keyboard. For example, the instruc-tion"Press Return?"means to press the key onthe com puter that is lahcled Returnwww.docin.coInstallationBefore you use Maxwell 3D, you must1. Set up your systems graphical windowing systerm2. Install the Maxwell softw are, using the directions in theAnsell PC or UNIX Installation guideIf you have not yet done these steps, refer to the ansoft installetionguides and the documentation that came w ith your computer systemor ask your system administrator for helpsing a Graphical User InterfaceIf you are familiar with the concepts of using a mouse, menus, andother graphical user interface(GUn)tools, skip to Chapter 1“ IntroductionIf you have not used GuI systems before, this section will help youunderstand some of the terminology used in this guide. Since GUIare basically visual, the best way to learn to use them is by practicingon your systemMost gui systcms usc a mouseas a poinTing device, with whichyou can select areas on the screenfor command execution andmoving from one program toanother. Your mouse may have 2www.door 3 buttons; Maxwell 3D ignoresthe middle button on 3-buttondelsAnsoft products donot usc this button. You canprogram mouse buttons to work in non-standard ways, as you mightwant to if you are left-handed. For simplicity, the left-hand hutton(under your forefinger if you are right-handed) is called the leftbutton, and the one on far right is the right mouse button. You willprobably find the terms intuitive once you use these buttons a fewtimesPoint and click; Right clickTo choose an item with the mouse, first move it on your desk until thearrow cursor is on that item; you are now pointing" at the item. Next,ress and release the left bu tton thlled"clicking " Point-andclick is the most common action you will make with your mouseally, click" refers to a lefise button clickYou can sometimes use your right mouse button to access or entercommands. In the 3d Modeler for instance, a right mouse buttonclick causes a short menu of commands to appear at the moustcursor. Generally, right click "refers to a right mouse button clickDouble-ClickOccasionally you may want to sclect all of thc text in a box,orperform a special lask(such as indicating the end of drawing a linewhile you are using Maxwell 3D. You can do this efficiently byquickly clicking twice with your left mouse button -a doubleDragging objects; Click and HoldWhen you are drawing in the 3D Modeler, you can often use yourmouse to enter objects and move around the screen. Frequently, youwill click the mouse button and hold it down until the next part of thecommand is reached (the object is oved, the next point is enteredand so forth). If you click and hold on the edge of a w indow, you canposition, or drag, the window on your screen. You can often dragobjects in Maxwell; experiment to see w hat will moveTool BarsTool bars are shortcut methods for entering commands. There is atool bar in the 3d Modeler and most of the setup modules for severalcommand s. To use a tool bar. click the mouse cursor on the buttonyou want to use. Here is an example of a tool bar囗。圖哦良风≌固函MenusWithin each screen of maxwell 3d are areas w hich list subsets ormenus,of commands. You can access a menu by clicking your mouseon the word or button that indicates the menu. The menu is pulleddown, listing the commands available on that menu. (For examplethc New command is availablc on the File mcnu. Usually, thc mcnuwill remain displayed until you choose a command, or click on thedesktop to exit. If the menu does not remain displayed, click and holdthe mouse button, then release the button to make your choiceFile Edit viewNewopenCloseSavectrl+SSave AsImportExportExitctrl+QAn arrow on the right side of a command indicates that there is asubmenu for that command. An ellipsis (. )indicates that a pop-upwindow appears aftcr choosing this commandWhen you are asked to use a menu command, each level is separatedby a"/". Thus, to zoom in on a drawing, you would choose the viewLoom In menu command To open a new file, you would choose File/There are also pop-up menus, which appear when you righL-click ona maxwell modeler window. choose commands from thcsc menus inthe same way as from menu barsFor more information on using GUIs, refer to"User Interface"in theMaxwell Control Panel,s online help systemOther ReferencesFor detailed information on Maxwell 3d commands refer to theonline documentation for the maxwell 3d field simulatorTo start maxwell 3d, you must first access the maxwell controlPanel. for more detailed inform ation on the maxwell control panelcommands, refer to the Maxwell Control Panels online help systemwww.docin.comTable of Contents1. Introduction1-1General Procedure.1-2The Sample Problem1-4Meshes.....,,,,,,,,面2. Create aAccess the maxwell Control Panel·:.·:·甲,,,,,,,,,,2-2Start the Project managerCreate a Project directoryCreate a New project··,···············,·,,,,,,,,,,2-6Enter notes2-73. Draw the model3-1Open the project3-2Start. the 3D Modeler3-3Side window........................snaps3-6Define the problem region: Coordinates and Units ..,...... 3-7Absolute and relative coordinates3-7Grids3-7Zooming in and out of the view window3-9Create the electromagnet3-10Draw the Coil...,,.,..,3-10Draw thc Circlc........,..,...,,,......,..........3-10Create the Cylinder,,3-11Create the hole for the Core3-12Draw the Core·中··············3-13SavingP3-14Create the magnel翻...3-15Draw the magnet3-15Move the magnet3-15Toggle Off the Background..................3-16Create a termini..........,,,,,..,,,,......,,,..3-17Create the Coil terminal..........,,......,,,.,..3-18Define the Problem Region;..,;;“;##.3-20Define the Problem Region .................. 3-21Shading and rendering . ......................................3-22Exit the 3d modeler3-234 Define The problemAccess the Material Manager4-2Exclude the background·····+···,,,,,,,,,,,,,,.4-2Assign Steel to the CoreAssign Copper to the Coil4-3Assign vacuum to the problem Region.......4.......4-3Assign NdFe35 to the Magnet4-3Access the 3D Boundary/Source Manager45assign a current to the coil.....4-6Define the sourceAssigning the Source lo the Termina.........,..,,,,∴4-64-7Check the Direction of the CurrentExit the 3D Boundary/Source Manager4-85. Generate a Solution5-1Setup executive Parameters······5-2Create a Force Setup for the Magnet.5-3Create a Force Setup for the Coil and Core5-3Create a Force Setup for the entire model·········Exiting the Executive Parameters moduleSpecifying Solution Criteria·非5-5Solver type11翻自。■非非首·····:.··.·Magnetic Field SolveResidualSolve for Field and Parameters+++++++++++++++++++++;,+“++Adaptive analysisContents-2
- 2020-11-27下载
- 积分:1
-
信号带宽估计
matlab 代码 信号带宽估计的matlab代码
- 2021-05-06下载
- 积分:1
-
2017年深圳杯建模挑战赛C题决赛论文(独家)
本人2017年入选了深圳杯建模决赛,这是正式答辩时的论文。仅供各位建模的同学学习参考。基于问趣二中的预测结果,计算得出未来十年的总成本数量及各模式下各分项成本(涵盖直接业务成本、经济技术成本、问接的当下和远期社会成本)比例,分析其变化趋势,并通过作图直观反映。考虑到目前深圳已经开始建立生活垃吸强制分类制度,本文详细分析了家庭分类与专业分类两种前端分流模式对总成本的影响。问题三的分析基于较为完善的模型,对远期效益成木比进行估算,从深圳市具休情况岀发,设计一套生活垃圾处理的优选模式,以供参考。符号说明变量含义生活垃圾处理社会总成本直接成本直接业务成本收集成本第种收集方式的成本第种收集方式中的第种成本运输成木第种运输方式的成本第种运输方式中的第种成本处理成本第种处理方式成本绎济技术成本固定成本第种固定成本可变成本第种可变成本税收减免第种税收减免间接的当下和远期社会成本,即环境损失成本第种环境损失成本年度垃圾处理量湿垃圾占垃圾总量的比例垃圾分类中的干垃圾总量垃圾分类中的湿垃圾总量模型假设假设在估算时间内国家及深圳市相关政策不变。假设在估算时间内折现※为假设在佔算时间内政府对源头分类的补贴保持不变倀设在估算时间内填埋、焚烧、生物处理三种方式下的基准地价的季度增长率分别为模型建立与求解问题一的模型建立模型的准备针对问题一,将生活垃圾处理的社会总成本分为直接业务成本、经济技术成本、问接的当下和远期社会成本,如图生活垃圾处理社会总成本直接业务成本D经济技术成本E间接的当下和远期社会成本图生活垃圾处理社会总成本构成直接业务成本分析在直接业务成木中,我们又将其细化分成了垃圾收集成木、运输成木和处理成本三个部分,如图直接业务成本D收集成本D处理成本D匚运输成本D图直接业务成本构成4()收集成本分析由附件一可知,在不同的垃圾处理模式中,收集方式分别对应混合收集、源头分类收集和混合收集末端分类。即收集成本可划分为混合收集成本源头分类收集成本及混合收集木端分类成本而且每一种收集方式的成本又涵盖了公用垃圾桶成本(分别对应)和运输成本(分别对应),值得注意的是,源头分类收集方式会有额外的政府补贴,而混合收集末端分类方式在末端分类时会占用额外的土地、人力、设备等,因此会产生额外的成本和,如图收集成本De混合收集源头分类成本收集成本集,末端分类成本D公用福政府Dcg成本图收集成本构成()运输成本分析运输成本分为混合运输成本和分类运输成本两类,其中每一种运输成本都包括转运站成本(表示从各公用桶运输到转运站进行进一步处理所需成本,分别对应)和运输成本(分别对应),如图:运输成本Dt混合分类运输运输成本成本转运站成运输站成运输本成本DtD图运输成本构成5()处理成本分析由于处理模式的不同,处理成本可分为焚烧处理成本、填埋处理成本以及生物处理成本,如图处理成本D。焚烧填埋生物处理处理处理成本成本成本DstD图处理成本构成经济技术成本分析经济技术成本包括固定成本、可变成本和税收减免。固定成本分为土地成本和建设成本可变成本包括飞灰补贴、底灰补贴电价补贴、渗沥液补贴以及其他补贴;税收减笕分为増值税减笕、营业税减免和企业所得税减免,如图:经济技术成本E税收减免可变成本定成本E稅减税减税减其他补赎二c5EC2填埋场生物处理厂图经济技术成本构成间接的当下和远期社会成本分析问接的当下和远期成本涵盖了由于环保标准提高所花费的成本、水污染造成的损失、大气污染造成的损失以及固体废弁物污染造成的损失如图6问接的当下和远期社会成本L水污染损失气污染固体废物污染损失L4业损幻1匚人体健康损失[林损头「其他损类图间接的当下和远期社会成本构成模型的建立考虑到不同情况下,决策者会选择不同的模式组合方式。因此,在计算社会总成本时,本文选用各个模式下不同环节所需成本的叠加,从而求得深圳市生活垃圾处理的社会总成木。直接业务成本的计算直接业务成本包括收集成本、运输成本、处理成本直接业务成本的计算公式为:()收集成本的计算公式为=∑∑++代表混合收集成本,代表源头分类收集成本,代表源头混合收集,末端分类成木;代表第种收集方式的公用桶成木,代表第种收集方式的运输成本,代表单位垃圾消耗的公用桶成本,代表生活垃圾年产量,此成本仅包括垃圾桶至小型转运站的成本,如果决策者选择源头混合收集,末端分类方式收集垃圾,则应该加上额外的土地、设各、人工等成本(后面统称为额外成本),如果选择源头分类,则应加上政府补贴;代表单位吨数单位公里运输价格(是一个与距离有关的分段函数),代表距离;代表单位湿垃圾政府补贴成木;代表单位土地、设备、人工等的成木代表湿垃圾占总垃圾量的比重。()运输成本包括混合运输成本、分类运输成本运输成本的计算公式为7代表第种运输方式的转运站成本,包括转运站人工费,以及设备维护费等,代表第科运输方式的运输成本,此成本仅包括小型转运站至末端垃圾处理站的成本,代表单位转运站成本。()处理成本包括焚烧成本、填埋成本和生物处理成本处理成木的计算公式为代表单位垃圾焚烧处理成本;代表单位垃圾填埋处理成木;代表单位垃圾生物处理成本。经济技术成本的计算经济技术成本包括固定成本、可变成本、税收减免经济技术成木的计算公式为固定成本包括焚烧垃圾的十地成本、填埋的十地成本、建设成木。固定成木的计算公式为:代表当年地价,代表十地面积,代表折现率,代表工业用地年;十地机会成本为;代表年地价,代表季度地价增长率,代表时间:代表填哩高度;ρ代表填埋密度代表十地机会成本;代表建设补贴。可变成本包括飞灰补贴、底灰补贴、电价补贴渗沥液补可变成本的计算公式为8=代表单位底灰处理补贴,代表底灰量,代表单位飞灰处理补贴,代表K灰量;代表上网电价补贴,代表超额供电补贴;代表单位污水处理补贴,代表污水处理量税收减免包括增值税减免、营业税减免企业所得税减免税收减免的计算公式为:间接的当下和远期社会成本的计算间接的当下和远期社会成本包括环保标准提高后所需成本(远期环境标准提髙后垃圾处理费升高所需成本)、水污染导致的健康损失、空气污染健康损失、固体废弃物污染损失。水污染导致的健康损失包括早逝引起的健康损失、疾病治疗费用和误工损失;由于垃圾厂排放的气休中对人体造成巨大损失的气体为二嵁英,故将空气污染健康损失考虑为二嗯英造成的健康损失;在计算固休废弃物污染时,采用市场价值法对生活垃圾固休废弃物造成的人工管理费、设备费和运输费等费用进行计算不管对生活垃圾使用哪种处理方式,在计算生活垃圾堆存造成的经济损失时,以需按填埋量来进行计算间接的当下和远期社会成本为:∑∑总数总数指标评价和危险特征阐述,结合国际组织的研究成果,对水污染健康损伤的不良影响进行定量评{,代表年人均收入,代表就诊人数,代表人均治疗费用,代表日均收入,代表住院病例,代表每患病者入住天数;代表不同浓度区域的编码,代表不同浓度区域的二惡英致癌风险代表每平方公里人口密度,代表不同浓度区域所占的面积,代表个体生命价值代表治疗费用;代表生活垃圾堆存损失系数,代表生活垃圾堆存量。综上,由上述各式可得生活垃圾的社会总成本为:+十问题二模型建立及解决各模式的直接成本估算方案完善深圳市生活垃圾直接成木包括直接业务成木和经济技术成木,由式()至式()可知,城市生活垃圾直接成本为:当期社会总成本估算由已知数据代入问题一模型中可知年的社会总成本为:+十元日前仅得到年深圳市生活垃圾年产量数据,如图:s0047544069406图年深圳市生活垃圾年产量无法直接计算出当期以及未来十年各模式下直接成本,故基于灰色预测方法,根捃此数据,估算得出年的生活垃圾年产量如表
- 2020-12-05下载
- 积分:1
-
three.js+objLoader.js源码包,内含测试3D建模
html加载3d建模,包含three.js+OBJLoader.js的组合使用demo
- 2020-12-05下载
- 积分:1
-
LeetCode cpp最新中文题解.pdf
LeetCode cpp最新中文题解.pdfLeetCode cpp最新中文题解.pdfLeetCode cpp最新中文题解.pdf目录3.4 Add binary615.1.5 Binary Tree Level Or-3.5 Longest Palindromic Substring. 62der traversal il3.6 Regular Expression Matching665.1.6 Binary Tree Zigzag3.7 Wildcard Matching67Level Order traversal. 963.8 Longest Common Prefix5.1.7 Recover Binary Search3. 9 Valid Number70Tree983.10 Integer to roman725. 1. 8 Same Tree3. 11 Roman to Integer735.1.9 Symmetric Tree1003.12 Count and Say745.1.10 Balanced Binary Tree.. 1023. 13 Anagrams755.1.11 Flatten Binary Tree to3. 14 Simplify Path76Linked List1033. 15 Length of Last Word775.1. 12 Populating Next RightPointers in each node ii 105第4章栈和队列7952二叉树的构建10641栈795.2.1 Construct Binary Tree4Valid Parentheses79from Preorder and In4.1.2 Longest valid Parenorder Traversa106theses805.2.2 Construct Binary Tree4.1.3 Largest Rectangle infrom Inorder and posHistogram82torder Traversal1074.1.4 Evaluate reverse pol-53二叉查找树108ish notation845.3. 1 Unique Binary Search4.2队列85Trees.1085.3.2 Unique Binary Search第5章树86Trees li.1105.1二叉树的遍历865.3.3 Validate Binary Search5.1.1 Binary Tree PreorderTreeTraversal865.3. 4 Convert Sorted array to5.1.2 Binary Tree InorderBinary Search Tree...112Traversal885.3.5 Convert Sorted List to5.1. 3 Binary Tree PostorderBinary Search Tree113Traversal9054二叉树的递归.1145. 1. 4 Binary Tree Level Or5.4.1 Minimum Depth of Bider traversal)2nary lree115目录5.4.2 Maximum Depth of Bi8.3.,2重新实现 next permunary Tree116tation1425.4.3 Path Sum11783.3递归.1435.4 4 Path Sum il118 8.4 Permutations II1445.4.5 Binary Tree Maximum8.4.1 next permutation... 144Path Suum11984.2重新实现 next permu5.4.6 Populating Next Righttation144Pointers in each node 120843递归1445.4.7 Sum Root to Leaf num8.5 Combinations146bers2185.1递归1468.5.2迭代147第6章排序1238.6 Letter Combinations of a phone6.1 Merge Sorted Array123umber1476.2 Merge Two Sorted Lists12486.1递归1486.3 Merge k Sorted Lists124862迭代96.4 Insertion Sort List125第9章广度优先搜索1506.5 Sort list1269.1 Word Ladder1506.6 First Missing Positive1279.2 Word Ladder il1546.7 Sort Colors1289.3 Surrounded regions162第7章查找94小结16413194.l适用场景1647.1 Search for a range131942思考的步骤7.2 Search Insert Position.13294.3代码模板1657. 3 Search a 2D Matrix133第10章深度优先搜索173第8章暴力枚举法13510.1 Palindrome Partitioning1738.1 Subsets13510.2 Unique Paths1768.1.1递归1350.2.1深搜1768.1.2迭代.1371022备忘录法.1768.2 Subsets il13810.23动规177821递归13810.24数学公式1788.2.2迭代.14110.3 Unique Paths Il1798. 3 Permutations14210.3.1备忘录法1798.3.1 next permutation14210.3.2动规.180目录10.4 N-Queens1813.4 Maximal rectangle21310.5 N-Queens II18413.5 Best Time to Buy and Sell Stock10.6 Restore ip addresses186.21410.7 Combination Sum18813.6 Interleaving String21510.8 Combination Sum Il18913.7 Scramble String21710.9 Generate Parentheses.19013. 8 Minimum Path Sum.22210.10 Sudoku solver19213.9 Edit Distance22410.11 Word Search.19313. 10 Decode Ways.22610.12小结19513. 11 Distinct sub22710.12.1适用场景19513. 12 Word Break22810.122思考的步骤19513 13 Word Break il2300.12.3代码模板197第14章图23210.12.4深搜与回溯法的区別.19714. 1 Clone Graph23210.12.5深搜与递归的区别..197第15章细节实现题235第11章分治法19915.1 Reverse Integer2351.1 Pow(x, n)19915.2 Palindrome Number.23611. 2 Sqrt(x)20015.3 Insert Interval237第12章贪心法20115.4 Merge Intervals23812.1 Jump game20115.5 Minimum Window Substring23912.2 Jump game II15.6 Multiply Strings24112. 3 Best Time to buy and Sell stock 20415.7 Substring with Concatenation12. 4 Best Time to buy and sell stock l205of all words24412. 5 Longest Substring Without re15.8 Pascal,s Triangle245peating Characters20615.9 Pascals Triangle Il24612.6 Container with Most Water.. 207 15.10 Spiral Matrix24715.11 Spiral matrix II248第13章动态规划20915.12 ZigZag Conversion25013. 1 Triangle20915.13 Divide Two Integers25113.2 Maximum Subarray15. 14 Text Justification25313.3 Palindrome Partitioning II1215.15 Max Points on a line255目录第1章编程技巧在判断两个浮点数a和b是否相等时,不要用a==b,应该判断二者之差的绝对值fabs(a-b)是否小于某个阈值,例如1e-9。判断一个整数是否是为奇数,用x%2!=0,不要用x%2=1,因为ⅹ可能是负用char的值作为数组下标(例如,统计字符串中每个字符岀现的次数),要考虑到char可能是负数。有的人考虑到了,先强制转型为 unsigned int再用作下标,这仍然是错的。正确的做法是,先强制转型为 unsigned char,再用作下标。这涉及C十整型提升的规则,就不详述了。以下是关于STL使用技巧的,很多条款来自《 Effective STL》这本书。vector和 string优先于动态分配的数组首先,在性能上,由于 vector能够保证连续内存,因此一旦分配了后,它的性能跟原始数组相当;其次,如果用new,意味着你要确保后面进行孓 delete,一旦忘记了,就会出现BUG,且这样需要都写一行 delete,代码不够短再次,声明多维数组的话,只能一个一个new,例如int** ary = new int*[row_num];for(int i=0: i< row num; ++1)ary [i] new int [col_num]用 vector的话一行代码搞定vectorary(row_num, vector(col_num, 0))使用 reserve来避免不必要的重新分配第2章线性表这类题目考察线性表的操作,例如,数组,单链表,双向链表等。2数组2.1.1 Remove Duplicates from Sorted array描述Given a sorted array, remove the duplicates in place such that each element appear only onceand return the new lengthDo not allocate extra space for another array, you must do this in place with constant memoryFor example, Given input array A =[1, 1, 2Your function should return length =2, and a is now [1, 2]分析无代码1/ LeetCode, Remove Duplicates from Sorted Array//时间复杂度0(n),空间复杂度0(1)class Solution tublicint removeDuplicates(vector& nums)tif (nums empty o) return 0;int index =ofor (int i =1: i nums size: 1++ iif (nums [index] ! nums [i])nums [++index]= nums [i]return index 12.1数组代码2//LeetCode, Remove Duplicates from Sorted Array/使用STL,时间复杂度0(n),空间复杂度0(1)class Solution ipublicint removeDuplicates(vector& nums)treturn distance(nums begin(), unique(nums begin(), nums end ())代码3/ LeetCode, Remove Duplicates from Sorted Array/使用STL,时间复杂度0(n),空间复杂度0(1)lass Solution fublicint removeDuplicates(vector& nums)treturn distance(nums begin(, removeDuplicates(nums begin(, nums end(), nums begintemplateOutIt removeDuplicates(InIt first, InIt last, OutIt output)thile (first last)i*output++ = *firstfirst upper_bound(first, last, *firstreturn output相关题目Remove Duplicates from Sorted Array I,见§2.1.22.1.2 Remove Duplicates from Sorted Array II描述Follow up for"Remove Duplicates " What if duplicates are allowed at most twice?For example, Given sorted array a =[1, 1, 1, 2, 2, 3]Your function should return length=5, and A is now [1, 1, 2, 2, 3分析加一个变量记录一下元素出现的次数即可。这题因为是已经排序的数组,所以一个变量即可解决。如果是没有排序的数组,则需要引入一个 hashmap来记录出现次数。4第2章线性表代码1// Leet Code, Remove Duplicates from Sorted Array II//时间复杂度0(n),空间复杂度0(1)//qauthorhex108(https://github.com/hex108)class Solution tublicint removeDuplicates(vector& nums)tif (nums size(
- 2020-12-04下载
- 积分:1