Tips and Tricks for Competitive Programmers | Set 1 (For Beginners) Last Updated : 05 Aug, 2024 Comments Improve Suggest changes Like Article Like Report This article is a collection of various tips that would help beginners of Competitive programming to get an insight of things that should or shouldn’t be done. Competitive programming can only be improved by “PRACTICE, PRACTICE AND PRACTICE”. Try to solve as many questions you can solve on sites like practice.geeksforgeeks.org. This will enhance your mind to think more on algorithms. Start with the beginner section, and when you feel comfortable with that, move on to higher level i.e. easy, medium, and hard and so on. Try to attempt all the questions yourself and don’t see the solution before attempting it. Don’t feel demotivated when you get wrong answers, it’s just part of the learning. The more you practice the more you learn. Just be passionate about coding and practice. Few Days before you begin: Learn -Practice-Repeat -Try to learn a new concept on a daily basis. Solve questions daily, one or two if not more!! After going through a new algorithm or technique, we should immediately search for its applications and attempt problems. Like if you learn dynamic programming, try to finish up all its problems. Adapt the habit of reading which most of the youngsters don’t have nowadays. Write before coding- Implement all algorithms yourself rather than copying from someone else. Make yourself written notes while studying these concepts. Mathematics is great area to start competitive programming. Getting Edgy- During practice always solve that problem that is just at the edge of your knowledge i.e., you don't exactly know how to solve the problem but you know what you should know to solve that problem. For example, you look at the problem and you can tell that it's a simple graph problem but you do not know anything about graph. Trees, Graphs, Algos- Make sure you are thorough with the concepts of trees, graphs and important algorithms as there is at least one question making use of their applications in every contest or a company hiring round. Short is sweet- Long contest is good for learning but try to take part in more and more short contests. Short contest is the real competitive programming. We should make it a must habit to spend some short time during peak hours in a programming forum where top coders usually hangout sharing their insights and often get into discussions. Complexity is Complex- Do not be obsessed with lower and lower execution time. Do not waste time on over-optimizing your solution. If the solution is accepted, move on to next problem. First just get into the habit of coding daily and then worry about complexities. Hard must come- Some people say Stick to one website for practice while others believe you must taste all bunches. Whatever you decide , slowly but surely start solving harder problems. Target Job– If you are frequently participating in the contests which are meant for jobs then make sure to read all previous questions, algorithms and related stuff to cut short your efforts as well as selection time.You must attempt previous company questions too. Last day before the contest especially If you are attempting the contest for Getting Hired Don’t look for new problems because that may create panic in your mind. Take sufficient amount of sleep the night before. Keep your mind relaxed and stay stress free During the contest Be Attentive - Most of the programmers when see a new question, they will hurry in typing it on system before pre planning or before writing logic to crack that task. Sometimes they will stick at a point in between of typing code in system and might need to start coding again. If we avoid typing in system before cracking the logic it will be helpful to save time. One should start with: Reading the problem statement at least twice Analyzing the problem statement Input output pattern should be kept in mind before submission and read problem many times to understand concept behind problem. Use pen and paper to develop the logic and then code Read the instructions of the contest carefully (Time limit, Meaning of various symbols used in the contest page, Number of submissions allowed etc.) Clock is ticking- Keep an eye on the clock .If you are unable to solve a particular question, you very well have the option to go to next. Test the test cases- If your code is not accepted, then go through your code again and check about variable declaration, complexity of the code, and try checking your code for multiple numbers of test cases. After the contest Editorials are MUST- After submission; even if your code is accepted then just don’t jump on to the next question. Try to read editorial of the question , this will help you know better and efficient solution of that question. Geeks around may know better- Examining codes written by other eminent coders will reveal great insights (if it is allowed). Even reviewing other's solution to a problem we have solved might expose some of the unique features of the problem and aids us in viewing the same problem from a different point of view. The important point here is that- you may come across different algorithms that are used to solve questions, learn those algorithms and make sure that you understand them. Practice- Don't worry if you are unable to solve the questions there, it just means that you need more practice. Past teaches future- It is a good practice to stick to a problem which we are unable to solve for at least 2 days. On reviewing the solution, we will understand where we deviated from the correct path and would aid our thinking process in future attempts. We should make a note of the problems which we were unable to solve and hence, we went for the solution. We should make sure to review the same problem after a couple of weeks and attempt to solve it entirely. Time is precious- Preparation for anything is very important be it for a contest day, an exams or a project submission, which student mostly fail to do. Preparing at the last moment often fail short of the expectations. Give enough time to go through algorithms, sample problems and work upon your own strengths and weaknesses. Happy Coding!! This article is exclusively drafted by contributions of our Campus Geeks- Rahul Agarwal, Aditya Chatterjee, Shubham Singh Rajput, Vineet Sethia, Saiteja Reddy, Shaily Seth, Mudit Maheshwari and Ajay Jain. Tips and Tricks for Competitive Programmers | Set 2 (Language to be used for Competitive Programming) Comment More infoAdvertise with us Next Article Tips and Tricks for Competitive Programmers | Set 1 (For Beginners) K kartik Follow Improve Article Tags : GBlog Competitive Programming DSA GBlog-Competitive-Programming Similar Reads Competitive Programming - A Complete Guide Competitive Programming is a mental sport that enables you to code a given problem under provided constraints. The purpose of this article is to guide every individual possessing a desire to excel in this sport. This article provides a detailed syllabus for Competitive Programming designed by indust 8 min read Competitive Programming (CP) Handbook with Complete Roadmap Welcome to the Competitive Programming Handbook or CP Handbook by GeeksforGeeks! This Competitive Programming Handbook is a go-to resource for individuals aiming to enhance their problem-solving skills and excel in coding competitions. This CP handbook provides a comprehensive guide, covering fundam 12 min read Mathematics for Competitive ProgrammingMust do Math for Competitive ProgrammingCompetitive Programming (CP) doesnât typically require one to know high-level calculus or some rocket science. But there are some concepts and tricks which are sufficient most of the time. You can definitely start competitive coding without any mathematical background, but maths becomes essential as 15+ min read Pigeonhole Principle for CP | Identification, Approach & ProblemsIn competitive programming, where people solve tough problems with computer code, the Pigeonhole Principle is like a secret tool. Even though it's a simple idea, it helps programmers tackle complex challenges. This article is your guide to understanding how this principle works and why it's crucial 8 min read Euler Totient for Competitive ProgrammingWhat is Euler Totient function(ETF)?Euler Totient Function or Phi-function for 'n', gives the count of integers in range '1' to 'n' that are co-prime to 'n'. It is denoted by \phi(n) .For example the below table shows the ETF value of first 15 positive integers: 3 Important Properties of Euler Totie 8 min read Mathematics for Competitive Programming Course By GeeksforGeeksMathematics forms the foundation of problem-solving in Competitive Programming (CP). Mastering key mathematical concepts is crucial for approaching algorithmic challenges effectively. If you're an aspiring competitive programmer or someone who wishes to enhance your problem-solving skills, this Math 3 min read Number Theory for CPBinary Exponentiation for Competitive ProgrammingIn competitive programming, we often need to do a lot of big number calculations fast. Binary exponentiation is like a super shortcut for doing powers and can make programs faster. This article will show you how to use this powerful trick to enhance your coding skills. Table of ContentWhat is Binary 15+ min read GCD (Greatest Common Divisor) Practice Problems for Competitive ProgrammingGCD (Greatest Common Divisor) or HCF (Highest Common Factor) of two numbers is the largest positive integer that divides both of the numbers.GCD of Two NumbersFastest Way to Compute GCDThe fastest way to find the Greatest Common Divisor (GCD) of two numbers is by using the Euclidean algorithm. The E 4 min read Bit Manipulation for CPBit Manipulation for Competitive ProgrammingBit manipulation is a technique in competitive programming that involves the manipulation of individual bits in binary representations of numbers. It is a valuable technique in competitive programming because it allows you to solve problems efficiently, often reducing time complexity and memory usag 15+ min read Bit Tricks for Competitive ProgrammingIn competitive programming or in general, some problems seem difficult but can be solved very easily with little concepts of bit magic. We have discussed some tricks below in the previous post.Bitwise Hacks for Competitive Programming One-Liner Hacks of Bit Manipulation:One-Liner CodeFunctionx&1 7 min read Bitwise Hacks for Competitive ProgrammingPrerequisite: It is recommended to refer Interesting facts about Bitwise Operators How to set a bit in the number 'num': If we want to set a bit at nth position in the number 'num', it can be done using the 'OR' operator( | ).  First, we left shift '1' to n position via (1<<n)Then, use the 'O 14 min read Combinatorics for CPInclusion Exclusion principle for Competitive ProgrammingWhat is the Inclusion-Exclusion Principle?The inclusion-exclusion principle is a combinatoric way of computing the size of multiple intersecting sets or the probability of complex overlapping events. Generalised Inclusion-Exclusion over Set:For 2 Intersecting Set A and B: A\bigcup B= A + B - A\bigca 5 min read Greedy for CPBinary Search on Answer Tutorial with ProblemsBinary Search on Answer is the algorithm in which we are finding our answer with the help of some particular conditions. We have given a search space in which we take an element [mid] and check its validity as our answer, if it satisfies our given condition in the problem then we store its value and 15+ min read Ternary Search for Competitive ProgrammingTernary search is a powerful algorithmic technique that plays a crucial role in competitive programming. This article explores the fundamentals of ternary search, idea behind ternary search with its use cases that will help solving complex optimization problems efficiently. Table of Content What is 8 min read Array based concepts for CPWhat are Online and Offline query-based questions in Competitive ProgrammingThe query-based questions of competitive programming are mainly of two types: Offline Query.Online Query. Offline Query An offline algorithm allows us to manipulate the data to be queried before any answer is printed. This is usually only possible when the queries do not update the original element 4 min read Precomputation Techniques for Competitive ProgrammingWhat is the Pre-Computation Technique?Precomputation refers to the process of pre-calculating and storing the results of certain computations or data structures in advance, in order to speed up the execution time of a program. This can be useful in situations where the same calculations or data stru 15+ min read PreComputation Technique on ArraysPrecomputation refers to the process of pre-calculating and storing the results of certain computations or data structures(array in this case) in advance, in order to speed up the execution time of a program. This can be useful in situations where the same calculations are needed multiple times, as 15 min read Frequency Measuring Techniques for Competitive ProgrammingMeasuring the frequency of elements in an array is a really handy skill and is required a lot of competitive coding problems. We, in a lot of problems, are required to measure the frequency of various elements like numbers, alphabets, symbols, etc. as a part of our problem. Examples: Input: arr[] = 15+ min read Dynamic Programming (DP) for CPDP on Trees for Competitive ProgrammingDynamic Programming (DP) on trees is a powerful algorithmic technique commonly used in competitive programming. It involves solving various tree-related problems by efficiently calculating and storing intermediate results to optimize time complexity. By using the tree structure, DP on trees allows p 15+ min read Dynamic Programming in Game Theory for Competitive ProgrammingIn the fast-paced world of competitive programming, mastering dynamic programming in game theory is the key to solving complex strategic challenges. This article explores how dynamic programming in game theory can enhance your problem-solving skills and strategic insights, giving you a competitive e 15+ min read Game Theory for CPInteractive Problems in Competitive ProgrammingInteractive Problems are those problems in which our solution or code interacts with the judge in real time. When we develop a solution for an Interactive Problem then the input data given to our solution may not be predetermined but is built for that problem specifically. The solution performs a se 6 min read Mastering Bracket Problems for Competitive ProgrammingBracket problems in programming typically refer to problems that involve working with parentheses, and/or braces in expressions or sequences. It typically refers to problems related to the correct and balanced usage of parentheses, and braces in expressions or code. These problems often involve chec 4 min read MEX (Minimum Excluded) in Competitive ProgrammingMEX of a sequence or an array is the smallest non-negative integer that is not present in the sequence.Note: The MEX of an array of size N cannot be greater than N since the MEX of an array is the smallest non-negative integer not present in the array and array having size N can only cover integers 15+ min read Like