From 8d5d33e61ecc23603bc053271d9e122b22492827 Mon Sep 17 00:00:00 2001 From: CyC2018 <1029579233@qq.com> Date: Sat, 31 Mar 2018 11:47:51 +0800 Subject: [PATCH] auto commit --- notes/剑指 offer 题解.md | 6 ++++-- pics/004edd56-1546-4052-a7f9-a9f7895ccec5.png | Bin 0 -> 4096 bytes pics/c47f333d-75d1-4ff8-8e82-4533a4ba6a6c.png | Bin 0 -> 5120 bytes pics/d99dc9e2-197c-4085-813d-7195da1c6762.png | Bin 0 -> 3072 bytes 4 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 pics/004edd56-1546-4052-a7f9-a9f7895ccec5.png create mode 100644 pics/c47f333d-75d1-4ff8-8e82-4533a4ba6a6c.png create mode 100644 pics/d99dc9e2-197c-4085-813d-7195da1c6762.png diff --git a/notes/剑指 offer 题解.md b/notes/剑指 offer 题解.md index 6ed4f0a3..4568effd 100644 --- a/notes/剑指 offer 题解.md +++ b/notes/剑指 offer 题解.md @@ -217,6 +217,8 @@ public String replaceSpace(StringBuffer str) { 输入链表的第一个节点,从尾到头反过来打印出每个结点的值。 +

+ ## 解题思路 ### 使用栈 @@ -795,11 +797,11 @@ private void printNumber(char[] number) { ① 如果该节点不是尾节点,那么可以直接将下一个节点的值赋给该节点,令该节点指向下下个节点,然后删除下一个节点,时间复杂度为 O(1)。 -

+

② 否则,就需要先遍历链表,找到节点的前一个节点,然后让前一个节点指向 null,时间复杂度为 O(N)。 -

+

综上,如果进行 N 次操作,那么大约需要操作节点的次数为 N-1+N=2N-1,其中 N-1 表示 N-1 个不是尾节点的每个节点以 O(1) 的时间复杂度操作节点的总次数,N 表示 1 个为节点以 O(n) 的时间复杂度操作节点的总次数。(2N-1)/N \~ 2,因此该算法的平均时间复杂度为 O(1)。 diff --git a/pics/004edd56-1546-4052-a7f9-a9f7895ccec5.png b/pics/004edd56-1546-4052-a7f9-a9f7895ccec5.png new file mode 100644 index 0000000000000000000000000000000000000000..539a6c2262dbd86588da6879a42e6435e2b6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ko^;`zZDJ?APKx(`N>GtslahIZ4cRGLJ4Xq+zL zwa`Ao!g`UzW{=jn?=nJ-dd9*EzThAT46C9=wQqKW5Yd90DlSo#Gy_G>sh7AbYP>hC5<>9h~m5_wCAF*QJ|@?UE=@2O8Vbi sc($Uh_ELOi8ayWGTRsVn0|6le0|Dpc>1BKV0`~Uy| literal 0 HcmV?d00001 diff --git a/pics/d99dc9e2-197c-4085-813d-7195da1c6762.png b/pics/d99dc9e2-197c-4085-813d-7195da1c6762.png new file mode 100644 index 0000000000000000000000000000000000000000..a2c04eba924fb8d11d077c2450b763aa35214c54 GIT binary patch literal 3072 zcmeH}dr(t%7RQ6A0g)is6{&{k0;Mpvbd{Hai3BY27FIp`p13z?(fX+ z{O&pD`#Ha?gZ`d|>ponE!C(x%4tNA%FgoYZ_Zq#m=shsfen0xqNeuENV|ZO#$I-#+ z2sb}B45pf8uykS#I@XUra4Zpn!985QbXwyoPNLtuygb|vrBSD3)lrAX2(7bn!pWT{ zH`G(crH3#7x!9oF&1qLfsNz4uB<1cSftZkf2$btnl$C3u5>$(zG+!@1vGlpk9K?Q-!N$*RH!X@wBp|_DJvo=N65IEsirM1gP4IMBvhr@AjTx+QnE63IJ^Z?l zB&Sa{ls}NFA_~Bw^$hjyZlRoM9GhzYwOvb@K9b(E_LMDmMv{3e=p0s-L_2@yLs;{o z@hpG0v-3hLB|dDb!ax`dDXbygu0!r}PBX~D=gybJ)8o?m!!(L$Z&1zO0b8ZsPs@&J z3sz3)A*+3DAlZO}- zAjcTi-vB2>q^8z>0h$8e-F}VQJxB6!44@pU;&o>*n-Ub^mGy~Z{)uU6N0)x`BfWJW zESd@U#Q50APkyGV>R1_cM{UF2uCjtQZi5uF)l$0_VO1}#fwIb7v?qk^r;psLQx!aa zQY%Lms8XLvU(k9V*cWyTBz>R~nYbKnJk`UQ-(#3;R5vOGCYXOIBL*~39I|`X0{z2% ze?l`w7Mo8cvpd5(5w&Ven+w@`Pu>J%rV-v;n$CA}V?d--df!F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