#力扣LeetCode2053. 数组中第 K 个独一无二的字符串 @FDDLC
作者:互联网
题目描述:
2053. 数组中第 K 个独一无二的字符串 - 力扣(LeetCode) (leetcode-cn.com)
Java代码:
class Solution {
public String kthDistinct(String[] a, int k) {
HashMap<String,Integer> map=new HashMap<>();
for(String s:a)map.put(s,map.getOrDefault(s,0)+1);
for(String s:a)if(map.get(s)==1&&--k==0)return s;
return "";
}
}
标签:map,return,HashMap,独一无二,LeetCode2053,力扣,FDDLC,String 来源: https://blog.csdn.net/liuxc324/article/details/121258378