Giter Site home page Giter Site logo

competitive-coding's Introduction

Competitive-Coding

1. Segregate your problem

Firstly read the problem statement carefully, then segregate your problem. Is the problem related to sorting, searching, patterns, segmented sieve, strings, arrays, binary bits, etc. For example- If problem statements ask about binary search on rotated array then it is related to two types of categories i.e. searching and arrays. So, your code will be according to these two categories only.

2. Know your ranges

In every problem statement there is a range limit given till which the test cases will be tested. As these range limits are very high (around 108) so you should declare a variable which can be used afterwards in the code. This makes your code simple. For example- If your limits are given as 0 ≤ n ≤ 106
Code: #define ll long

3. Divide and rule works better

While solving a problem divide your code into smaller units which makes your code simple to use and reduces the time complexity, which in turn reduces the time limit error. For example- If the problem expects more from your code such as sorting of strings in lexicographic and numeric type then you needs divide it into multiple segments. Segments like lexico compare, numeric compare, string to integer convertor, string extraction etc.

4. Declare variables before taking inputs

Declare all the variables at the start of the code. This reduce the occurrence of time limit error (TLE) in the code and makes your code simple. Time limit error TLE comes because the online judge has some restriction that it will not allow to process the instruction after certain Time limit given by Problem setter usually. So declaring your variables at start reduces the total execution time. For example- If your problem is about getting prime number in between two numbers you need to declare an array of size given in the program. And if you declare variables afterwards it may give you a TLE which reduces in pre-declaration variables.

5. Being open to more coding languages is better

While coding you may have faced losing time in coding for all the functions. But by knowing many languages you can use different in-built functions present in different languages. Also in competitive coding competitions you are given different time limits for differ languages so you can write in a language with maximum time, which will reduce your TLE. Also execution time of some data structures like dictionaries, list present in python.

6. Visualize your code

Visualizing your code helps you get an idea about how your code works.

You can visualize all your codes here(independent of language).

competitive-coding's People

Contributors

abhishek-rout avatar abhishek-gadge avatar vaibhavkamble460 avatar yashrajkakkad avatar rushabhshah309 avatar akash-salvi avatar nancyradadia avatar viditjain04 avatar aditchhaparwal avatar aniket990011 avatar anupam-kumar-krishnan avatar arpit2136 avatar himanshudadheech avatar rogg-et avatar paarth14 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.