论坛首页 招聘求职论坛

广州亿迅面试失败!

浏览 16061 次
精华帖 (0) :: 良好帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2010-05-07  
上个星期去亿迅面试运营增值部(?,在6搂),编程题5道,4道要用递归,其中一道还要用回溯法,反正考的很难
hr给4张白纸,没规定时间,我做了接近1个小时40分(还有简答题,挑错题),最后编程题只完成3道,随后两个小组长来面试,时间很短,最后over!
回家后在eclipse上做了最难的两道,一道用了3个半小时,一道用了2个半,编码,调试,工作3年的搞这种算法题真的不适合啊。
总结:基础不扎实,项目经验,知识面都很窄(3年java开发经验,只做过2个erp,1个oa的开发,反正就是那种web应用,3层(action,service,dao),ssh,增删改查)
ps:原本想进电信项目的公司,业务广,项目种类也多,可惜挑战失败,最后只能确定了一个小公司的offer(5.5k),又要熬了!
付题目解答,好像网上没真确完整的解答,留个爪印吧,哈哈。。

1给出一组整数,例如,(19,27,42,...)现在请把他们分成三堆,使得每一堆的和相等;
a。如何判断该问题是否有解
b。请给出解决方案的算法(尽可能每小组相等的算法)
c。给出o(n)
package com.java.core;

import java.util.ArrayList;
import java.util.List;

public class Enumerate {

	private int[] data;

	private List<Integer> list = new ArrayList<Integer>();

	private List<Integer> index_list = new ArrayList<Integer>();// 数组data的下标, list.get(i)=data[index_list.get(i)];

	private int s;// 余下的和,初始值为sum(data)/3

	private int n;// list.get(0)=data[n]

	private int index;// 数组data的下标

	public void enumerate() {
		if (n < data.length) {
			if (index < data.length) {
				if (data[index] < s) {
					index_list.add(index);
					list.add(data[index]);
					s -= data[index];
					index++;
					enumerate();
				} else if (data[index] == s) {
					index_list.add(index);
					list.add(data[index]);
					s = 0;
				} else {
					index++;
					enumerate();
				}
			} else {
				if (list.size() > 0) {
					int l = (Integer) list.remove(list.size() - 1);
					s += l;
					index = (Integer) index_list.remove(index_list.size() - 1) + 1;
					enumerate();
				} else {
					n++;
					index = n;
					enumerate();
				}
			}
		}
	}

	public int[] getData() {
		return data;
	}

	public void setData(int[] data) {
		this.data = data;
	}

	public List<Integer> getList() {
		return list;
	}

	public void setList(List<Integer> list) {
		this.list = list;
	}

	public List<Integer> getIndex_list() {
		return index_list;
	}

	public void setIndex_list(List<Integer> indexList) {
		index_list = indexList;
	}

	public int getS() {
		return s;
	}

	public void setS(int s) {
		this.s = s;
	}

	public int getN() {
		return n;
	}

	public void setN(int n) {
		this.n = n;
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public static void main(String[] args) {
		int[] array = { 3, 5, 8, 9, 15 };

		Enumerate enumerate = new Enumerate();
		enumerate.setData(array);
		enumerate.setS(20);

		System.out.println(enumerate.getS());
		enumerate.enumerate();

		if (enumerate.getS() == 0) {
			for (Integer i : enumerate.getList()) {
				System.out.print(i + ",");
			}
		}
	}
}

package com.java.core;

import java.util.List;

public class Back {

	private int[] data;

	private int avg;

	private Enumerate enumerate1 = new Enumerate();

	private Enumerate enumerate2 = new Enumerate();

	public int[] getData() {
		return data;
	}

	public void setData(int[] data) {
		this.data = data;
	}

	public Enumerate getEnumerate1() {
		return enumerate1;
	}

	public void setEnumerate1(Enumerate enumerate1) {
		this.enumerate1 = enumerate1;
	}

	public Enumerate getEnumerate2() {
		return enumerate2;
	}

	public void setEnumerate2(Enumerate enumerate2) {
		this.enumerate2 = enumerate2;
	}

	public int sum(int[] data1) {
		int sum = 0;
		for (int i = 0; i < data1.length; i++) {
			sum += data1[i];
		}

		return sum;
	}

