全部评论
用栈模拟试试,元素进入都跟栈顶元素比较下,相同就栈顶出栈,不同就新元素入栈。 最后再把栈里元素反转下
栈
感觉直接的方式是用模拟一个链表,节点存char,每次遍历链表发现有重复的当遍历完时就再重新遍历一遍
广联达笔试题😂
public static boolean process(String str){
int count = 1;
for(int index = 0;index < str.length() - 1;++index){
if(str.charAt(index) == str.charAt(index + 1)){
++count;
str = str.substring(0,index) + str.substring(index + 2);
index -= 2;
}
}
System.out.println(str);
return count % 2 != 0;
}
map
相关推荐
点赞 评论 收藏
分享
华灯初上i:给一个问题: 你觉得langchain写agent有什么优势嘛,使用过程中遇到了什么问题,怎么解决的。框架的取消机制如何实现的(推理取消和工具调用取消)。
点赞 评论 收藏
分享
