Home  >  Article  >  Technology peripherals  >  Using this method, anyone can reach the first place in leetcode (can be copied)

Using this method, anyone can reach the first place in leetcode (can be copied)

WBOY
WBOYforward
2023-10-20 14:17:01793browse

A few days ago, someone shared a method of using GPT to answer questions in leetcode, learn algorithms, inspire ideas, and improve programming skills.

I didn’t believe it at first, but I tried it myself and was shocked! Is AI’s ability to understand problems and solve problems with coding now so useless?

Using this method, anyone can reach the first place in leetcode (can be copied)

I found a more complex algorithm question in leetcode:

Using this method, anyone can reach the first place in leetcode (can be copied)

From an array Find the four-tuple that satisfies the condition in nums[].

I began to think that AI should not be able to understand what is:

"a * b = c * d"

"a != b != c != d"

And, I think AI should not be able to understand the counting logic through two examples.

It turns out that I underestimated AI.

Voiceover: In this experiment, the tool used is Claude.

Using this method, anyone can reach the first place in leetcode (can be copied)

In the prompt, I set the identity and capabilities of the AI, as well as the precise mission:

(1) Make it clear that AI is a programmer and is good at algorithms;

(2) Clarify the function prototype;

(3) Copy the title description in leetcode;

What did Claude output?

Using this method, anyone can reach the first place in leetcode (can be copied)

(1) gives a simple and crude four-fold loop solution;

(2) gives the algorithm logic;

(3) gives the time complexity and space complexity;

(4) gives the system prompt: I am not good at solving mathematical problems;

The time complexity is a bit high. I would like to ask Claude if there is room for optimization:

Using this method, anyone can reach the first place in leetcode (can be copied)

(1) Claude uses an unordered_map space for time;

(2) gives the optimization logic;

(3) gives the time complexity and space complexity;

Push it further I pressed Claude to see if there was room for further optimization:

Using this method, anyone can reach the first place in leetcode (can be copied)

(1) Claude used an algorithm that he didn’t understand;

(2) gives the optimization logic;

(3) gives the time complexity and space complexity;

Voiceover: Well, this can really be optimized to O(n) ?

We did not use a dedicated AI for writing code, nor did we use GPT, which is currently known as the most powerful AGI tool. We did not even use the upgraded Claude2, but the AI’s ability to understand symbols and logic, As well as coding and iterative optimization problem-solving abilities, it really shocked me.

For programmers, it doesn’t matter how many questions they have answered in leetcode or how many ACs they have. With the help of AI, it can inspire us to broaden our thinking and improve our abilities. This is something that everyone should learn and think about.

#In every wave of technological revolution, it is not the tools and technologies that eliminate us, but the person behind them who first mastered the tools and technologies.

What do you think of this wave of AI revolution?

Voiceover: The title of this article was generated by AI.

The above is the detailed content of Using this method, anyone can reach the first place in leetcode (can be copied). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:51cto.com. If there is any infringement, please contact admin@php.cn delete