论坛首页 Java企业应用论坛

一道8K的面试题

浏览 24616 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (1) :: 隐藏帖 (18)
作者 正文
   发表时间:2011-09-08  
无语!是我理解能力差,还是楼主错别字太多,理解题目意思真费劲。
好好描述问题,有这么难?
0 请登录后投票
   发表时间:2011-09-08  
看到后面的回复,我欣慰了!
这题目能按照楼主的描述解答出来,至少值1W+
0 请登录后投票
   发表时间:2011-09-08  
吓我了,我看了二次没明,我想再看下评论,明白下,原来,哈哈。。。
0 请登录后投票
   发表时间:2011-09-08  
cn-done 写道
看到后面的回复,我欣慰了!
这题目能按照楼主的描述解答出来,至少值1W+

5W+都不是不可能
0 请登录后投票
   发表时间:2011-09-08  
看不懂就对了,面试公司就是要求面试人能猜明意思
0 请登录后投票
   发表时间:2011-09-08  
牛人分两种:
   一种是把复杂的问题简单化,
   另一种是把简单的问题复杂化。
0 请登录后投票
   发表时间:2011-09-08  
觉得可以用Comparator 比较器啊!
0 请登录后投票
   发表时间:2011-09-08  
诶,貌似我有那么点明白了。。。
0 请登录后投票
   发表时间:2011-09-09   最后修改:2011-09-09

                  List<String> list = new ArrayList<String>(); //作为测试,只存放了几条数据 
                  list.add("###20110810$$$hello3434334343443hhh20110810");
                  list.add("###20110810$$$world3434334343443hhh20110810"); 
                  list.add("###20110811$$$hello3434334343443hhh20110811");
                  list.add("###20110811$$$world3434334343443hhh20110811");
                  list.add("###20110812$$$hello3434334343443hhh20110812");
                  list.add("###20110812$$$world3434334343443hhh20110812"); 
                  list.add("###20110813$$$hello3434334343443hhh20110813");
                  list.add("###20110813$$$world3434334343443hhh20110813");
                  list.add("###20110814$$$hello3434334343443hhh20110814");
                  list.add("###20110814$$$world3434334343443hhh20110814");
                  list.add("###20110815$$$hello3434334343443hhh20110815");
                  list.add("###20110815$$$world3434334343443hhh20110815");

                  Set<String> set = new LinkedHashSet<String>(); //代表要根据set集合分组,

                  set.add("20110810");
                  set.add("20110811");
                  set.add("20110812"); 
                  set.add("20110813");
                  set.add("20110814");
                  set.add("20110815");

                   Map<String,List<String>> dataMap = new TreeMap<String,List<String>> (new Comparator<String>() { 
                                    public int compare(String o1, String o2) { 
                                                     if (o1 == null || o2 == null) 
                                                                 return 0; 
                                                     return o1.compareTo(o2); 
                                    } 
                     });


                 for(String str : list){ 
                                 String[] arrayStr = str.split("\\$\\$\\$");
                                 String newStr = arrayStr[0].replace("###", "");
                                 if(set.contains(newStr)){
                                                 List<String> valueList = dataMap.get(newStr);
                                                 if(valueList == null ){
                                                               valueList = new ArrayList<String>();
                                                }
                                                 valueList.add(arrayStr[1]); 
                                                 dataMap.put(newStr,valueList);
                               } 
                }
                 //打印结果 
               for(String key : dataMap.keySet()){
                                System.out.println("key:" + key + "  value:"+ dataMap.ge(key)); 
               }

 

0 请登录后投票
   发表时间:2011-09-09  
key:20110810  value:[hello3434334343443hhh20110810, world3434334343443hhh20110810]
key:20110811  value:[hello3434334343443hhh20110811, world3434334343443hhh20110811]
key:20110812  value:[hello3434334343443hhh20110812, world3434334343443hhh20110812]
key:20110813  value:[hello3434334343443hhh20110813, world3434334343443hhh20110813]
key:20110814  value:[hello3434334343443hhh20110814, world3434334343443hhh20110814]
key:20110815  value:[hello3434334343443hhh20110815, world3434334343443hhh20110815]
0 请登录后投票
论坛首页 Java企业应用版

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