LeetCode
A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Write a function to determine if a number is strobogrammatic. The number is represented as a string.
For example
the numbers "69", "88", and "818" are all strobogrammatic.
classSolution{publicbooleanisStrobogrammatic(Stringnum){Map<Character,Character> map =newHashMap<>();map.put('0','0');map.put('1','1');map.put('8','8');map.put('6','9');map.put('9','6');int l =0, r =num.length()-1;while(l <= r){Character value =map.get(num.charAt(l));if(value ==null||num.charAt(r)!= value)returnfalse; l++; r--;}returntrue;}}