Given an array of positive and negative integers, re-arrange it so that you have positive integers on one end and negative integers on other

后端 未结 30 2592
醉梦人生
醉梦人生 2020-12-07 07:37

I recently came across a Microsoft Interview Question for Software Engineer.

Given an array of positive and negative integers, re-arrange it so that you

30条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-07 08:19

    I have hard-coded the values of the array. However it will work any set of integers.

        int[] n={2,-3,1,5,-10,-8};
        int k=0;
        for(int i=1;i

提交回复
热议问题