文章
73. Set Matrix Zeroes
Givenamxnmatrix,ifanelementis0,setitsentirerowandcolumnto0.Doitinplace.Example1:<pre<codeInput:1,1,1,1,0,1,
60. Permutation Sequence
Theset1,2,3,...,ncontainsatotalofn!uniquepermutations.Bylistingandlabelingallofthepermutationsinorder,wegetthefollowingsequen
81. Search in Rotated Sorted Array II
Supposeanarraysortedinascendingorderisrotatedatsomepivotunknowntoyoubeforehand.(i.e.,0,0,1,2,2,5,6mightbecome2,5,6,0,0,1,2).You
75. Sort Colors
Givenanarraywithnobjectscoloredred,whiteorblue,sorttheminplacesothatobjectsofthesamecolorareadjacent,withthecolorsintheor
PAT A1066
!clipboard.png(/img/bVboeQS?w1466&h653)平衡二叉树AVL,写过总结,这里不再赘述;<pre<codeinclude<iostream>include<stdlib.h>include<stdio.
PAT A1099
!clipboard.png(/img/bVboeIN?w1494&h771)和完全二叉排序树那道题类似,采用的方法还是中序遍历空树填节点的方法;代码如下:<pre<codeinclude<iostream>include<stdlib.h>
79. Word Search
Givena2Dboardandaword,findifthewordexistsinthegrid.Thewordcanbeconstructedfromlettersofsequentiallyadjacentcell,where&34;
PAT A1064
!clipboard.png(/img/bVboeBy?w1496&h633)这道题自己起先想到的思路是根据完全二叉树性质,找出左右子树,递归进行;但是示例给出的思想很值得学习;对于一个二叉搜索树,其中序序列必递增的,所以可以利用这一点;我们先对输入的节点序列进行递增排序,之后我们对
90. Subsets II
Givenacollectionofintegersthatmightcontainduplicates,nums,returnallpossiblesubsets(thepowerset).Note:Thesolutionsetmustnotcontai
时间复杂度与空间复杂度分析
作为开发人员,我们都希望在完成功能的基础上让代码运行的更快、更省空间,那如何衡量编写的代码是否更有效率,这就需要我们学会如何分析代码时间复杂度和空间复杂度.什么是复杂度分析执行时间和占用空间是代码性能的2个评判标准,我们分别用时间复杂度和空间复杂度去描述这2个标准,二者统称复杂度,
已加载文章中没有匹配内容,试试其他关键词或清空搜索。