摘要:
package com.mianshi.ms;import java.util.Stack;/** * 类说明 输入N对括号,输出正确的配对组合 */public class NPair { public static Stack<String> doCompute(int N){ Stack<String > stack=new Stack<String>(); if(N==1){ stack.push("()"); return stack; } Stack<String> stac... 阅读全文
摘要:
package com.bupt.syc;import java.util.Iterator;import java.util.LinkedList;import org.junit.Test;public class Josephus { // 模拟解法 public static int JosephusWinner(int M, int N) throws Exception { if (N < M) { throw new Exception("M should smaller than N"); } int ... 阅读全文
摘要:
public class RemoveDuplicatedChar { public static void removeDuplicated(char[] str) { if (str == null) return; int len = str.length; if (len < 2) return; int tail = 1; for (int i = 1; i < len; i++) { int j; for (j ... 阅读全文