	public boolean isSolvable() {
		int sum = sum(data);
		if (sum % 3 == 0) {
			avg = sum / 3;
			enumerate1.setS(avg);
			enumerate2.setS(avg);
			return true;
		} else
			return false;
	}

	private int[] newArray(int[] data1, List<Integer> index_list) {
		int[] data2 = new int[data1.length - index_list.size()];
		int data1_index = 0;
		for (int i = 0; i < data1.length; i++) {
			if (!index_list.contains(i)) {
				data2[data1_index] = data1[i];
				data1_index++;
			}
		}

		return data2;
	}

	private void back__(Enumerate enumerate) {
		List<Integer> list = enumerate.getList();
		List<Integer> index_list = enumerate.getIndex_list();
		if (list.size() > 0) {
			int l = (Integer) list.remove(list.size() - 1);
			enumerate.setS(enumerate.getS() + l);
			enumerate.setIndex((Integer) index_list
					.remove(index_list.size() - 1) + 1);
			enumerate.enumerate();
		} else {
			enumerate.setN(enumerate.getN() + 1);
			enumerate.setIndex(enumerate.getN());
			enumerate.enumerate();
		}
		back();
	}

	public void back() {
		if (enumerate1.getS() == 0) {
			int[] data1 = newArray(data, enumerate1.getIndex_list());

			enumerate2.setData(data1);
			enumerate2.setIndex(0);
			enumerate2.setN(0);
			enumerate2.enumerate();

			if (enumerate2.getS() == 0) {
				int[] data2 = newArray(data1, enumerate2.getIndex_list());

				int sum = sum(data2);
				if (sum != avg) {
					back__(enumerate2);
				}
			} else {
				if (enumerate2.getN() < enumerate2.getData().length) {
					back__(enumerate2);
				} else {
					back__(enumerate1);
				}
			}
		} else {
			if (enumerate1.getN() < enumerate1.getData().length) {
				back__(enumerate1);
			}
		}
	}

	public static void main(String[] args) {
		int[] data = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 15 };
		// int[] data = { 15, 9, 8, 7, 6, 5, 4, 3, 2, 1 };
		Back back = new Back();
		back.setData(data);
		if (back.isSolvable()) {
			back.getEnumerate1().setData(data);
			back.getEnumerate1().enumerate();
			back.back();

			System.out.println(back.getEnumerate1().getS());
			for (Integer i : back.getEnumerate1().getList()) {
				System.out.print(i + ",");
			}

			System.out.println();
			System.out.println(back.getEnumerate2().getS());
			for (Integer i : back.getEnumerate2().getList()) {
				System.out.print(i + ",");
			}

			int[] data2 = back.newArray(back.getEnumerate2().getData(), back
					.getEnumerate2().getIndex_list());
			System.out.println();
			System.out.println(back.sum(data2));
			for (int i = 0; i < data2.length; i++) {
				System.out.print(data2[i] + ",");
			}
		}
	}
}


2.数字转为大写的金额字符串,比如1001.12转为壹千零壹元壹角贰份
a。要求函数可以重用
PS。我只实现整数部分
package com.java.core;

public class MoneyString {

	public String changeToString(long n) {
		String str = "";
		if (n == 0)
			str = "零";
		else if (n == 1)
			str = "壹";
		else if (n == 2)
			str = "贰";
		else if (n == 3)
			str = "叁";
		else if (n == 4)
			str = "肆";
		else if (n == 5)
			str = "伍";
		else if (n == 6)
			str = "陆";
		else if (n == 7)
			str = "柒";
		else if (n == 8)
			str = "捌";
		else if (n == 9)
			str = "玖";

		return str;
	}

	public long pow(int n, int p) {
		if (p == 1)
			return n;
		else
			return n * pow(n, p - 1);
	}

