字符串消消乐
来源:互联网 发布:淘宝服装拍摄灯光布置 编辑:程序博客网 时间:2024/04/28 21:28
遇到3个一样的就标记
public static void test(String s) { boolean modify = false; int len = 0; char[] re = new char[s.length()]; for (int i = 0; i < s.length(); i++) { if (s.charAt(i) != '*') { re[len++] = s.charAt(i); } } char[] res = new char[len]; System.arraycopy(re, 0, res, 0, len); char slow = 0; char fast = 1; while (fast < len) { if (fast + 1 < len && res[fast] == res[fast + 1] && res[fast] == res[slow]) { char temp = res[slow]; while (fast < len && res[fast] == temp) { modify = true; res[slow] = '*'; res[fast] = '*'; fast++; } } slow = fast; fast++; } if (modify) { test(new String(res)); } else System.out.println(Arrays.toString(res)); }
0 0
- 字符串消消乐
- 消消乐
- 消消乐
- 开心消消乐分析
- 开心消消乐
- 《开心消消乐》
- 《开心消消乐二》
- 矩阵消消乐
- c++实现消消乐
- 云消消乐
- unity消消乐源码
- 消消乐屏幕适配
- 消消乐无限道具BUG
- 消消乐(C语言版)
- Unity3D消消乐实现原理
- 看“果冻消消乐”运营分析有感
- 消消乐游戏算法实现(三消乐)
- 全民消消乐电信SDK对接
- 常用排序算法总结1一一冒泡排序
- 互斥锁问题
- 数学家、数学轶事与数学史话
- React 调用百度富文本 及存在的问题
- 文件权限管理
- 字符串消消乐
- Android开发学习笔记:浅谈WebView
- NAT穿透技术原理及应用
- Java面向对象
- 【for-each】增强for循环
- Servlet
- CopyComplexNodes
- Android系统自带样式(android:theme)详解
- android 修改系统时间