由买买提看人间百态

topics

全部话题 - 话题: charaters
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
I**A
发帖数: 2345
1
来自主题: JobHunting版 - 排列组合害死人啊
递归就可以了。
我纠结递归有一阵儿了
所以编了一些程序
public static void combine( String instr ){
int length = instr.length();
StringBuilder outstr = new StringBuilder();
doCombine( instr, outstr, length, 0 );
}
public static void doCombine(String instr, StringBuilder outstr, int
length, int start ){
for( int i = start; i < length; i++ ){
outstr.append( instr.charAt(i) );
System.out.println( outstr );
if( i < length - 1 ){
g**********y
发帖数: 14569
2
来自主题: JobHunting版 - Google的面经
radiochromatogram * suspensefulnesses = 289
public class WordProduct {
private final static String DIR = "src/test/resources/com/practice/
search";

public void search() {
int N = 30;
String content = FileHelper.readFile(DIR + "/WORD.LST");
String[] words = content.split("\n");
HashSet[] set = new HashSet[30];
HashMap map = new HashMap();

for (int i=0; i set[i] = ... 阅读全帖
d******u
发帖数: 397
3
来自主题: JobHunting版 - 寻找下一个回文数
int find_next_palindrome(int a){
String b = Integer.toString(a);
int l = b.length()/2;
if (b.length()%2 == 1){
l++;
}
int c = (int)Math.pow(10, l);
int d = a/c;
String e=Integer.toString(d+1);
String re=reverse_string(e);//helper function
if (b.length()%2 == 1){
e+=b.charAt(b.length()/2);
}
e+=re;
return Integer.parseInt(e);
}
String reverse_string(String in)... 阅读全帖
Z**********4
发帖数: 528
4
来自主题: JobHunting版 - java没有指针真麻烦
bool isMatch(char *str, const char* pattern) {
while (*pattern)
if (*str++ != *pattern++)
return false;
return true;
}
以上是C code 判断str里面是不是存在pattern
如果改成java的话
private static boolean isMatch (char[] str,char[] pattern)
{
int i=0;
while(i {
if(str[i]!=pattern[i])
return false;
i++;
}
return true;
}
是不是只能这样啊?java不能用指针嘛?还有我只能用i char数组作为参数 这样很不方便啊 我试了pattern.charAt(i)!=... 阅读全帖
r******r
发帖数: 700
5
来自主题: JobHunting版 - 谁能猜猜,这是个什么 algorithm?
Complexity 是多少? 别运行,试试看。
public static void mysteriousAlgorithm(String st, String chars) {
if (chars.length() == 1)
System.out.println(st + "" + chars);
else
for (int i = 0; i < chars.length(); i++) {
String newString = chars.substring(0, i) + chars.
substring(i + 1);
mysteriousAlgorithm(st + chars.charAt(i), newString);

}
}
s*********3
发帖数: 389
6
来自主题: JobHunting版 - 一道G题
I wrote some Java code afterwards. It seems not very clean. Please comment.
import java.util.*;
//Assumptions:
//1. We can move either up or down or left or right at any point in time,
but not diagonally.
//2. One item in the matrix can not be used twice to compose of the pattern
string.
//3. If different routes lead to the same indexes of matrix items to compose
of the pattern string, display them.
//4. The maximum number of movable steps is (matrix.length - 1) + (matrix[0]
.length - 1) = matri... 阅读全帖
g**********y
发帖数: 14569
7
public class PermuteK {
private int[] P;

public String permute(String input, int k) {
calculatePermuteNumber(input.length());
return find(input, k);
}
private void calculatePermuteNumber(int N) {
P = new int[N];
P[0] = 1;
for (int i=1; i P[i] = P[i-1]*i;
}
}

private String find(String input, int k) {
int N = input.length();
if (N == 1) return input;
int i = k/P[N-1];
... 阅读全帖
g**********y
发帖数: 14569
8
来自主题: JobHunting版 - 贡献几道面试题
字母重不重复出现没关系,大致code:
public void dfs(String str, Trie trie) {
if (str.length() == 0) {
if (trie.isWord()) print(trie.word);
}

char number = str.charAt(0);
for (c : getCharacter(number)) {
Trie next = trie.get(c);
if (next != null) dfs(str.substring(1), next);
}
}
g**********y
发帖数: 14569
9
来自主题: JobHunting版 - 怎么快速找二进制的某一位是否0
LZ估计是说输入就是一字符串,或者转成字符串了,然后"1".equals(str.charAt(i))?
m*******r
发帖数: 339
10
来自主题: JobHunting版 - 贡献今天facebook电面 一道题
我练练手,试着写了下:
public class StringPath {
public static boolean stringMatch(char[][] m, String s) {
StringBuffer sb = new StringBuffer();
boolean visited[][] = new boolean[m.length][m[0].length];
boolean found = false;
for (int i=0;i for (int j=0;j if (searchDFS(m, i, j, s, 0, visited, sb)) found = true;
}
}
return found;
}
public static boolean searchDFS(char[][] m, int x, int y, String s, int pos, boolean[][] v, S... 阅读全帖
h********w
发帖数: 221
11
来自主题: JobHunting版 - Epic Written Interview
1. 6 magazines
2. E
3. BC
4. 电话按键,如2222, mode(4) , 0 is 2, 1 is A, 2 is B, 3 is C and so and,
Public phoneKey(String str){
String keystring="";
for(int i=0; i {

int count=0;
int key =0;

if(str.charAt(i) =='2'){

for(int j=0; str[j]!=2; j++)
{

++count;
}
key=count%4;

switch(key)
case 0:
key= 2; break;
case 1:
key = a; break;
.....
keystring+=key;
.....
}
累了,休息一下,
BTW, EPIC t... 阅读全帖
h********w
发帖数: 221
12
来自主题: JobHunting版 - Epic Written Interview
1. 6 magazines
2. E
3. BC
4. 电话按键,如2222, mode(4) , 0 is 2, 1 is A, 2 is B, 3 is C and so and,
Public phoneKey(String str){
String keystring="";
for(int i=0; i {

int count=0;
int key =0;

if(str.charAt(i) =='2'){

for(int j=0; str[j]!=2; j++)
{

++count;
}
key=count%4;

switch(key)
case 0:
key= 2; break;
case 1:
key = a; break;
.....
keystring+=key;
.....
}
累了,休息一下,
BTW, EPIC t... 阅读全帖
p*****2
发帖数: 21240
13
来自主题: JobHunting版 - 上一道题吧

可以用stack 和 dp。不过我也是在有提示的情况下做出来的。我本来是hbase的思路。
但是做不对。没想到你那个思路。你这么快能想到正确的解法还是挺赞的。
public class test
{
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
String str=in.next();
int[] dp=new int[str.length()];
Arrays.fill(dp,-1);
Stack stack=new Stack();
int max=0;
int maxcount=0;

for(int i=0;i {
char c=str.charAt(i);
if(c=='(')
... 阅读全帖
l*********y
发帖数: 142
14
来自主题: JobHunting版 - 攒人品之facebook电面面经
#include
#include
#include
#include
#include
#include
#include
using namespace std;
class Counter {
public :
Counter() {
counter = 0;
}
void increment() {
counter++;
}
void decrement() {
counter --;
}
int getValue() {
return counter;
}
private:
int counter;
};
class COWString {
public:
COWString() {
pointer = NULL;
rc = new Counter();
}... 阅读全帖
c*****e
发帖数: 3226
15
来自主题: JobHunting版 - longest valid Parentheses有O(n)算法么
哦,对的。不过还是觉得扫描2次这个方法很蠢。
搜了一下,网上有别的解法,而且通过了leetcode online judge.
public static int longestValidParentheses(String s) {
Stack stack = new Stack();
int len = 0;
int maxLen = 0;
int startIndex = s.length();
for(int i = 0; i < s.length(); ++i) {
if(s.charAt(i) == '(') {
stack.push(i);
continue;
}

if(stack.isEmpty()) {
startIndex = s.length();
} else {
... 阅读全帖
w*********0
发帖数: 48
16
来自主题: JobHunting版 - longest valid Parentheses有O(n)算法么
O(n)
import java.util.*;
public class Solution {
public int longestValidParentheses(String s) {
// Start typing your Java solution below
// DO NOT write main() function
if (s == null || s.length() == 0) return 0;
ArrayList pos = new ArrayList();
HashMap pair = new HashMap();
int len = s.length();
int max = 0;
for (int i = 0; i < len; i++) {
if (s.charAt(i) == '(')... 阅读全帖
c*****e
发帖数: 3226
17
来自主题: JobHunting版 - longest valid Parentheses有O(n)算法么
哦,对的。不过还是觉得扫描2次这个方法很蠢。
搜了一下,网上有别的解法,而且通过了leetcode online judge.
public static int longestValidParentheses(String s) {
Stack stack = new Stack();
int len = 0;
int maxLen = 0;
int startIndex = s.length();
for(int i = 0; i < s.length(); ++i) {
if(s.charAt(i) == '(') {
stack.push(i);
continue;
}

if(stack.isEmpty()) {
startIndex = s.length();
} else {
... 阅读全帖
w*********0
发帖数: 48
18
来自主题: JobHunting版 - longest valid Parentheses有O(n)算法么
O(n)
import java.util.*;
public class Solution {
public int longestValidParentheses(String s) {
// Start typing your Java solution below
// DO NOT write main() function
if (s == null || s.length() == 0) return 0;
ArrayList pos = new ArrayList();
HashMap pair = new HashMap();
int len = s.length();
int max = 0;
for (int i = 0; i < len; i++) {
if (s.charAt(i) == '(')... 阅读全帖
l*****a
发帖数: 14598
19
来自主题: JobHunting版 - longest valid Parentheses有O(n)算法么
简单说就用ArrayList存字符的index,
如果当前字符是')', s.charAt(list.size()-1)=='('
remove the end of list
最后你会得到一个保存那些没有match的index的list
比方说[2,5,12] 字符串长度 len
then 0,1 is a match, 3,4 is a match 6,7,8,9,10,11 is a match
len-12-1 is a match
pick up the largest among them
s******e
发帖数: 146
20
来自主题: JobHunting版 - longest valid Parentheses有O(n)算法么
我今天也正好做到这个。
想法是存上每个‘(’之前已经匹配的括号数量。
比如
()(()()(()
第1次遇到前括号,入栈数字是0,然后遇到后括号,现在的长度是2+0
第2次遇到前括号,入栈数字是2,当前长度重设为0
第3次遇到前括号,入栈数字是当前长度0.然后后括号,出栈,长度是2+0,
第4次遇到前括号,入栈数字是当前长度2.然后后括号,出栈,长度是2+2,
第5次遇到前括号,入栈数字是当前长度4,当前长度重设为0
第6次遇到前括号,入栈数字是当前长度0,遇到后括号,出栈,长度是2.
如果栈内仍有数字,目前是2,4,则全部出栈,和当前长度2比。取最长为4.
public class Solution {
public int longestValidParentheses(String s) {
// Start typing your Java solution below
// DO NOT write main() function
Stack stack = new Stack();
... 阅读全帖
l*****a
发帖数: 14598
21
来自主题: JobHunting版 - longest valid Parentheses有O(n)算法么
简单说就用ArrayList存字符的index,
如果当前字符是')', s.charAt(list.size()-1)=='('
remove the end of list
最后你会得到一个保存那些没有match的index的list
比方说[2,5,12] 字符串长度 len
then 0,1 is a match, 3,4 is a match 6,7,8,9,10,11 is a match
len-12-1 is a match
pick up the largest among them
s******e
发帖数: 146
22
来自主题: JobHunting版 - longest valid Parentheses有O(n)算法么
我今天也正好做到这个。
想法是存上每个‘(’之前已经匹配的括号数量。
比如
()(()()(()
第1次遇到前括号,入栈数字是0,然后遇到后括号,现在的长度是2+0
第2次遇到前括号,入栈数字是2,当前长度重设为0
第3次遇到前括号,入栈数字是当前长度0.然后后括号,出栈,长度是2+0,
第4次遇到前括号,入栈数字是当前长度2.然后后括号,出栈,长度是2+2,
第5次遇到前括号,入栈数字是当前长度4,当前长度重设为0
第6次遇到前括号,入栈数字是当前长度0,遇到后括号,出栈,长度是2.
如果栈内仍有数字,目前是2,4,则全部出栈,和当前长度2比。取最长为4.
public class Solution {
public int longestValidParentheses(String s) {
// Start typing your Java solution below
// DO NOT write main() function
Stack stack = new Stack();
... 阅读全帖
h*****g
发帖数: 312
23
来自主题: JobHunting版 - 这题in place 做不了吧?
You are given a string like "aaaabbbcc", do an in place conversion which
write frequency of each charater(which come continuosly) with that character
Example:
input: aaabbbccd
output: a3b2c2d1
input: aabaa
output: a2b1a2
s********r
发帖数: 137
24
来自主题: JobHunting版 - 这题in place 做不了吧?
只处理出现次数小于10的情况,但是可以很容易修改处理出现次数多余9次的情况。
我写的,见笑了:
/***********************************************************************
*********************/
/* Compress a String: AAABBCDDDD will be A3B2CD4 */
//
private static String compressString(String str)
{
char[] chars = str.toCharArray();
char current = chars[0];
int count = 1;
int indexCounter = 1;
int shiftBack = 0;
for(int i = 1; i< chars.length; i++){
if (curren... 阅读全帖
p*****2
发帖数: 21240
25
来自主题: JobHunting版 - onsite后收到A家的拒信,面经。

第一题写了一下,还不算容易。刚开始题目理解错了。
HashSet hs = new HashSet();
HashMap hm = new HashMap();
HashSet visited = new HashSet();
boolean Change(String a, String b)
{
visited.add(a);
if (a.equals(b))
return true;
if (hm.containsKey(a))
return hm.get(a);
char[] arr = a.toCharArray();
for (int i = 0; i < arr.length; i++)
{
if (arr[i] != b.charAt... 阅读全帖
p*****2
发帖数: 21240
26
来自主题: JobHunting版 - onsite后收到A家的拒信,面经。

第一题写了一下,还不算容易。刚开始题目理解错了。
HashSet hs = new HashSet();
HashMap hm = new HashMap();
HashSet visited = new HashSet();
boolean Change(String a, String b)
{
visited.add(a);
if (a.equals(b))
return true;
if (hm.containsKey(a))
return hm.get(a);
char[] arr = a.toCharArray();
for (int i = 0; i < arr.length; i++)
{
if (arr[i] != b.charAt... 阅读全帖
f**********2
发帖数: 2401
27
来自主题: JobHunting版 - 报个A家OFFER,回馈版上
1. 归并操作
public int[] Merge(int[] a, int[] b) {
int [] c = new int[ a.length()+b.length() ];
int i=0,j=0,k=0;
while (i if (a[i] else {c[k]=b[j];k++;j++}
while (i {c[k]=a[i];k++;i++;}
while (j {c[k]=b[j];k++;j++;}
return c;
}
时间O(nlgn),空间O(n)?
2 从数组的头和尾开始算和sum,若sum=SUM,输出;若sum ;若sum> SUM, 偏大了,尾指针-1; 包在一个循环里,结束条件是头指针》=尾指针。
3 开一个不小于string长度的数组,遍历string,若相同的char,统计到一起;最后遍
历数组,找第一个值为1的index,再在string里面... 阅读全帖
z****e
发帖数: 54598
28
来自主题: JobHunting版 - 一道码公电面题(nvidia),怎么做
java
public class Test {
public static boolean isOdd(int para){
String s = "" + para;
boolean result = false;
for(int i=0;i if(s.charAt(i)=='1') result = (result==true ? false:true );
}
return result;
}
public static void main(String[] args){

System.out.println(Test.isOdd(32011));
}
}
z****e
发帖数: 54598
29
来自主题: JobHunting版 - 一道码公电面题(nvidia),怎么做
java
public class Test {
public static boolean isOdd(int para){
String s = "" + para;
boolean result = false;
for(int i=0;i if(s.charAt(i)=='1') result = (result==true ? false:true );
}
return result;
}
public static void main(String[] args){

System.out.println(Test.isOdd(32011));
}
}
D********g
发帖数: 650
30
来自主题: JobHunting版 - 一道G家店面题
20分钟写了大约下面的code,如果要输出string,还要backtrack:
static String word2Anagram(final String word) {
if (word == null) {
return null;
}

int ht[] = new int[256];
for (int i = 0; i < word.length(); ++i) {
int charVal = (int) word.charAt(i);
ht[charVal] ++;
}

StringBuilder anagram = new StringBuilder();
for (int i = 0; i < ht.length; ++i) {
if (ht[i] > 0) {
anagram.append((cha... 阅读全帖
D********g
发帖数: 650
31
来自主题: JobHunting版 - 一道G家店面题
加上了backtracking:
static class DPElement {
int value;
int prevCostIdx; // 0-based cost idx
int takenThisElement; // 0/1, indicating whether taking current
element, idx 0 based.
public DPElement() {
value = 0;
prevCostIdx = 0;
takenThisElement = 0;
}
}
static String word2Anagram(final String word) {
if (word == null) {
return null;
}

int ht[] = new int[256];
f... 阅读全帖
B*******1
发帖数: 2454
32
来自主题: JobHunting版 - 一道G家店面题
: int ht[] = new int[256];
: for (int i = 0; i < word.length(); ++i) {
: int charVal = (int) word.charAt(i);
: ht[charVal] ++;
Is this a bug?
dead - > ade ?
p*****o
发帖数: 1285
33
来自主题: JobHunting版 - Minimum Window Substring
LeetCode上的题目,我怎么想都是O(kn),k是T里的unique charater的数目。请问大侠
如何做到O(n)。
附题目:
Given a string S and a string T, find the minimum window in S which will
contain all the characters in T in complexity O(n).
For example,
S = "ADOBECODEBANC"
T = "ABC"
Minimum window is "BANC".
p*****o
发帖数: 1285
34
来自主题: JobHunting版 - 一道题
某家on-site的一道题。
Find the most frequent character in a string.
Data: strings are composed of Unicode charaters, stored in 10 sets of 5GB
files on 10 different servers each with 2GB of memory.
Constraints: network communication is expensive.
Question: find the best algorithm.
p*****2
发帖数: 21240
35
我写了一个练练。
public int numDecodings(String s)
{
if(s==null || s.length()==0)
return 0;

int len=s.length();
int[] dp=new int[len+1];
dp[len]=1;
for(int i=len-1;i>=0;i--)
{
if(s.charAt(i)!='0')
{
dp[i]=dp[i+1];
if(i dp[i]+=dp[i+2];
}
}

return dp[0];
}
c***d
发帖数: 26
36
来自主题: JobHunting版 - [难题求助] leetcode wordsearch
这题野蛮暴力就能通过大case呀。
public class Solution {
public boolean exist(char[][] board, String word) {
// Start typing your Java solution below
// DO NOT write main() function
if (board==null) return false;
boolean visited[][] = new boolean[board.length][board[0].length];
for(int i = 0; i < board.length; i++) {
for(int j = 0; j < board[0].length; j++) {
if (helper(board, visited, word, i, j, 0)) return true;
}
}
... 阅读全帖
z******e
发帖数: 82
37
来自主题: JobHunting版 - G电面一题
public class Test {
public static void main(String[] args) {
test("12023456", "", 0);
}
public static void test(String nums, String out, int start) {
if (nums == null || start == nums.length()) {
System.out.println(out);
return;
}
int i = nums.charAt(start) - '0';
if (i != 0) {
test(nums, out + (char) (i + 64), start + 1);
if (start + 1 < nums.length()) {
i = Integer.parseInt(nums.... 阅读全帖
g*******n
发帖数: 214
38
来自主题: JobHunting版 - G电面一题
如果不用recursion的话代码太长是不是面试的时候不能用?
public ArrayList numString2Char(String num) {
//map to store all the previous possibilities
HashMap> map = new HashMap ArrayList>();
int[] numbers = new int[num.length()];
for (int i = 0; i < num.length(); i++) {
numbers[i] = Integer.parseInt(num.charAt(i) + "");
}
if(numbers[0]==0) return null;
ArrayList tempList;
... 阅读全帖
l***m
发帖数: 339
39
来自主题: JobHunting版 - 刚面完ebay,说打算招300个
首先我不是很会java啊。。不过我知道你这个代码有点问题,比如 输入是 “,” ,你
返回true,就不对了,因为他是无效得,得返回false。 还有一个问题,就是
while(!isValid(str.charAt(i)))
: i++;
这个做完以后你要判断是不是i j, 比如",,,,,,!",这种一直没有
valid得,这样就不对了。。
不过感觉用java写果然容易很多啊,至少可以都转成小写字母。
z******e
发帖数: 82
40
来自主题: JobHunting版 - 发个Twitter的面试题
// " /*dfsfsdf*/ //fdsfs " is processed.
private static String uncomment(String str) {
boolean slash2 = false;
boolean inStr = false;
boolean slashstar = false;
StringBuilder sb = new StringBuilder();
char lastc = ' ';
char c = ' ';
int deleteStart = -1;
for (int i = 0; i < str.length(); i++) {
lastc = c;
c = str.charAt(i);
sb.append(c);
// ""
if (c == '"') {
inStr = !inStr;
continue;
}
if (!inStr && c == '\n' && slash2) {
slash2 = false;
sb.delete(deleteStart, sb.length() - 1);
deleteStart = -1... 阅读全帖
c*****a
发帖数: 808
41
来自主题: JobHunting版 - 50行code能解决addbinary 问题么
public String addBinary(String a, String b) {
StringBuilder res= new StringBuilder();
int carry=0;
for(int i =0; i< Math.max(a.length(), b.length()); i++){
int num=0;
num = bit(a, a.length() -1 - i) + bit(b, b.length()-1 -i) +
carry;
res.insert(0, num % 2);
carry = num / 2;
}
if(carry ==1)
res.insert(0, 1);
return res.toString();
}
public int bit(String str, int index){
... 阅读全帖
f*******t
发帖数: 7549
42
来自主题: JobHunting版 - Wildcard Matching题求助
问过1337哥,他说最大数据是32768*32768,肯定会MLE。
我有个优化的版本,但最后一个test case还是TLE。十分想看谁有能AC的代码!
public boolean isMatch(String s, String p) {
if (s == null || p == null)
return false;
if (s.isEmpty() && p.isEmpty()) { //Both are empty string -> true
return true;
} else if (s.isEmpty()) { // If s is empty, p must not contain
any character other than '*'
for (int i = 0; i < p.length(); i++) {
if (p.charAt(i) != '*')
... 阅读全帖
l**b
发帖数: 457
43
来自主题: JobHunting版 - G phone interview
响应2爷号召,有题目就练,贴个我的:
public String getLongestSubstring(String s) {
if (s == null || s.length() == 0) return "";
if (s.length() <= 2) return s;

char a = '\0';
char b = '\0';
int aLastIndex = -1;
int bLastIndex = -1;
int left = 0;
int right = 0;
String result = "";
while (right < s.length()) {
char c = s.charAt(right);
if (a == '\0') {
a = c;
} else if (b ==... 阅读全帖
c********t
发帖数: 5706
44
能不能和下面解法对比一下优缺点?
public static void permutation(String str) {
permutation("", str);
}
private static void permutation(String prefix, String str) {
int n = str.length();
if (n == 0) System.out.println(prefix);
else {
for (int i = 0; i < n; i++)
permutation(prefix + str.charAt(i), str.substring(0, i) + str.
substring(i+1, n));
}
}
c********t
发帖数: 5706
45
能不能和下面解法对比一下优缺点?
public static void permutation(String str) {
permutation("", str);
}
private static void permutation(String prefix, String str) {
int n = str.length();
if (n == 0) System.out.println(prefix);
else {
for (int i = 0; i < n; i++)
permutation(prefix + str.charAt(i), str.substring(0, i) + str.
substring(i+1, n));
}
}
p*****2
发帖数: 21240
46
来自主题: JobHunting版 - 对scala很失望

我工作不用呀。刚才看了一下,是某个test case超时了,所以不是编译的问题。计时
是计的那个test case。大牛帮我看看这个程序哪里可以提高一些?跟java的算法完全
一样。慢了那么多。
object test {
def main(args: Array[String]): Unit = {
val s=readLine
val a=new Array[Int](s.length())
var i=0
var j=s.length-1
for(k <- 0 to s.length-1)
if(s(k)=='l')
{
a(j)=k+1
j-=1
}
else
{
a(i)=k+1
i+=1
}
a.foreach(println)
}
}
void run() throws Exception
{
... 阅读全帖
c*******r
发帖数: 309
47
来自主题: JobHunting版 - Permutation leetcode-
这下边的code我总觉得初始判断有问题, 如果str==null||str.length()==0返回null
这个recursion还有效么
public ArrayList permutes(String str){
if(str==null||str.length()==0)
return null;
ArrayList result=new ArrayList();
char first=str.charAt(0);
String other=str.substring(1);
ArrayList strings=permutes(other);
for(int i=0;i for(int j=0;j String temp=insert(s... 阅读全帖
s****0
发帖数: 117
48
package myutil;
import java.util.Scanner;
import java.util.Stack;
public class ParseExp {
Stack oprand = new Stack();
Stack oprator = new Stack();
static int[] code = new int[256];
static {
code['+'] = 10;
code['-'] = 11;
code['*'] = 20;
code['/'] = 21;
code['^'] = 30;
code['$'] = 0;
code['('] = 100;
code[')'] = 1;
}
public ParseExp() {
}
public Integer parse(String... 阅读全帖
s****0
发帖数: 117
49
package myutil;
import java.util.Scanner;
import java.util.Stack;
public class ParseExp {
Stack oprand = new Stack();
Stack oprator = new Stack();
static int[] code = new int[256];
static {
code['+'] = 10;
code['-'] = 11;
code['*'] = 20;
code['/'] = 21;
code['^'] = 30;
code['$'] = 0;
code['('] = 100;
code[')'] = 1;
}
public ParseExp() {
}
public Integer parse(String... 阅读全帖
l*****a
发帖数: 14598
50
你弄个stringbuilder
然后一列一列append,每列也是个stringbuilder,偶数列头尾没有reverse 之后在插入
总结果
###注意最后一列填满
最后对于总的string.
for(int j=0;j //这是一行的
for(int i=0;i str.charAt(i*col+j)
}
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)