Skip to content

Commit bd5a531

Browse files
committed
1111
1 parent 74383dc commit bd5a531

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Feel free to add issues, create pull requests and be a contributer.
7979
| Leetcode | [389. Find the Difference](https://leetcode.com/problems/find-the-difference/description/) | [Java](./java/findTheDifference.java) | _O(n)_ | _O(1)_ | Easy | |
8080
| Leetcode | [408. Valid Word Abbreviation](https://leetcode.com/problems/valid-word-abbreviation/description/) | [Java](./java/validWordAbbreviation.java) | _O(n)_ | _O(1)_ | Easy | |
8181
| Leetcode | [422. Valid Word Square](https://leetcode.com/problems/valid-word-square/description/) | [Java](./java/validWordSquare.java) | _O(n)_ | _O(1)_ | Easy | |
82+
| Leetcode | [482. License Key Formatting](https://leetcode.com/problems/license-key-formatting/description/) | [Java](./java/licenseKeyFormatting.java) | _O(n)_ | _O(1)_ | Medium | |
8283
| Leetcode | [500. Keyboard Row](https://leetcode.com/problems/keyboard-row/description/) | [Java](./java/findWords.java) | _O(n)_ | _O(1)_ | Easy | |
8384
| Leetcode | [520. Detect Capital](https://leetcode.com/problems/detect-capital/description/) | [Java](./java/detectCapitalUse.java) | _O(n)_ | _O(1)_ | Easy | |
8485
| Leetcode | [521. Longest Uncommon Subsequence I](https://leetcode.com/problems/longest-uncommon-subsequence-i/description/) | [Java](./java/findLUSlength.java) | _O(n)_ | _O(1)_ | Easy | |

java/licenseKeyFormatting.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public String licenseKeyFormatting(String S, int K) {
3+
StringBuilder sb = new StringBuilder();
4+
int count = 0;
5+
6+
for(int i = S.length()-1; i>=0; i--)
7+
{
8+
if(S.charAt(i) == '-') continue;
9+
if(count % K == 0 && count > 0) sb.insert(0,"-");
10+
sb.insert(0, Character.toUpperCase(S.charAt(i)));
11+
count++;
12+
}
13+
return sb.toString();
14+
}
15+
}

0 commit comments

Comments
 (0)