I have a question
A country has 25 states ( can vary) and based on population of each state give a color to that state.
state1 population is 5000
state2 population is 10000
state3 population is 12000 and so on....
now im also given colors to assign based on population
population==5000 assign green
5000<population<10000 - blue
population==10000 assign orange
10000<population<15000 - yellow and so on up to 100,000 ( this is the max limit of population for a state )
I can give a solution where
Step 1: create a dictionary/hashtable to maintain colors based on population.
Step 2 : Read each country population ( iterate thru countries ) and lookup in hashtable and assign.
the above solution is bruteforce.
I was given a hint to use bitwise operator for this . Any thoughts how I can go about it ?
Open Chat in New Window