### wronganswer.5's blog

By wronganswer.5, history, 5 months ago,

You are given a list of videos. Each video carry two information- Hashtags attached to it, timestamp of the video. For each video, another video is found related to it if the video is released earlier and carries atleast one common hashtag. Output the number of related videos for each video.

Input- V1: {[#shorts , #gym] , 1} V2: {[#shorts , #cars, #halloween] , 5} V2: {[#truck , #automobile, #shorts] , 10} V3: {[#dance] , 15}

Output: [0,1,2,0]

Explanation- No video is released before V1. V2 one video is released before V2, which is V1 at timestamp 1 second and has a common hashtag- shorts. Similarly for V3, V1 and V2 both are related as they share #shorts as common hashtag and V1 and V2 are released earlier. For V3, no releated video is found.

The number of videos can be in millions so think of the most optimum approach.

• +3

By wronganswer.5, history, 7 months ago,

I have been trying to solve the problem WITTYBOY on SPOJ but not able to solve it. Please share the approach to solve this problem.

Here is the link of the problem : LINK TO PROBLEM

Thanks in advance.

• 0

By wronganswer.5, history, 8 months ago,

I am facing difficulties in writing recursive bitmask dp approach to the question Elevator Rides.

Here is the link to the task : LINK

Any help is appreciated. Thanks.

• 0

By wronganswer.5, history, 8 months ago,

You are given a number A, convert A to number D by following steps.

Convert A to basic form B Basic form contains exactly single occurence of all prime factors of A. eg. if A=12 -> (2 x 2 x 3) then B = 2x3 = 6 if A=120, then B=2x3x5=30 After converting into basic number, then multiply all it's divisors to get a number C.

Count the number of divisors of C, you get your final answer which is D.

Find D and print is module 1e9+7

Constraints: 2<=A<=10^15

Sample input: 12 Sample output: 9

Explanation: A = 2 x 2 x 3 hence basic form B = 2 x 3 = 6

The divisors of B are 1, 2, 3, 4. Hence C = 1 x 2 x 3 x 6 = 36

The divisors of C are 1, 2, 3, 4, 6, 9, 12, 18, 36. Therefore the D or the count of divisors of C is 9

Sample Input: 71 Sample Output: 2

I calculated prime numbers and divisors in O(sqrt(N)) each but my soln only passed 5/10 test cases. How to solve this question?

Thanks in advance.

• +5

By wronganswer.5, history, 8 months ago,

This question was asked was in an OA. I was not able to sovle it fully i.e my soln got partially accepted.

Code

I want to solve this problem via memorization as I am not so good at writing bottom-up approach directly.

I took 5 states-> X and Y coordinates of alice and bob and index of the corr(array of position of apples). How to optimize states?

Thanks in advance.

• +4

By wronganswer.5, history, 11 months ago,

You are given a string s. You are allowed to do following operation any number of times: choose two characters in s say c1 and c2, replace all the occurences of c1 with c2 and all the occurences of c2 with c1. You want to make it lexographically smallest.

eg: s="bbcacad" ans: "aabbccd"

step1: choose a and b, we get -> aacbcbd step2: choose b and, we get -> aabcbcd

eg2: s="bdea" ans: "abde"

How to solve this question?

• -9