java - 递归查找出现次数
问题描述
我需要编写一个函数来查找文本中最常见的起始字母。文本由空格解析,所有单词都使用按字典顺序排序的链表链接。我写了一个函数来查找起始字母的出现次数,现在需要编写一个递归函数来返回最常见的字母。
这是出现次数的函数:
public int howManyStarting (char letter) {
int counter=0;
WordNode current= _head;
while (current != null){
if (current.getWord().charAt(0) == letter){
counter += current.getNumOfAppearance();
}
current = current.getNext();
}
return counter;
解决方案
推荐阅读
- python - 如何为CNN输入python制作3维数组
- java - 如何通过 JPA 从连接的第二个表中检索特定行
- vue.js - 删除当前页面的 Vuex 记录时如何处理导航?
- ajax - BootsFaces DateTimePicker AJAX 不工作
- swift - 领域模型转换失败
- javascript - vue.js:无法从计算属性访问路由器参数
- angularjs - 在个人资料图像上使用 AngularJS 的三元运算
- scala - 如何覆盖案例类属性并避免重复存储?
- laravel-5 - Laravel 关系返回空结果
- c++ - C ++内联汇编试图将字符从字符串复制到寄存器中