当前位置:网站首页>LeetCode-1528-重新排列字符串-哈希表-字符串
LeetCode-1528-重新排列字符串-哈希表-字符串
2022-06-25 22:01:00 【李烦烦搞快点】
Note:
开个哈希表记录下每个数字对应的字母,然后从0开始把字符串复原出来即可,O(N)复杂度
代码如下:
class Solution {
public:
string restoreString(string s, vector<int>& indices) {
unordered_map<int, char> hash;
string ans;
for(int i = 0; i < indices.size(); i ++)
hash[indices[i]] = s[i];
for(int i = 0; i < indices.size(); i ++)
ans += hash[i];
return ans;
}
};
边栏推荐
- 首个大众可用PyTorch版AlphaFold2复现,哥大开源OpenFold,star量破千
- The first public available pytorch version alphafold2 is reproduced, and Columbia University is open source openfold, with more than 1000 stars
- Recently prepared to translate foreign high-quality articles
- hiberate实体类CURD、事务操作汇总
- pdm的皮毛
- 做接口测试,这3种工具到底什么时候用?
- CTS RTS RX TX in serial port flow control UART (direct communication between serial port module and MCU)
- 为什么OpenCV计算的帧率是错误的?
- Comp212 distributed protocol
- 【无标题】打开一个项目连接,无法正常显示时,ping一下ip
猜你喜欢

多台云服务器的 Kubernetes 集群搭建

Pycharm student's qualification expires, prompting no suitable licenses associated with account solution

STM32开发板+机智云AIoT+家庭监测控制系统

Use and difference between ue4\ue5 blueprint node delay and retroggable delay

【opencv450-samples】inpaint 使用区域邻域恢复图像中的选定区域

UE4 学习记录二 给角色添加骨架,皮肤,及运动动画

剑指 Offer 46. 把数字翻译成字符串(DP)

Ble Low Power Bluetooth networking process and Bluetooth role introduction

Set up your own website (15)

Rk3568+ Hongmeng industrial control board industrial gateway video gateway solution
随机推荐
[opencv450 samples] read the image path list and maintain the proportional display
记录一下Qt将少量图片输出为MP4的思路及注意事项
Basic operator
Leetcode(605)——种花问题
golang Make a list of intervals with sequential numbers
CDN加速是什么
qtcreator 格式化代码
How to solve the problem of SQL?
转载: QTableWidget详解(样式、右键菜单、表头塌陷、多选等)
String对象(常量)池
My vscode
Windows安装Redis及简单使用
#23class介绍
Live800 online customer service system: do business across time and space, starting from each interaction
Oracle - data query
#24class静态成员
Qt Utf8 与 Unicode 编码的互相转换, Unicode编码输出为格式为 &#xXXXX
Problem recording and thinking
2. What is the geometric meaning of a vector multiplying its transpose?
【AXI】解读AXI协议乱序机制
