Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. public class Solution {
  2. public String licenseKeyFormatting(String S, int K) {
  3. StringBuilder sb = new StringBuilder();
  4. for(int i=S.length()-1; i>=0; i--) {
  5. if(S.charAt(i) != '-') {
  6. sb.append(sb.length() % (K+1) == K ? "-" : "").append(S.charAt(i));
  7. }
  8. }
  9. return sb.reverse().toString().toUpperCase();
  10. }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement