中软面试题-最新

      中软的面试比较经典,也比较严格,一般有四轮,类似于微软的面试。中软面过以后,根据项目组,会推到美国微软那边运用live meeting & con-call 再面一次。以下是我的面试题及个人的小分析,拿出来和大家share一下。希望更多的人能过这个坎。如有什么问题,可以一起交流。直接进入主题:

 1. English communication. (sale yourself, project information, your interesting,and how to deal with problem    you encounter etc.)

 2.  the using of key words "new".

     Regarding this problem, you can refer to my other blog with this path: new . or you can get more information from internet.

3.Write a method which can remove the same unit from a Array which has been sorted.

//在排序好的数组中移除相同的元素
public   int  [] RemoveCommon( int  [] a)
{
       
if  (a.Length == 0 )
    {
        
return  a;
    }            
    List 
< int >  Result  =   new  List < int > ();
    
int  i , j;
    i 
=  j  =   0 ;
    
int  temp  =  a[ 0 ];

    
while  (i  <  a.Length)
    {
        
if  (a[i]  !=  temp)
        {   
            j
++ ;     
            temp 
=  a[i];
            Result.Add(temp);    
        }
        i
++ ;
    } 
    
//  convert List to Array
    
// ......
     return  Result;            
}

4. Judge Triangle and write test case for your code.

判断一个三角形,如果是等边的返回1,等腰返回2,其他的返回3,不能构成三角形的返回 4。 再编写test case 测试
判断一个三角形,如果是等边的返回1,等腰返回2,其他的返回3,不能构成三角形的返回  4 。 再编写test  case  测试
public   int  Triangle( int  a,  int  b,  int  c)
{           
    
if  (a  <=   0   ||  b  <=   0   ||  c  <=   0 )
    {
        
return   4 ;
    }
    
int  [] arry  =   new   int  [ 3 ] { a, b, c };
    Array.Sort(arry);
    
int  min, mid, max;
    min 
=  arry[ 0 ];
    mid 
=  arry[ 1 ];
    max 
=  arry[ 2 ];
    
if  (max - mid < min)   //  注意:用这个去判断是否能构成三角形
    {
        
return   4 ;   // 不能构成三角形
    }
    
if  (min  ==  max)
    {
        
return   1 ;   // 等边
    }
    
else   if  ( mid == min  ||  mid  ==  max)
    {
        
return   2 //  等腰
    }
    
else
        
return   3 ;    //  其他         
}

在这里,我最想提的就是这一题了,因为,我们知道,判断三角形,我们常用 两边之和大于第三边。但是,在这里,就不能用了。例如: a= int.MaxValue, b=int.MaxValue, c=int.MaxValue, 这时候三边肯定能构成三角形,但是,a+b 的和已经超过了int 型的最大值。造成内存溢出。 有人说,内存溢出 就是 0 或者负数,用这个不就可以判断吗?这个还真不行。你可以多写几个test case 试试。

Test case:

其他的普通的case,我就不写了,在这里就强调一下,边界值的问题(也就是常说的 临界值)。int.maxvalue, 0 etc.

5.Reverse string.

字符串反转,例如: string str="I love china", 反转后就是 str="china love I".
private   char  [] Convent( char  [] str, int  start,  int  end)
{
    
char  temp;
    
int  len  =  end  -  start;          
    
int  i = 0 ;
      
while (i < len / 2 )
      {
           temp  =  str[start + i];
           str[start  + i]  =  str[end  - -   1 ];
           str[end - i - 1 =  temp;
           i ++ ;
        }
    
return  str;
}
public   string  Reverse( string  str)
{
    
if  (String.IsNullOrEmpty(str))
    {
        
return   null ;
    }
     
char  [] objstr  =  str.ToCharArray(); ;
     
int  length = objstr.Length;
     objstr  =  Convent(objstr, 0 ,length);
     
int  i  =   0 ;
     
int  start = 0 ,end = 0 ;
    
while  (i  <  length)
    {                 
        
if  (objstr[i]  ==   '   ' || i == length - 1 )
        {
            
if  (i  ==  length  -   1 )
            {
                end  =  i  +   1 ;
            }
            
else
            {
                end  =  i;
            }
            objstr  =  Convent(objstr, start, end);
            start  =  end + 1
         }
         i ++ ;
    }
     
return   new   string (objstr);
}

6. Find the most width level in a tree and return the count of level, if there are many one, just return the nearest level. (it can be found in the internet)

寻找树的最宽层,并返回那层的层数(如有多个最宽层,返回离根节点最近的层数)
static   int   M  10   // 假设二叉树最多的层数
int  Width(BinTree T)
 { 
  
int   static  n[M]; // 向量存放各层结点数
   int   static  i = 1 ;
  
int   static  max = 0 ; // 最大宽度
   if (T)
   {
    
if (i == 1 // 若是访问根结点
     { 
      n[i] ++ // 第1层加1
      i ++ // 到第2层
       if (T -> lchild) // 若有左孩子则该层加1
       n[i] ++ ;
      
if (T -> rchild) // 若有右孩子则该层加1
       n[i] ++ ;
     }
    
else
     {  // 访问子树结点
      i ++ // 下一层结点数
       if (T -> lchild)
       n[i] ++ ;
      
if (T -> rchild) 
       n[i] ++ ;
     }
    
if (max < n[i])max = n[i]; // 取出最大值
     Width(T -> lchild); // 遍历左子树
    i -- // 往上退一层
    Width(T -> rchild); // 遍历右子树
   }
  
return  max;
 } // 算法结束

7. Implement the function: Int ConvertToInt(string num)

实现 Int ConvertToInt(string num)
public    int  ConvertToInt( string  num)
{          
    
int  result = 0 ;
    
int  temp = 0 ;
    
if  ( ! string .IsNullOrEmpty(num))
    {
        
if  (IsInteger(num))
        {
            
for  ( int  i  =   0 ; i  <  num.Length; i ++ )
            {
                temp  =  result;
                result  =  result  *   10   +  (( int )num[i]  -   48 );  // 0 的Asscall码 是48
                 if  (temp  ==  result)
                    
continue ;
            }
            
if  (temp  !=  result)
            {
                
throw   new  Exception( " overflow " );
            }
        }
       
    }         
    
return  result;    
}
//  判断字符串是否是整数。
public   bool  IsInteger( string  strIn)
{
    
bool  bolResult  =   true ;
    
if  (strIn  ==   "" )
    {
        bolResult  =   false ;
    }
    
else
    {
        
foreach  ( char  Char  in  strIn)
        {
            
if  ( char .IsNumber(Char))
                
continue ;
            
else
            {
                bolResult  =   false ;
                
break ;
            }
        }
    }
    
return  bolResult;
}

  关于上面的判断字符串里转换后是否是整数,还有其他的方法:

判断是否是数字
public   bool  isnumeric( string  str)
{
    
char [] ch  =   new   char [str.Length];
    ch  =  str.ToCharArray();
    
for  ( int  i  =   0 ; i  <  ch.Length; i ++ )
    {
        
if  (ch[i]  <   48   ||  ch[i]  >   57 )
            
return   false ;
    }
    
return   true ;
}

8. Quick sort. (you can get it from internet)

快速排序
static   public   void  Quicksort( int [] array,  int  begin,  int  end)
{
    
if  (begin  <   0   ||  end  <   0   ||  begin  >  end)
        
return ;
    
int  left  =  begin, right  =  end, temp;
    temp 
=  array[left];
    
while  (right  !=  left)
    {
        
while  (temp  <  array[right]  &&  right  >  left)
            right
-- ;
        
if  (right  >  left)
        {
            array[left] 
=  array[right];
            left
++ ;
        }
        
while  (temp  >  array[left]  &&  right  >  left)
            left
++ ;
        
if  (right  >  left)
        {
            array[right] 
=  array[left];
            right
-- ;
        }
    }
    array[right] 
=  temp;
    Quicksort(array, right 
+   1 , end);
    Quicksort(array, begin, right 
-   1 );
}
Ok, that is all.

那次面试比较久,接近四个小时。后面被推到微软那边面试,面试题,详见后面解析。 

阅读终点,创作起航,您可以撰写心得或摘录文章要点写篇博文。去创作
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
国际外包是一家专业提供件开发、外包和咨询服务的公司。华为ETL(Extract, Transform, Load)是华为公司用于数据仓库建设与管理的关键技术之一,用于将数据从不同的来源提取出来、进行转换和加载到目标数据仓库。 华为ETL面试通常会涉及以下几个方面的内容: 1. ETL的基本概念和原理:面试官可能会询问ETL的定义、核心工作流程和重要性等。应聘者需要清楚地解释ETL的概念和作用,并能够说明其在数据仓库建设和管理的重要性。 2. 数据提取(Extract):面试官可能会询问你对数据提取过程的理解和应用实践。你需要了解不同的数据来源和提取方法,例如从关系型数据库、文件或API提取数据,并且能够解释数据提取过程可能遇到的挑战和解决方案。 3. 数据转换(Transform):面试官可能会询问你在数据转换过程的经验和技能。你需要掌握数据清洗、转换和整合的方法和技术,例如数据规范化、格式转换、数据合并等,并能够描述数据转换过程的一些典型问和解决方案。 4. 数据加载(Load):面试官可能会询问你对数据加载的理解和应用实践。你需要了解不同的数据加载方法和策略,例如全量加载、增量加载、并行加载等,并能够解释数据加载过程的一些常见问和解决方案。 此外,面试还有可能出现一些与ETL相关的工具和技术的问,例如数据抽取工具、数据转换语言、数据质量控制等。应聘者需要对这些工具和技术有一定的了解和应用经验。 最后,无论面试问到哪个方面的内容,应聘者需要准备足够的实际案例和解决方案,以便能够展示自己的实际经验和能力。只有通过具体的实践案例,才能更好地回答面试官的问,展现自己的能力和价值。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值