relifs>0:\rj-=1\rwhilei<jandnums[j]==nums[j+1]:j-=1\relse:\rres.append([nums[k],nums[i],nums[j]])\ri+=1\rj-=1\rwhilei<jandnums[i]==nums[i-1]:i+=1\rwhilei<jandnums[j]==nums[j+1]:j-=1\rreturnres\r21.èéꨩë"_5ìÕë$EvaluationWarning:ThedocumentwascreatedwithSpire.PDFfor.NET.\rZ[\7éꨩë(BinarySearchTree),èí"_`5ìÕë(GreaterTree),L7îï?ðYîïÕñJ\rí\rîï-.\r¤?\r“>”\r¤\?òó\r¤é?ôõ\rõö?\r¤\?\rclassSolution:\rdefconvertBST(self,root:TreeNode)->TreeNode:\rcur=0\rdefdfs(root):\rnonlocalcur\rifnotroot:return\rdfs(root.right)\rcur+=root.val\rroot.val=cur\rdfs(root.left)\rdfs(root)\rreturnroot\r¤é?\rclassSolution:\rdefconvertBST(self,root:TreeNode)->TreeNode:\rcur,stack,p=0,[),root\rwhileporstack:\rwhilep:\rstack.append(p)\rp=p.right\rp=stack.pop()\rcur+=p.val\rp.val=cur\rp=p.left\rreturnroot