当前位置:网站首页>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;
}
};
边栏推荐
- golang Make a list of intervals with sequential numbers
- 多台云服务器的 Kubernetes 集群搭建
- Qt Utf8 与 Unicode 编码的互相转换, Unicode编码输出为格式为 &#xXXXX
- 记一次beego通过go get命令后找不到bee.exe的坑
- Oracle -- table operation
- Idea auto generator generates constructor get/set methods, etc
- Live800 online customer service system: do business across time and space, starting from each interaction
- Recently prepared to translate foreign high-quality articles
- UE4 学习记录二 给角色添加骨架,皮肤,及运动动画
- OpenJudge NOI 2.1 15:Counterfeit Dollar
猜你喜欢

Xampp重启后,MySQL服务就启动不了。

元宇宙标准论坛成立

Baidu: in 2022, the top ten hot spots will rise and the profession will be released. There is no suspense about the first place!

jdbc常见异常及错误解决办法汇总

Fegin client entry test

24class static member

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

RK3568+鸿蒙工控板工业网关视频网关解决方案

CAD中图纸比较功能怎么用

STM32 development board + smart cloud aiot+ home monitoring and control system
随机推荐
[modulebuilder] GP service realizes the intersection selection of two layers in SDE
hiberate实体类CURD、事务操作汇总
Fegin client entry test
Core points of assembly language
Leetcode(605)——种花问题
[opencv450 samples] inpaint restores the selected region in the image using the region neighborhood
Ue4 Ue5 combine le plug - in de reconnaissance vocale de bureau pour la reconnaissance vocale
String对象(常量)池
Es7/es9 -- new features and regularities
【AXI】解读AXI协议乱序机制
OBS-Studio-27.2.4-Full-Installer-x64.exe 下载
做接口测试,这3种工具到底什么时候用?
UE4_ Ue5 combines the offline voice recognition plug-in for speech recognition
Determine whether the appointment time has expired
毕业旅行 | 伦敦5日游行程推荐
Kubernetes cluster construction of multiple ECS
Idea common plug-ins
UE4_UE5结合offline voice recognition插件做语音识别功能
Somme logarithmique (deux points) pour le Groupe 52 - - e de la course de la lune blanche de niuke
jdbc常见异常及错误解决办法汇总
