• 2024-07-19Lexicographically Largest
    看看官方题解,来用“exchangingargument”证明一下假设不选最小的满足条件的\(v\),选了个更大的\(v_1\),那么对于最终的序列如果没有\(a_i+i-v\),那么显然将\(v_1\)换成\(v\)更好,否则的话考虑\(a_j+j-v_j=a_i+i-v(i<j)\),那么如果位置\(j\)可以选出一个\(v^{'}\)使得\(a_j+j-v^{'}=a_
  • 2024-06-17C. Lexicographically Largest
    原题链接题解1.第\(i\)个位置上的数,对\(S\)的贡献最大不会超过\(a_i+i\),我们令其为\(c_i\)2.我们不去细想如何操作才能得到最优解,而是去想第一大的\(b\)是多少?第二大的\(b\)是多少?3.对\(c_i\)降序排序得到\(b_i\),如果所有\(b_i\)都不同,那么直接输出即可。4.但
  • 2023-11-28Make Lexicographically Smallest Array by Swapping Elements
    MakeLexicographicallySmallestArraybySwappingElementsYouaregivena 0-indexed arrayof positive integers nums anda positive integer limit.Inoneoperation,youcanchooseanytwoindices i and j andswap nums[i] and nums[j] if |nums
  • 2023-03-31leetcode-744-easy
    FindSmallestLetterGreaterThanTargetYouaregivenanarrayofcharacterslettersthatissortedinnon-decreasingorder,andacharactertarget.Thereareatleasttwodifferentcharactersinletters.Returnthesmallestcharacterinlettersthatis
  • 2022-11-26C. Almost All Multiples
    C.AlmostAllMultiplesGiventwointegers$n$and$x$,apermutation$^{\dagger}$$p$oflength$n$iscalledfunnyif$p_i$isamultipleof$i$forall$1\l
  • 2022-10-09LeetCode 2434. Using a Robot to Print the Lexicographically Smallest String
    原题链接在这里:https://leetcode.com/problems/using-a-robot-to-print-the-lexicographically-smallest-string/题目:Youaregivenastring s andarobotthatcurr