Chapter Introduction
All the code on this site, along with the accompanying plugins, supports Java, C++, Golang, Python, and JavaScript. This chapter will introduce how to use these programming languages so that readers without a programming background can quickly start practicing problems.
Intended Audience of This Chapter
This chapter is aimed at absolute beginners in programming.
If you have some experience with solving algorithm problems, you can skip this chapter.
If you are familiar with a programming language but have never solved algorithm problems, you only need to read LeetCode Guidelines in this chapter to understand the basics of the platform before moving on to the next chapter.
If you wish to use the Algorithm Visualization Panel to test your algorithms but are not familiar with JavaScript, you can read JavaScript Basics.
Chapter Content
This chapter is tailored for the scenario of practicing algorithm problems, focusing on the basics of programming languages.
After reading this foundational chapter, you won't become an expert in the programming language, but you will be able to start solving problems on LeetCode.
Algorithms themselves are not closely tied to programming languages; they are more about a way of thinking. In fact, you could describe an elegant algorithm implementation by writing on paper.
Therefore, the requirement for programming languages in solving algorithm problems is quite low. As long as you can use the standard library, control statements (like if-else), and ensure the code runs without syntax errors, you can start practicing problems.
This chapter includes: basic syntax of the programming language, control statements, commonly used data structures from the standard library, and guides you to solve some simple algorithm problems on LeetCode for practice.
Advanced uses of the programming language, language features, common frameworks, and project development are larger topics that will not be covered in this chapter.
Learning Approach of This Chapter
As all the code on our site supports C++, Java, Python, Golang, and JavaScript, this chapter will introduce the basic usage of each language. You can choose the language you plan to use in the future for learning.
For programming beginners, it's sufficient to pick any one of the programming languages introduced in this chapter to get started, and then quickly move on to learning data structure principles and algorithm-solving techniques, which is the main focus of our site.
Why Not C Language
Readers often ask why we don't include C language code on the site, considering many people learned C language in school.
The main reason is that the C language standard library is too simple and doesn't offer basic common data structures, which is not user-friendly for solving algorithm problems.
For complex algorithms, which are inherently abstract and hard to understand, mixing in low-level programming details can further increase the learning difficulty, which is counterproductive for an algorithm tutorial.
If you insist on using C language, you can choose C++ as an alternative. C++ is a superset of C, compatible with standard C, and offers a rich standard library with ready-to-use implementations of common data structures, balancing performance and practicality, making it very convenient for algorithm problems.
Choice of Programming Language
Considering this chapter is aimed at complete beginners, we will briefly introduce the characteristics of several programming languages and their focus areas in actual development.
Firstly, technical roles can be divided into frontend and backend. Simply put, the frontend is the interface that directly interacts with users, while the backend handles data and logic on the server side.
For the frontend, mastering JavaScript is essential as it is the mainstay of web frontend development and the standard scripting language of browsers.
For the backend, there are various technology stacks. C++/Java/Python/Golang are common choices, and JavaScript can also be used for backend development with the node.js framework.
For example, in web development, Java/node.js/Python are common choices for the backend. Golang is primarily used for cloud-native development, C++ for high-performance systems, and Python is the mainstream language in AI and data analysis fields.
In actual work, people usually work with multiple languages simultaneously, and when you switch jobs, the technology stack of the new company is likely different from the old one, requiring you to learn anew. Therefore, programming languages are just tools, and your career will inevitably involve multiple languages.
For your first language, if you aim to work in frontend-related fields, then learning JavaScript is essential, and you can choose JavaScript. If you plan to work in backend-related fields, look into your desired niche area to choose an appropriate programming language.
If you haven't decided yet, I would recommend starting with Python. Python is easy to learn, practical, and convenient for writing automation scripts and the like.
Moreover, an important factor is that various AI platforms currently offer excellent support for Python, making it more convenient to have AI assist you in writing Python scripts.