Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit404865d

Browse files
palindrome permutation
1 parentcbba375 commit404865d

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
packageeasy;
2+
3+
importjava.util.HashMap;
4+
importjava.util.Map;
5+
6+
publicclassPalindromePermutation {
7+
8+
publicbooleancanPermutePalindrome(Strings) {
9+
10+
char[]chars =s.toCharArray();
11+
Map<Character,Integer>map =newHashMap<Character,Integer>();
12+
for(charc :chars){
13+
if(!map.containsKey(c))map.put(c,1);
14+
elsemap.put(c,map.get(c)+1);
15+
}
16+
intevenCount =0;
17+
for(Map.Entry<Character,Integer>e :map.entrySet()){
18+
if(e.getValue() %2 !=0)evenCount++;
19+
if(evenCount >1)returnfalse;
20+
}
21+
returntrue;
22+
23+
}
24+
25+
}

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
|276|[Paint Fence](https://leetcode.com/problems/paint-fence/)|[Solution](../../blob/master/EASY/src/easy/PaintFence.java)| O(n)|O(1) | Easy| DP
5555
|273|[Integer to English Words](https://leetcode.com/problems/integer-to-english-words/)|[Solution]|
5656
|270|[Closest Binary Search Tree Value](https://leetcode.com/problems/closest-binary-search-tree-value/)|[Solution](../../blob/master/EASY/src/easy/ClosestBinarySearchTreeValue.java)| O(h)|O(1) | Easy| DFS
57+
|266|[Palindrome Permutation](https://leetcode.com/problems/palindrome-permutation/)|[Solution](../../blob/master/EASY/src/easy/PalindromePermutation.java)| O(n)|O(1) | Easy| HashMap
5758
|261|[Graph Valid Tree](https://leetcode.com/problems/graph-valid-tree/)|[Solution](../../blob/master/MEDIUM/src/medium/GraphValidTree.java)| O(V+E)|O(V+E)| Medium|
5859
|259|[3Sum Smaller](https://leetcode.com/problems/3sum-smaller/)|[Solution](../../blob/master/MEDIUM/src/medium/_3Sum_Smaller.java)| O(n^2)|O(1)| Medium|
5960
|257|[Binary Tree Paths](https://leetcode.com/problems/binary-tree-paths/)|[Solution](../../blob/master/EASY/src/easy/BinaryTreePaths.java) | O(n*h) | O(h) | DFS/Recursion

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp