Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2850875

Browse files
Create 11-03-2024.cpp
1 parent 7fba646 commit 2850875

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

‎2024/03 - March/11-03-2024.cpp‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
Author : Saransh Bangar
3+
Date : 11/03/2024
4+
Problem : Custom Sort String
5+
Difficulty : Medium
6+
Problem Link : https://leetcode.com/problems/custom-sort-string/description/
7+
Video Solution : NA
8+
*/
9+
10+
11+
class Solution {
12+
public:
13+
string customSortString(string order, string s)
14+
{
15+
unordered_map<char, int>map;
16+
for (int i=0;i<order.length();i++)
17+
map[order[i]] = i;
18+
auto customSort = [&](char a, char b)
19+
{
20+
return map[a]<map[b];
21+
};
22+
sort(s.begin(), s.end(), customSort);
23+
return s;
24+
}
25+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /