当前位置:网站首页>Leetcode-1528- rearrange string - hash table - string
Leetcode-1528- rearrange string - hash table - string
2022-06-25 23:39:00 【Li Fan, hurry up】
Note:
Open a hash table and record the letters corresponding to each number , And then from 0 Start restoring the string ,O(N) Complexity
The code is as follows :
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;
}
};
边栏推荐
- 记一次beego通过go get命令后找不到bee.exe的坑
- Day3 data types and operators summary and job
- Style setting when there is a separator in the qcombobox drop-down menu
- Anaconda一文入门笔记
- Once beego failed to find bee after passing the go get command Exe's pit
- Qt Utf8 与 Unicode 编码的互相转换, Unicode编码输出为格式为 &#xXXXX
- The simplest screen recording to GIF gadget in history, licecap, can be tried if the requirements are not high
- 解决TypeError: Unicode-objects must be encoded before hashing
- Classic image segmentation network: UNET supports libtorch deployment reasoning [with code]
- What is Unified Extensible Firmware Interface (UEFI)?
猜你喜欢

QComboBox下拉菜单中有分隔符Separator时的样式设置

Konva series tutorial 2: drawing graphics

BI-SQL丨存储过程(一)

社招两年半10个公司28轮面试面经(含字节、拼多多、美团、滴滴......)

When are the three tools used for interface testing?

24class static member

UE4 学习记录一 创建角色,并控制其移动

#23class介绍

Use of xinchida ble 5.0 Low Power Bluetooth module (at command serial port transparent transmission) rsbrs02abr

ACM. Hj16 shopping list ●●
随机推荐
Xinchida nd04 nd04c nrf52832 (52810) ble module (low power Bluetooth communication module) at command test
23class introduction
QLabel 文字水平滚动显示
OBS-Studio-27.2.4-Full-Installer-x64. Exe Download
B. Box Fitting-CodeCraft-21 and Codeforces Round #711 (Div. 2)
1.8 billion pixel Mars panorama Ultra HD released by NASA, very shocking
B. Box Fitting-CodeCraft-21 and Codeforces Round #711 (Div. 2)
Hibernate architecture introduction and environment construction (very detailed)
C. Fibonacci Words-April Fools Day Contest 2021
Ble Low Power Bluetooth networking process and Bluetooth role introduction
qtcreator 格式化代码
史上最简单的录屏转gif小工具LICEcap,要求不高可以试试
[Axi] interpretation of Axi protocol disorder mechanism
Pycharm student's qualification expires, prompting no suitable licenses associated with account solution
C. Yet Another Card Deck-Educational Codeforces Round 107 (Rated for Div. 2)
The software test interview has been suspended. The interviewer always says that the logical thinking is chaotic. What should I do?
【2023校招刷题】番外篇1:度量科技FPGA岗(大致解析版)
hiberate实体类CURD、事务操作汇总
jdbc常见异常及错误解决办法汇总
关于go协程超时退出控制条件与方式分析
