6.6 learning record

Arnhem practice

company project

Information dissemination module

Mysql报this is incompatible with sql_mode=only_full_group_by错误

problem causes

This error occurs problems mysql 5.7 version and above will occur:

   mysql 5.7版本默认的sql配置是:sql_mode="ONLY_FULL_GROUP_BY",这个配置严格执行了"SQL92标准"。

   很多从5.6升级到5.7时,为了语法兼容,大部分都会选择调整sql_mode,使其保持跟5.6一致,为了尽量兼容程序。
复制代码
Problem Principle

When sql execution, the emergence of reasons:

Is simply: the resulting output is called the target list, is to follow the back of select field, there is a local group by column, that is,

Followed behind the group by fields. Since the turn of the ONLY_FULL_GROUP_BY settings, so if a field is not in the target list

And group by field simultaneously, or the aggregate value of the function, then this sql mysql query is considered illegal and will be reported error.

Solutions

I used temporary solution, permanent solution needs to be modified my.ini in the sql_mode, zip installed version does not have this file, you need to create your own online tutorials by a My.ini and then re-create the service. Temporary solution: using sql statement to temporarily modify @@ GLOBAL.sql_mode = the SET STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION; Note: This method can solve the problem directly, but after the restart mysql will be invalid.

Click the corresponding function 500 returns a status code

the reason

As the project is in a different calling interface module, the function call interface in another module, although the module has started, but after viewing the interface is not configured to invoke found in nginx, nginx according to the port and then reconfigure the project to start, after the restart nginx normal.

Expand learning

Encountered pit

About Invoke add () >> In the List object type <List <method

public void test() {
List<String>   tem = new ArrayList<>();
List<List<String>> lists = new ArrayList<>();
lists.add(tem); //注意这里如果直接添加tem,后续如果有对tem的操作,同样会修改添加进lists里的tem对象。
}
复制代码

Therefore, it should be changed

lists.add(new ArrayList<>(tem));
复制代码

Create a new object added to the lists, the subsequent modification of the tem does not affect the object lists in.

Daily question

338. bit count

topic

Given a non-negative integer num. For 0 ≤ i ≤ i, each digital num range, which calculates the number of binary digits 1 and returns them as an array.

Example 1:

Input: Output 2: [0,1,1] Example 2:

Input: Output 5: [0,1,1,2,1,2]

Thinking

This type of conversion if the subject -> way traversal time complexity is O (n ^ 2), since the calculation is the number 1, you can try to achieve a bit operation to solve the problem of traversing. A number n-1 and n with the operation, can be eliminated rightmost we need only claim '1', while for n-1, n is a number in the number of n-1 in a 1 plus, n-1 number 1 of. The title will become a kind of recursive problem.

Code

 public static int[] countBits(int num) {
        int[] res = new int[num+1];
        for(int i = 1; i <= num; i++) {
            res[i] = res[i & i - 1] + 1;
        }
        return res;
    }
复制代码

40 Total composition II

topic

Given an array of candidates and the number one goal target, you can find all the candidates for the target numbers and combinations.

Each number candidates used only once in each combination.

Description:

All figures (including the target number) are positive integers. Solution Set can not contain duplicate combinations thereof. Example 1:

Input: candidates = [10,1,2,7,6,1,5], target = 8, the set is solved: [[1, 7], [1, 2, 5], [2, 6], [1, 1, 6]]

Thinking

Title difficult, recursively through the array, if the value is greater than the initial target returned directly,

Code

class Solution {
    public List<List<Integer>> combinationSum2(int[] candidates, int target) {
    Arrays.sort(candidates);
               List<List<Integer>> lists = new ArrayList<>();
                   List<Integer> tem = new ArrayList<>();
                 util(candidates, target, 0,lists,tem,0);
               return  lists;
    }

    public static void util(int[] candidates, int target, int start,  List<List<Integer>> lists,  List<Integer> tem, int i) {
        for(int j = i; j < candidates.length; j++) {
            start += candidates[j];
            if(start > target) {
                start -= candidates[j];
                break;
            }
            if(start == target) {
                tem.add(candidates[j]);
                if(!lists.contains(tem))
                lists.add(new ArrayList<>(tem));
                start -= candidates[j];
                tem.remove(tem.size() - 1);
                break;
            }
            if(start < target) {
                tem.add(candidates[j]);
                util(candidates, target, start, lists, tem, j+1);
                tem.remove(tem.size() - 1);
                start -= candidates[j];
            }
        }

    }
}
复制代码

Reproduced in: https: //juejin.im/post/5cf8697251882539c33e4d6b

Guess you like

Origin blog.csdn.net/weixin_33735676/article/details/91459843