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 Method for This Chapter
Since all the code on this site supports C++, Java, Python, Golang, and JavaScript, this chapter will introduce the basic usage of each of these languages. You can choose the language you wish to use in the future for your studies.
For beginners, you can start with any one of these programming languages and then quickly move on to learning the principles of data structures and problem-solving techniques in algorithms, which is the main focus of this site.
Why No C Language
Readers often ask why we don't provide C language code, given that most people learn it in school.
The main reason is that the C language standard library is too simple and does not offer many basic data structures, which is not ideal for solving algorithm problems.
Complex algorithms are inherently abstract and difficult to understand. Adding low-level programming details only increases the difficulty of learning, which is counterproductive for an algorithm tutorial.
If you insist on using C, you might consider using C++ as an alternative. C++ is a superset of C, compatible with standard C, and also offers a rich standard library with ready-to-use implementations of common data structures, balancing performance and practicality, which makes solving algorithm problems much more convenient.
Choosing a Programming Language
This section is aimed at beginners, so let's briefly introduce some characteristics of various programming languages and their focus areas in practical development.
Firstly, technical roles can be divided into two main categories: frontend and backend. Simply put, the frontend involves 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 because it is the primary language for web frontend development and the standard scripting language for browsers.
For the backend, the technology stack is more diverse. C++/Java/Python/Golang are common choices, and JavaScript can also be used for backend development through node.js frameworks.
For example, in web development, Java/node.js/Python are common backend choices. Golang is primarily used for cloud-native development, C++ for high-performance systems, and Python is the mainstream language in the fields of AI and data analysis.
In practice, most people use multiple languages simultaneously. Moreover, when you change jobs, the technology stacks of the new and old companies will likely differ, requiring you to learn anew. Therefore, programming languages are merely tools, and your career will inevitably involve multiple languages.
For your first language, if you plan to work in frontend development, learning JavaScript is essential. You might choose JavaScript. If you're interested in backend development, consider the specific field you want to work in to select the appropriate programming language.
If you are still undecided, I would recommend starting with Python. Python is easy to learn and practical. It's convenient for tasks such as writing automation scripts.
Additionally, Python is well-supported by various AI platforms, making it easier for AI to assist you in writing Python scripts.