	public String recursive(long n) {
		if (n > pow(10, 8) - 1) {
			if (n % pow(10, 8) > pow(10, 7) - 1)
				return recursive(n / pow(10, 8)) + "亿"
						+ recursive(n % pow(10, 8));
			else
				return recursive(n / pow(10, 8)) + "亿零"
						+ recursive(n % pow(10, 8));
		} else if (n > pow(10, 4) - 1) {
			if (n % pow(10, 4) > pow(10, 3) - 1)
				return recursive(n / pow(10, 4)) + "万"
						+ recursive(n % pow(10, 4));
			else
				return recursive(n / pow(10, 4)) + "万零"
						+ recursive(n % pow(10, 4));
		} else if (n > pow(10, 3) - 1) {
			if (n % pow(10, 3) > pow(10, 2) - 1)
				return recursive(n / pow(10, 3)) + "千"
						+ recursive(n % pow(10, 3));
			else
				return recursive(n / pow(10, 3)) + "千零"
						+ recursive(n % pow(10, 3));
		} else if (n > pow(10, 2) - 1) {
			if (n % pow(10, 2) > pow(10, 1) - 1)
				return recursive(n / pow(10, 2)) + "百"
						+ recursive(n % pow(10, 2));
			else
				return recursive(n / pow(10, 2)) + "百零"
						+ recursive(n % pow(10, 2));
		} else if (n > pow(10, 1) - 1) {
			return recursive(n / pow(10, 1)) + "拾" + recursive(n % pow(10, 1));
		} else {
			return changeToString(n);
		}
	}

	public String delZero(String str) {
		int i = 0, j = 1;
		if (j < str.length()) {
			if (str.charAt(i) == '零'
					&& (str.charAt(j) == '零' || str.charAt(j) == '亿'
							|| str.charAt(j) == '万' || str.charAt(j) == '千'
							|| str.charAt(j) == '百' || str.charAt(j) == '拾' || str
							.charAt(j) == '元')) {
				return delZero(str.substring(j, str.length()));
			} else {
				return str.charAt(i)
						+ delZero(str.substring(j, str.length())).toString();
			}
		} else {
			return str.charAt(i) + "";
		}
	}

	public String toString(long n) {
		return delZero(recursive(n) + "元");
	}

	public static void main(String[] args) {
		long n = 1010001001010l;

		MoneyString ms = new MoneyString();

		System.out.println(ms.toString(n));
	}
}
   发表时间:2010-05-07  
我也面过,这两题,第一题我没做,不会做,第二题查表就行啦,不用这么烦吧?还有,笔试不会很严格,关键是第二次复试,那个啥经理说我的基础不错,但是java的技术应用经验不够(什么框架的),不符合他们公司的要求....
0 请登录后投票
   发表时间:2010-05-07   最后修改:2010-05-07
我第二道题当年笔试的时候也做过,不过我们的要求是把阿拉伯数字转成英文
英文里很多数字都是1000倍的关系,比如THOUSAND,MILLION,BILLION,TRILLION
方法跟楼主的类似。

只是我们写这个程序是给你一天的时间,可以上网,但同时要写文档并且要做介面
我当时用SWING做了个简单的介面,结果出错处理考虑的不完善。 最后面试的时候
被对方的技术人员挑出了错误(当然,用.net直接加个validation控件就可以轻松
完成)

附代码

/**
* Public class which is designed for the purpose of converting
* numbers into English words. Passes these words as a string
* output parameter.
*
* @author Hao Zang
*
*/

public class MoneyConvert {
//String array stores millenary unit.
private static String[] majorNames = {
    "",
    " THOUSAND",
    " MILLION",
    " BILLION",
    " TRILLION"    
    };
    
//String array stores cardinal(10base) unit
  private static String[] tensNames = {
    "",
    " TEN",
    " TWENTY",
    " THIRTY",
    " FOURTY",
    " FIFTY",
    " SIXTY",
    " SEVENTY",
    " EIGHTY",
    " NINETY"
    };
     
  //String array stores numbers' name
  private static String[] numNames = {
    "",
    " ONE",
    " TWO",
    " THREE",
    " FOUR",
    " FIVE",
    " SIX",
    " SEVEN",
    " EIGHT",
    " NINE",
    " TEN",
    " ELEVEN",
    " TWELVE",
    " THIRTEEN",
    " FOURTEEN",
    " FIFTEEN",
    " SIXTEEN",
    " SEVENTEEN",
    " EIGHTEEN",
    " NINETEEN"
    };
 
