/
githubmirror
/
interviews
Обзор
Документация
Войти
/
githubmirror
/
interviews
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
leetcode/hash-table/StrobogrammaticNumber.java
17 строк
616 B
Kevin Naughton Jr
finish renaming files and directories
27 мар 2018, 19:52
27 мар 2018, 19:52
ec6dfb5
Код
Авторство
О чём код?
// 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. public class StrobogrammaticNumber { public boolean isStrobogrammatic(String num) { for(int i = 0, j = num.length() - 1; i <= j; i++, j--) { if(!"00 11 88 696".contains(num.charAt(i) + "" + num.charAt(j))) { return false; } } return true; } }