LeetCode --- 1370. Increasing Decreasing String 解题报告

Posted 杨鑫newlfe

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode --- 1370. Increasing Decreasing String 解题报告相关的知识,希望对你有一定的参考价值。

You are given a string s. Reorder the string using the following algorithm:

  1. Pick the smallest character from s and append it to the result.
  2. Pick the smallest character from s which is greater than the last appended character to the result and append it.
  3. Repeat step 2 until you cannot pick more characters.
  4. Pick the largest character from s and append it to the result.
  5. Pick the largest character from s which is smaller than the last appended character to the result and append it.
  6. Repeat step 5 until you cannot pick more characters.
  7. Repeat the steps from 1 to 6 until you pick all characters from s.

In each step, If the smallest or the largest character appears more than once you can choose any occurrenc

以上是关于LeetCode --- 1370. Increasing Decreasing String 解题报告的主要内容,如果未能解决你的问题,请参考以下文章

算法leetcode|1370. 上升下降字符串(rust很好用)

算法leetcode|1370. 上升下降字符串(rust很好用)

算法leetcode|1370. 上升下降字符串(rust很好用)

leetcode1370之上升下降字符串

leetcode1370之上升下降字符串

JS Leetcode 1370. 上升下降字符串 题解分析,桶排序与charCodeAt fromCharCode妙用