ARTS Week 1

An algorithm week, an English review technical articles, learning a technical skill, a technical point of view and share ideas

Algorithm

Title: two numbers and

Given an array of integers, index returns these two figures, so that they add up to a specified number.

Because the index is the return of two numbers, so you can not sort the array. Even if the sort should retain the original index.

Ideas 1

Two-cycle

1
2
3
4
5
6
7
8
9
10
11
12
class  {
public int[] twoSum(int[] nums, int target) {
for(int i = 0; i < nums.length; i++){
for(int j = i + 1; j < nums.length; j++){
if(nums[i] == target - nums[j]){
return new int[]{i,j};
}
}
}
throw new RuntimeException("not found");
}
}

beats 26.64%

Ideas 2

Use HashMap, space for time

1
2
3
4
5
6
7
8
9
10
11
12
class  {
public int[] twoSum(int[] nums, int target) {
HashMap<Integer,Integer> map = new HashMap(nums.length);
for(int i=0;i<nums.length;i++){
if(map.containsKey(target-nums[i])){
return new int[]{map.get(target-nums[i]),i};
}
map.put(nums[i],i);
}
大专栏  ARTS 第 1 周word">throw new RuntimeException("not found");
}
}

beats 99.70%

Review

The Key To Accelerating Your Coding Skills

In the process of learning to program, starting from a point in time will feel "epiphany", this time called the inflection point.

The first is the tutorial phase (3-8 weeks rigorous coding), at this stage should pay attention to detail, summarize learning from the error message. Recognizing the programming can not be done overnight, is the need for long-term continuous learning.

Second phase inflection point (right frame of mind of 2-4 weeks), you will find that at this stage of the coding efficiency is improved by 10 to 20 times. However, do not meet, always left empty cup mentality, stick a little progress every day. Emphasis on basic learning algorithms and data structures.

Finally, the turning point, no longer blind pursuit of new technology that can see through the nature of the new technology. Able to learn new techniques based on knowledge has been learned. Accumulate its own code base.

How to tell if passed the inflection point? In fact, it is to change the mentality. Accept the software development is an ongoing process of learning. Continuous learning is accepted in order to solve more complex problems.

Tip

Share a comment Boot week of Spring @Profile, what use is it?

It can mark any @Component, @Configurationand @Beanon to decide whether to load the current environment.

For example, used in the project to Swagger, only we want to use in development and test environments.

1
2
3
4
5
6
7
8
2
@Configuration
@Profile("dev","test")
public class Swagger2 {



}

When spring.profiles.active=dev,testtime, Swagger can be accessed.

Non-generated environment can also be written as @Profile("!prod")

Note: The @Beanuse of the method @Profilewhen there may be a special case: For a Java method overload the same name of @Beanthe method (similar to the overloaded constructor) must consistently declared on all overloaded methods @Profileconditions.

Share

Recently the company recruit Java developers, resume screening by me, to talk about my personal point of view from the perspective of technical personnel more interview opportunities resume is what.

  • A complete resume. Including at least personal information, work experience, project experience, skills
  • Complete project experience. Including project profiles, architecture, use of technology, responsibility, achievement, harvest. If you can show it better.
  • skill. It will demonstrate the technology

bonus:

  • Entry through manufacturers
  • personal blog
  • Github

Precautions:

  • Resume should be true
  • Resume writing information not insignificant, focus.
  • To read your resume, imagine you are a recruiter, access to what information from your resume.

Guess you like

Origin www.cnblogs.com/lijianming180/p/12147670.html