Iam using two loops and an additional array to keep track of the strings that are already encountered along with their last position…dunno where I’am missing…pls help
Okay, I could not see your Solution, but here is my Logic, if you are familiar with the Collection Package of java.util, it is a cakewalk for you, and incase you dont know this, you have to apply serious logic.
Just Use a HashMap < String,Integer > to store the votes corresponding to a USER-Id.
And then sum all the votes.
Here is my solution. Solution
if you dont want to use collection then here is my solution :-https://www.codechef.com/viewsolution/6606934
first input string then search if this string already exist in string array then update sign(+,-) if + then +1 if - then -1 in array
if string not exist(in case of new vote) then insert the name at last and store the sign(+,-) +1 for + and -1 for -
and finally count
Your link is broken brother. please correct it.
link is not working may be your solution is private please correct it
the solution link is still broken.
posting question for the first time…hope now it works
This one is better…But i was trying to solve without hashmap…thanks
sb is our string array in which we are storing every new name
and a is integer array that stores +1 and -1 according to last vote of that person
i hope it was easy if you have any doubt then ask
It really helped…trying to implement…thanks
ha ha ha
well till now i never used collection library in any of my 300+ submission
but i use hash map concept manually for less execution time