Update appNew update is available. Click here to update.
About
A Bachelor’s student at the National Institute of Technology of communication engineering Department. Jealous about software engineering and with experience in C/C++ , algorithms, and ,Problem sol...
Paytm flipkart
National Institute Of Technology, Silchar, Assam 2025
My Stats
EXP gained
yellow-spark
12522
Level
7 (Expert)
Community stats
Discussions
1
Upvotes
1
Know more
Weekend contest rating
Contest attended
Problems solved
2021 2023
Better than %
Weekend contest rating
Contest attended
Problems solved
2021 2023
Better than %
236
Total problems solved
152
Easy
78
Moderate
6
Hard
0
Ninja
Jan Jan Feb Feb Mar Mar Apr Apr May May Jun Jun Jul Jul Aug Aug Sep Sep Oct Oct Nov Nov Dec Dec

Current streak:

0 days

Longest streak:

25 days

Less

More

Achievements
4
Ronin
Topics
Stacks & Queues
Sorting
+ 2 more
3
Samurai
Topics
Arrays
Linked List
Strings
Discussions
hashmap
Interview problems

#include <bits/stdc++.h>  vector<pair<char,int>> duplicate_char(string s, int n){    map<char,int> mp;    for(auto i:s)        mp[i]++;    vector<pair<char,int>> ans;    for(auto i:mp)    {        if(i.second>=2)        {            pair<char,int> p;            p.first=i.first;            p.second=i.second;            ans.push_back(p);        }    }    return ans; }

profile
ECE_067
Published On 27-Oct-2022
512 views
1 replies
0 upvotes
sort
Interview problems

bool comp(vector<int>& v1, vector<int>& v2) {    if(v1[0] != v2[0])    {        return v1[0] > v2[0];    }    else    {        return v1[1] < v2[1];    } }

vector<int> sortByFrequency(vector<int>& nums) {        unordered_map<int, int> d;    unordered_map<int, int> index;        // For each array element, insert into the dictionary its frequency and index of its first occurrence in the array    for(int i = 0; i < nums.size(); i++)    {        d[nums[i]] += 1;        if(index.find(nums[i]) == index.end())        {            index[nums[i]] = i;        }    }

   vector<vector<int>> lst;    for(auto it: d)    {        vector<int> temp;        temp.push_back(it.second);        temp.push_back(index[it.first]);        temp.push_back(it.first);        lst.push_back(temp);    }        // Sort the values based on a custom comparator.    sort(lst.begin(), lst.end(), comp);          // Finally return the sorted list having arranged items.    vector<int> result;    for(int i = 0; i < lst.size(); i++)    {        for(int j = 1; j <= lst[i][0]; j++)        {            result.push_back(lst[i][2]);        }    }

   return result;  }

profile
ECE_067
Published On 31-Oct-2022
357 views
0 replies
0 upvotes