Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is a list of all the phone numbers available for country codes on Wikipedia. It is here</p> <p><a href="http://en.wikipedia.org/wiki/List_of_country_calling_codes" rel="nofollow">http://en.wikipedia.org/wiki/List_of_country_calling_codes</a></p> <p>I would create two hashmaps. One with all the four digit codes and one containing both the two and three digit codes. </p> <pre><code>Hashmap fourdigitcodes; //check if first digit is 7 if(firstdigit==7) //country definitely russia else if country code begins with 1. Check the first four digits are in the hashmap with four digit codes and return the value if no value is found then answer is certainly usa. otherwise String country=""; HashMap&lt;String,String&gt; ccode = new HashMap&lt;String,String&gt;(); ccode.put("353","Ireland");//List all country codes ccode.put("49","Germany"); String value = ccode.get("49");//See if I have a value for the first 2 digits if(value != null){ country = value; //If I found a country for the first two digits we are done as the first two digits of the country code consisting of two digits cannot be in a country code with 3 }else{ the country is certainly 3 digit. return the first three digits by entering the first 3 digits as the key of the hashmap countaining the first three digits. } </code></pre> <p>In summary. If first digit is 7 Russian. If it is 1 check in the hashmap of four digit codes for the first four numbers if found a four digit code return the corresponding country.if not answer is USA otherwise check first two digits in the hashmap containing the 2 or 3 digits. If found two then return the answer other it is certainly a three digit code and return the corresponding country from the hash. </p> <p>It will be tedious to make the hashmap but I think an efficient solution.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload