题目: 题解:
class Solution {
public:int trapRainWater(vector<vector<int>>& heightMap) {int m heightMap.size(), n heightMap[0].size();int maxHeight 0;int dirs[] {-1, 0, 1, 0, -1};for (int i 0; i < m; i) {maxHei…
题目: 题解:
class Solution {public int longestPalindrome(String s) {int[] count new int[128];int length s.length();for (int i 0; i < length; i) {char c s.charAt(i);count[c];}int ans 0;for (int v: count) {ans v / 2 * 2;if (v …
题目: 题解:
class Solution:def longestPalindrome(self, s: str) -> int:ans 0count collections.Counter(s)for v in count.values():ans v // 2 * 2if ans % 2 0 and v % 2 1:ans 1return ans
题目: 题解:
func longestPalindrome(s string) int {mp : map[byte]int{}for i : 0; i < len(s); i {mp[s[i]]}res : 0for _, v : range mp {if v&1 1 {res v - 1} else {res v}}if res<len(s) {res}return res
}