S and T are strings composed of lowercase letters. In S, no letter occurs more than once.

S was sorted in some custom order previously. We want to permute the characters of T so that they match the order that S was sorted. More specifically, if x occurs before y in S, then x should occur before y in the returned string.

Return any permutation of T (as a string) that satisfies this property.

Example :
Input:
S = "cba"
T = "abcd"
Output: "cbad"
Explanation:
"a", "b", "c" appear in S, so the order of "a", "b", "c" should be "c", "b", and "a".
Since "d" does not appear in S, it can be at any position in T. "dcba", "cdba", "cbda" are also valid outputs.

Note:

  • S has length at most 26, and no character is repeated in S.
  • T has length at most 200.
  • S and T consist of lowercase letters only.

题目

思路

代码

[leetcode]791. Custom Sort String自定义排序字符串的更多相关文章

  1. [LeetCode] Custom Sort String 自定义排序的字符串

    S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sort ...

  2. LeetCode 791. Custom Sort String

    题目链接:https://leetcode.com/problems/custom-sort-string/description/ S and T are strings composed of l ...

  3. 791. Custom Sort String - LeetCode

    Question 791. Custom Sort String Solution 题目大意:给你字符的顺序,让你排序另一个字符串. 思路: 输入参数如下: S = "cba" T ...

  4. 【LeetCode】791. Custom Sort String 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 按顺序构造字符串 排序 日期 题目地址:https: ...

  5. 791. Custom Sort String字符串保持字母一样,位置可以变

    [抄题]: S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S wa ...

  6. 791. Custom Sort String

    S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sort ...

  7. Arrays.sort(a) 自定义排序

     Arrays.sort(a) 自定义排序,(需实现接口:Comparable) package com.hd; import java.util.Arrays; class Person imple ...

  8. [LeetCode] 324. Wiggle Sort II 摆动排序 II

    Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]... ...

  9. [Swift]LeetCode791. 自定义字符串排序 | Custom Sort String

    S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sort ...

随机推荐

  1. Emac

    https://emacs-china.org/ 启动 console模式的emacs,$emacs -nw 学习参考: 1)<21天精通emacs> 2)Emacs常用命令简集. 3)& ...

  2. Dos命令快速设置ip、网关、dns地址

    netsh interface ip set address name="本地连接" source=static 192.168.1.8 255.255.255.0 192.168 ...

  3. ArcGIS案例学习笔记4_1_矢量校正

    ArcGIS案例学习笔记4_1_矢量校正 概述 计划时间:第四天上午 教程:Editing编辑教程 pdf 目的:矢量数据的空间校正 案例1:仿射变换 数据:Editing编辑数据/spatialAd ...

  4. java axis2 webservice

    http://clq9761.iteye.com/blog/976029/ 这篇文章写的是最全的,也是最好的.无须下一步下一步操作来操作去,写类直接调试,非常好!

  5. Resize CentOS Linux hard drive partition (centos 6.3 调整LVS磁盘大小)

    查看当前磁盘信息: [root@localhost ~]# df -h 文件系统          容量  已用  可用 已用%% 挂载点/dev/mapper/VolGroup-lv_root    ...

  6. TMG2010安装配置细节设定

    TMG2010最适合的操作系统是Win2008R2,不支持Win2012,可能是因为发布Win2012系统时,微软已经决定废弃TMG改为支持UAG了吧. 在Win2012下安装TMG2010,运行TM ...

  7. you-get

    1.打开cmd,输入命令并执行 pip3 install you-get 2.输入命令,检测 You-Get 是否安装成功 you-get 3.开始下载吧 you-get [视频地址]you-get ...

  8. 判断用户 是用的电脑还是手机 判断 是安卓还是IOS

    $(function(){ var Terminal = { // 辨别移动终端类型 platform: function () { var u = navigator.userAgent, app ...

  9. php mysql 查询判断周几

    $where .= " and (DAYOFWEEK( from_unixtime(`px_time`, '%Y-%m-%d')) = 1)";  //周日从1开始

  10. 安装三代组装canu、smartdenovo、wtdbg及矫正软件Racon、Nanopolish的安装

    1)三代组装软件 ------------------------------------------------------------------canu--------------------- ...