  /**This method is used to convert those integers have no
   * more than three digits( 0~999 ).
   * For numbers from 1 to 19(0 is special case), numbers mod
   * by 100 specified the  position of the string array which
   * store numeral words.
   * For numbers above 20 to 999, do the loop
   * ( numbers divide by 10 and mod by 10 ) to get the every
   * digit’s value, and retrieve the correspondent word from
   * the string array.
   * The final results is connected with necessary symbols and
   * return as a format of string.
   *
   * @param number
   * @return
   */  
  public String convertLessOneThousand(int number) {
    String tempresult;
    String connect="-";
    String andsign="AND ";
   
    //No hyphen for cardinal numbers.
    if (number % 10 == 0) connect="";
    if (number % 100== 0) andsign="";
   
    if (number % 100 < 20){
    tempresult = numNames[number % 100];
    number /= 100;
       }
   
    else {
    tempresult = numNames[number % 10];
        number /= 10;
        tempresult = tensNames[number % 10] +connect
        + tempresult.trim();
        number /= 10;
       }
   
    if (number == 0)  return tempresult;
   
    return  numNames[number]+" HUNDRED "+ andsign
            + tempresult.trim();
}
 
 
  /**This method is used to convert those integers more than
   * four digits, alculate both the millenary unit and the other
   * unit. The final output results is connected with necessary
       * symbols and return as a format of string.
   * @param number
   * @return
   */
  public String convertAboveThousand(int number){
   String tempresult="";
  
   if (number == 0) tempresult="ZERO";
  
   int i=0;
  
   do {
      int n = number % 1000;
      if (n != 0){
         String s = convertLessOneThousand(n);
         tempresult = s + majorNames[i]+tempresult;
        }
      i++;
      number /= 1000;
      } while (number > 0);

   return tempresult;
 
 
  }
 
/**The convertToWord method first get both the integer
* part and the decimal part of  the input parameter,
* change the decimal part into integer for converting.
* Then using the other two integer converting method to
* get the integer and decimal part words string and
* connect them with currency units.
* The final output results in a format as string.
* @param moneyValue
* @return
*/
public   String convertToWord( double  moneyValue){
double  money  =  moneyValue  +   0.005 ; //to avoid round
String Dollars  =  "" ;
String Cents = "";
String connect = "";
String decimal;
String integer;
int intpart;
int decimalpart;


intpart = (int) money;
decimalpart = (int)(100*(money-(float)intpart));
decimal = convertLessOneThousand(decimalpart);
if(decimalpart !=0)
Cents = " CENTS";
if(intpart == 0)
return "ZERO DOLLAR"+ decimal+Cents;

if(intpart/1000>0){
Dollars =" DOLLARS";
integer = convertAboveThousand(intpart); 
}
else {
     Dollars =" DOLLARS";
     integer = convertLessOneThousand(intpart);
}

if(Cents.length()!=0){ connect =" AND";}


return  integer + Dollars + connect + decimal + Cents;

}






}
0 请登录后投票
   发表时间:2010-05-07  
oh my god
0 请登录后投票
   发表时间:2010-05-08  
亿迅,比较清楚,前段时间天天碰面,人太多了,不过现在搬了,不知道搬哪里去了。
亿迅这种,国企性质,招人太主观了,如果应聘你的那个人心情好,可能你就进去了。

“ps:原本想进电信项目的公司,业务广,项目种类也多,可惜挑战失败,最后只能确定了一个小公司的offer(5.5k),又要熬了! ”,只清楚点广州电信的计费是他们做的,至于你说的挑战不知道是不是,他们能给的工资估计和你现在拿的差不多。
0 请登录后投票
   发表时间:2010-05-08  
第二题可以用数组来做处理,就能舍弃那一大段if else或者switch了
2 请登录后投票
   发表时间:2010-05-08  
亿讯能给你的工资,广州随便一个公司都能给你,又累!没兴趣!
0 请登录后投票
   发表时间:2010-05-08  
请问 lz 几年工作经验了 ??
0 请登录后投票
   发表时间:2010-05-08  
pdw2009 写道
亿讯能给你的工资,广州随便一个公司都能给你,又累!没兴趣!

不是你能力不行,只是大家不互不合适。

不过,加强自己的能力还是不错的。
0 请登录后投票
   发表时间:2010-05-09  
4月份去过面试了一次。亿讯的工作环境跟作坊一样,而且笔试题又多又累,笔试完还有机试,机试完还面试了半个小时。无语了,他们怎么还用这套题目啊,不去也罢
0 请登录后投票
论坛首页 招聘求职版

跳转论坛:
Global site tag (gtag.js) - Google Analytics