【转载】VMware 宿主机没插网线无法与虚拟机通讯如何解决?
2011-09-23 10:49
507 查看
http://leetcode.com/onlinejudge#question_38
Question:
The count-and-say sequence is the sequence of integers beginning as follows:
1, 11, 21, 1211, 111221, ...
1 is read off as "one 1" or 11.
11 is read off as "two 1s" or 21.
21 is read off as "one 2, then one 1" or 1211.
Given an integer n, generate the nth sequence.
Note: The sequence of integers will be represented as a string.
Solution:
Recursive.
Question:
The count-and-say sequence is the sequence of integers beginning as follows:
1, 11, 21, 1211, 111221, ...
1 is read off as "one 1" or 11.
11 is read off as "two 1s" or 21.
21 is read off as "one 2, then one 1" or 1211.
Given an integer n, generate the nth sequence.
Note: The sequence of integers will be represented as a string.
Solution:
Recursive.
public class Solution { public String countAndSay(int n) { // Start typing your Java solution below // DO NOT write main() function int i = 1; String[] result = new String ; while(i<=n){ if(i==1){ result[i-1] = "1"; }else { getNext(result, i-1); } i++; } return result[n-1]; } public void getNext(String[] aray, int index){ String cur = aray[index-1]; String next = ""; for(int i=0; i< cur.length();){ int j = i; while(j<cur.length()){ if(cur.charAt(j) == cur.charAt(i)){ j++; }else { break; } } next += j-i; next += cur.charAt(i); i=j; } aray[index] = next; } }
相关文章推荐
- VMware 宿主机没插网线无法与虚拟机通讯如何解决?
- VMware 宿主机没插网线无法与虚拟机通讯如何解决?
- 宿主机没插网线无法与虚拟机通讯如何解决
- 宿主机( win 7 系统) ping 虚拟机VMware( cent os 6.6 ) 出现“请求超时”或者“无法访问目标主机”的解决方法
- 没插网线 解决宿主机与虚拟机如何通讯
- 解决电脑没插网线虚拟机无法桥接到主机
- 宿主机( win 7 系统) ping 虚拟机VMware( cent os 6.6 ) 出现“请求超时”或者“无法访问目标主机”的解决方法
- 解决VMware仅主机模式虚拟机无法ping通物理机问题
- (转)如何解决vmware虚机无法通过主机防火墙上网的问题
- VMware-console客户端 出现”目标主机积极拒绝,无法连接” 怎么 如何 解决 方法 ?
- VMware中虚拟机无法通过NAT与主机共享上网的一种解决方法
- 如何解决vmware虚机无法通过主机防火墙上网的问题
- VMware无法识别USB设备的解决方法 以及 从虚拟机中断开USB设备,使其重新连接到windows主机上
- VMware复制Ubuntu虚拟机后,新虚拟机网卡无法使用解决办法
- 如何解决虚拟机安装centos无法全屏显示问题!
- Red Hat 7 创建网桥,解决KVM宿主机与虚拟机无法通讯
- 主机与虚拟机互PING,但主机无法访问虚拟机服务解决 (CENTOS)
- vmware中如何让虚拟机和物理主机在同一网段
- 虚拟机VMware无法识别USB设备(USB摄像头)问题及解决方法