SPOJ-INVERSE-SORT

Problem

Algorithm:


We have to generate  10!  combination of "abcdefghij " by reversing and put appropriate distance from "abcdefghij "

So we need key(string)->value  data structure.
First thing comes to our mind is map<string,int>
But it uses O(logN) time to insert a value as everything is ordered here
So we use unordered_map (Normally o(1) highest o(n) barely

After that we take 2 string input and then find the relative string S from s1->s2 and another AC!!


CODE

Time needed 40-45sec.

মন্তব্যসমূহ

এই ব্লগটি থেকে জনপ্রিয় পোস্টগুলি

lightOJ-1072 Calm Down