GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode-4/java/482_License_Key_Formatting.java at master · Spencerai/leetcode-4 Expand file tree/ Copy path482_License_Key_Formatting.javaMore file actions 10 lines (10 loc) · 464 Bytes / Copy path482_License_Key_Formatting.javaFile metadata and controls10 lines (10 loc) · 464 Bytes 1 2 3 4 5 6 7 8 9 10 class Solution { public String licenseKeyFormatting(String s, int k) { // https://leetcode.com/problems/license-key-formatting/discuss/96512/Java-5-lines-clean-solution StringBuilder sb = new StringBuilder(); for (int i = s.length() - 1; i >= 0; i--) if (s.charAt(i) != '-') sb.append(sb.length() % (k + 1) == k ? '-' : "").append(s.charAt(i)); return sb.reverse().toString().toUpperCase(); } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |