Arts打卡第6周

时间:2019-05-12 23:34:58   收藏:0   阅读:283

Algorithm:

 移动零
 

Given an array nums, write a function to move all 0‘s to the end of it while maintaining the relative order of the non-zero elements.

Example:

Input: [0,1,0,3,12]
Output: [1,3,12,0,0]

Note:

  1. You must do this in-place without making a copy of the array.
  2. Minimize the total number of operations

答案:

class Solution {
    public void moveZeroes(int[] nums) {
        int count;

        int n;

        n = 0;
        count = 0;
        for (int i = 0; i < nums.length; i++){
            if (nums[i] == 0){
                count++;
            }else{
                nums[n] = nums[i];
                n++;
            }
        }
        for (int j = 0; j < count; j++){
            nums[n] = 0;
            n++;
        }
        for(int k = 0; k < nums.length; k++){
            System.out.print(nums[k]);
        }
    }
}

Review:https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-dispatcher-handler

讲了spring的DispatcherHandler  它的作用有,接受前段的请求,进行路由分发,找到对应的处理器。处理结果返回前端,以及处理异常。

Tip:

mysql if语句的使用:

SELECT if(false,sum(c.tax_data),SUM(c.fiscal_ret))FROM corp_tax c WHERE c.corp_year = 2018 and c.corp_month =6  AND park_id = 1

 

If 后面的括号如果是false会选择第二个值,如果是true,会选择第一个值。

Share:https://mp.weixin.qq.com/s/7D19F0oGYMBTJ3vlm2x_1A 这一篇是uml建模图的介绍。

 

原文:https://www.cnblogs.com/prader6/p/10854227.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!