Category Archives: ACM-ICPC

Where do I start competitive programming? I know the basics of C and C++.

Source: https://www.quora.com/Where-do-I-start-competitive-programming-I-know-the-basics-of-C-and-C++
Where do I start competitive programming? I know the basics of C and C++.

5 Answers

Rohit Surana

I would suggest you to first master C++ thoroughly. Since language is your weapon, a well sharped weapon is half job done 🙂

Then learn about basics of Data Structures like stacks queues, graphs, trees, and their implementation thoroughly. There are several youtube channels which have excellent tutorials on these topics. Finally solve Data Structures challenges on hackerrank.

Then study the C++ standard library which provides a robust implementation of all the Abstract Data Structures and some algorithms like sorting etc.

You can now start solving Warmup Challenges on Hackerrank in sorted order from easy to hard and then moving on to other domains. Hackerrank has the best UI as compared to other platforms also you can view various test cases. BUT you cannot view other people’s solutions.

Another good platform is codechef. Open Easy problems on CodeChef page. scroll down to the bottom of the page and start solving problems with most number of successful submissions. You can view other’s solutions on codechef so that you can get an idea of their thought process and style of code.

After practicing easy problems for 2 months. I would suggest to start learning various standard algorithms involving Dynamic Programming, Graphs, Trees, Greedy techniques, Number theory etc. Youtube has many good videos for these topics for ex. Excellent Dynamic Programming and other tutorials on Youtube by Tushar Roy .

There are many other good websites like Topcoder , HackerEarth, Sphere Online Judge (SPOJ) , Codeforces etc.

The is no shortcut to improve algorithmic thinking for competitive programming in a short time

Source: https://www.quora.com/How-can-I-improve-my-algorithmic-thinking-for-competitive-programming-in-a-short-time

Yeah. I like the question.

  1. You should learn the programming and modules by your own
  2. If there is a problem solve it perfectly it doesn’t matter how much time it takes.
  3. Learning part : Sorting algorithms, Data structures, Dynamic programming, Greedy algorithms(All basic part, you don’t need to remember the algorithm just catch the algorithm on the problem specification and can modify and apply)
  4. Please don’t be hurry in writing and submitting the code, just worry about the understanding the problem properly, analyse it step by step and then write your own algorithm as you understand and implement on the paper.
  5. Finally, Code the algorithm step by step as you want.
  6. Happy coding
14 Answers

Ashish Kedia

There is no short cut. And there is only one answer : Practice.

  • Take part in more short contest. They help you improve your speed of thinking. Long competition often have very hard problems that require more research and less thinking.
  • Take part in competitions as a team. It helps you see questions from a different point of view.
  • Discuss solutions with others after competition. That too helps understand you different solutions.
  • Take this course about learning how to learn.

Suchith Javagal (ಸುಚಿತ್)

Thanks for A2A, Ashwin Varghese

Unlike many people here I didn’t go too far with it. I had on and off relationship with competitive programming. Let me give a try. First of all, what do you mean by “short time”? I assume a semester – around 4 to 5 months. I also assume that you are comfortable with C++ or Java. Otherwise learn it first. You don’t need to learn Object Oriented Programming here. You won’t be dealing with design issues.

Grab “Competitive Programming – 3” by Steven and Felix Halim. Otherwise, continue reading….

What to do?

  1. In C++ learn Standard Template Library (STL) which contains the implementation of common data structures and algorithms. In Java, check out java.math, java.util and java.util.regex packages for the same.
  2. Learn mathematical topics like Number Theory, Graph Theory, Probability, Combinatorics, basic Geometry, Game theory, different proof methods etc. Later you might also have to learn Order Theory and little Abstract Algebra.
  3. Solve ad-hoc questions which require you to come up with your own algorithm instead of using or modifying standard algorithms. Also solve some problems which require mostly math.
  4. Learn data structures – Segment Tree, Fenwick Tree, Treap, Implicit Treap, Suffix Array / Automaton / Tree, Trie for String based problems, techniques on trees like finding Lowest Common Ancestors (LCA), Heavy Light Decomposition (HLD), Centroid Decomposition over the course of 5 months.
  5. Learn well-known algorithms – Fast exponentiation (applicable to matrices too), string searching – KMP or Z algorithm, basic graph theoretic algorithms to find MST, shortest path, solutions to well known problems like Knapsack problem etc.
  6. You hear terms like Dynamic programming (DP), greedy, Divide and Conquer, Brute Force etc. They are not algorithms, but problem solving paradigms. Know the difference. If you are scared of DP, then you are not alone.

The list of topics is not exhaustive. Have a look at these resources

  1. Data Science Tutorials – TopCoder tutorials
  2. MAXimal :: algo . It is in Russian. Use Google Translate. Some articles have been translated to English too – Main Page – E-Maxx Algorithms
  3. Data Structures and Algorithms
  4. Awesome resource for DS and Algorithms
  5. What are the “must known” algorithms for online programming contests?
  6. GeeksforGeeks | A computer science portal for geeks
  7. Mathematics for Computer Science – MIT OCW – For discrete mathematics.

How to do?

There are many good answers here. I’ll tell what I did. I started solving from most solved problems in SPOJ. I solved about 200+ most solved problems there. It taught me a lot of topics I mentioned earlier. Meanwhile, I used to participate in contests in Codechef, Codeforces and Hackerrank semi-regularly (do it regularly). Check out the editorial of the problems you haven’t solved during contest. If there is something new, learn and implement the idea on your own. Don’t give up until you get AC. (It is sometimes called ‘upsolving’). Then I solved problems from C and D ladder (in Codeforces) in A2OJ site.

Here is a a story – I took around two months to solve QTREE in SPOJ. I got plenty of WAs, rewrote the code thrice because it was very hard to find the bug. That was the first time I implemented Heavy light decomposition.

Tips

  1. It is okay to get frustrated because some topics are hard to learn and/or implement. It is okay to get Wrong Answer.
  2. Don’t compare yourself with “red coders” (top rated people) in the beginning. Remember that they have been doing it for years. It only leads to disappointment. They can be your inspiration though.
  3. Solve LOT of problems. Push yourself outside your comfort zone.
  4. Lot of practice is needed. That way, you learn to think and implement solutions pretty quickly over time.

Happy coding 🙂

Edit: Added resource for discrete mathematics. (Point 7 in resources section).

Akash Kandpal

Thanks for A2A,

I will try to answer this question. Imagine for next 6 months.

Stage 1: Setting up the base.(2 months)

Try solving first 200 problems in Sphere Online Judge (SPOJ) . for the first 2 months , try to do all the problems on your own. Stick with this for first 2 months till you gain confidence.

Stage 2: Moving to Code Chef(2 months)

Once you gain some confidence on SPOJ problems, move on to codechef and practice for next 2 months.

Stage 3: Moving to Top coder (2 months)
Now move to top coder and try competing in SRMs.

Practice daily , try solving 2 or 3 problems on your own. It might take an hour or 5 hours but do it on your own . Trust me after 2 months you will have a very good confidence in problem solving .

This is a sport , the more you train yourself the better you are. Hope this helps.

But if you want to prepare for cracking interviews then it will be better if you go for geekforgeeks and implement each and every algorithm out there in your own console and also keep a check to Wikipedia for learning new algorithms .

Tushar Nitave

Look, there is no shortcut for improving your thinking ability. It’s a slow process and you should be pertinacious. So, practice, practice and practice a lot!!!

Sorry that I didn’t give you direct answer to the question but, I hope you got my point.

Thank you.

Mohammad Abbas

You should try by developing logic. Solving problems in computing requires logical thinking and you need to improve that. Having a strong logic is very very helpful in programming competition, for instance, someone makes a program which runs in 10s, possibly you could make it run in less than 5s, and to do so, you need logic. Logic is the basic block of your program.

Having only a good logic won’t help. What would you do with an amazing logical way to tackle a problem if you don’t even understand the syntax? I guess you got what I mean. With great logic, one should know the language very nicely. You should know the insides and out of the language. You should be familiar with the language you’re about to code with and you should be able to understand each and everything written in the code. You can possibly have an amazing logic but the way you impelement that logic is more important. Being able to implement a task efficiently and smartly is the goal to a programming competition and once you have a good understanding of the language and an amazing logic, you can achieve the first prize.

Alex Langshur

By using those algorithms extensively on your own.

I’ve only recently gotten into competitive programming. However, my experience adopting the competitive programming logic and speed has been similar to the learning process behind non-competitive concepts.

Pull up that IDE, relax (you’re not being timed, don’t worry), and build something that makes use of that algorithm. The key to success is to understand how to use it and when to use it. Keep practicing with it on your own until you’re at a point of comfortability where you can pull it out of your inventory on short notice.

Don’t rush it either — it’ll take some time to get to the point where you can easily implement it in a competitive atmosphere.

Chetan Sharma

For most questions of these type the answer is doing deliberate practice. Absorbing practice. A kind of practice which is termed as being in “Flow”

Solving puzzles will help and do will reading good literature because I would prefer building a holistic mind.

Reading this book How to solve it A New Aspect of Mathematical Method:Amazon:Books will definitely help.

Solving puzzles on About – Project Euler will help.

Thinking about hard problems will also help. Your struggle to live with a complex problem and your inability to solve that problem and take that problem to your dreams will help too. Brooding over a complex problem will help too and so will taking help from your sub conscious mind will help too.

Playing a sport or doing some calisthenics will help too. Ideas is to send more oxygen to your brain.

Most importantly you will fail so many times that the motto Patience. Persistence. Perseverance will definitely help.

Egor Okhterov

I can answer you from the other end. How to improve in competitive programming very very slowly? I have an answer to that question.

You have to train on your own.

There is not a single person in this field who progressed fast alone. So, to answer your question we should just invert my previous advice:

You have to find a mentor.

Without mentor you will be progressing very slowly. No amount of practice and problem solving will replace a good trainer, who can see what is your current bottleneck and make you focus on that particular issue.

I was looking for a mentor for a few years already and could not find one, because I am too old (as they think). But you have time as an advantage and you should use it with the utmost care. The best step you could make at this stage towards your progress is to start actively looking for a mentor.

Praneet Sah

I can give you thousand ways to make your “thinking” better but everything drills down to just one word, PRACTICE!

I read somewhere, the worst programmer is the one who reads 100s of book but doesn’t practice anything.

So close Quora and get yourself to work!

Akash Agarwal

All of us like shortcuts don’t we, but the truth is that there is no shortcut. To get good at anything you need to spend time and train hard. Constant and deliberate practice makes you perfect or different from the average crowd in any field. The same principle applies here.

Keep solving problems, manage time wisely, work smart and don’t look back 🙂

Godspeed!

Akilesh Murugan

It’s not easy but not very tough if you are determined—

1.>>>Takeup any program you want to write ..( can be any simple or complex program).

2.>>>Code it down on the comp.

3.>>>RUN IT !

4.>>>Now get back to the code you have written and check wether you can shorten down the length by bringing in more logical functions .

5.>>>Shorten the length of the code as much as you can .. (Now that will be the perfect code for that prgm).

————THIS is how you improve your algol thinking .————

The time i.e short or long time totally depends on you

Practice a lot .

Good Luck !

Vipul Srivastava

You have to pratice a lot. There are lots of algos you have to learn them then there are tons of variations of standard algos you have to practice them. Now it boils down to how much you can pracatice and how fast you can do it that is how many questions in how much time you can practice.

Practice is the one mantra which can guarantee your success in competitive coding world.

All the best..!!

Allakonda Harish

Yeah. I like the question.

  1. You should learn the programming and modules by your own
  2. If there is a problem solve it perfectly it doesn’t matter how much time it takes.
  3. Learning part : Sorting algorithms, Data structures, Dynamic programming, Greedy algorithms(All basic part, you don’t need to remember the algorithm just catch the algorithm on the problem specification and can modify and apply)
  4. Please don’t be hurry in writing and submitting the code, just worry about the understanding the problem properly, analyse it step by step and then write your own algorithm as you understand and implement on the paper.
  5. Finally, Code the algorithm step by step as you want.
  6. Happy coding

Mostafa Radwan

You should solve many different problems

and your think will be improve as a result of the difficulty of the problem you solved

Learning data structures and algorithms from scratch

Quora sources: https://www.quora.com/How-do-I-learn-data-structures-and-algorithms-from-scratch

  1. Learn Big-Oh notation, omega and theta notations denoting complexity of algorithms and data structures.
  2. If you don’t know, learn some discrete mathematics and probability. Learn basic combinatorics, graph theory, matrices, probability theory, especially the concept of expected values. Do this on the fly.
  3. Learn basic data structures
    1. Implement singly and doubly linked lists on your own.
    2. Learn stack and queue. Implement them using linked lists. For more fun – try implementing stacks and queues using arrays.
    3. Implement vector data structure in C++ on your own. It is simple – when you run out of space, allocate twice the memory you had allocated previously and copy all the data to newly allocated array.
    4. Implement binary heap data structure and use it as priority queue.
  4. Learn sorting algorithms
    1. Learn somewhat inefficient sorting algorithms – Selection sort, Bubble sort and Insertion sort (the last one works fine on small inputs)
    2. Learn merge sort. Recursive functions can be somewhat hard to understand in the beginning. This teaches you that skill. Trace it very well.
    3. Learn quick sort. This is one of the most important algorithms ever discovered. Learn the importance of randomized quick-sort and pivot selection.
    4. Learn counting sort and why it works in linear sort.
    5. If you are interested, you can go further and learn about “stability” of sorting algorithms. For instance, merge sort and insertion sort are stable.
  5. Some more data structures now. Let’s go to the next level.
    1. Binary Search Tree – Implement the basic binary search tree and set operations using it – insert, delete, find elements in it.
    2. You might come across performance issues for certain inputs. Why? Now learn about “Balanced” binary search trees like AVL Tree and Red-Black Trees and try implementing them – This is hard, tedious and scary to implement and debug. Expect lot of Segmentation faults.
    3. Learn the concept of hashing and hash-table. Implement a hash-table. (there are two schemes).
    4. Figure out what else can be done with binary search trees. Augmenting data structures with more information? How about adding a feature where kth order statistic can be found? How about binary search on keys?
  6. You might have encountered terms like Divide and Conquer while studying merge sort. They are called “Algorithm design techniques”. You will also come across terms like Brute Force, Dynamic programming, Greedy algorithms. Now let’s dive into it.
    1. You already know Divide and Conquer. Learn Dynamic programming technique. You might find it a bit difficult in the beginning and all of us had been there. Study the solution of some standard problems like Rod Cutting, 0/1 Knapsack, Edit Distance, Matrix Chain Multiplication, Longest Increasing Subsequence etc.
    2. Now it is time to look at another technique – Greedy algorithms. Study standard problems which use greedy technique like selecting largest number of intervals among given ones so that there is no conflict. You’ll see more later.
    3. Learn the difference between all these techniques. DP and D&C differ in sub-problem overlap and Greedy, DP differ in the way decisions are made and revisited.
    4. Study the proofs of these algorithms, especially the greedy ones. Don’t worry about abstract concepts like Matroids for now.
  7. Let’s jump to Graph algorithms now.
    1. Let’s build a maze solver – Learn and implement Depth First Search (DFS) and Breadth First Search (BFS). They are basic searching techniques.
    2. Study Prim’s and Kruskal’s Minimum Spanning Tree algorithms and implement them.
    3. Let’s implement our version of Google Maps – Finding the shortest path between two given places given a roadmap. Learn and implement the algorithms of Dijkstra, Bellman-Ford and Floyd-Warshall.

Bingo, now you are pretty good at data structures and algorithms. But remember that this is just the tip of the iceberg. Once you learn it, implement on your own. Only then you get a feel of it. If you want to learn them in a fun way, try competitive programming.

Here are some resources

  1. Introduction to Algorithms – CLRS (Chapters are in the order I have written. I have skipped some chapters in it). I suggest this one along with the DSA course from Stanford on Coursera.
  2. Coursera – data structures and algorithms courses
    1. Algorithms, Part I – Princeton University | Coursera
    2. Algorithms, Part II – Princeton University | Coursera
    3. Algorithms | Coursera – from Stanford University
  3. MIT Open courseware
    1. Introduction to Algorithms (SMA 5503)
    2. Advanced Data Structures – As the course says, this is VERY advanced. If you are ready to go deeper, then go here.
  4. GeeksforGeeks – It is very helpful, especially if you are preparing for an interview.

Arunabh Ghosal

I was in the same situation 1 and a half year ago. I will explain how I learnt data structure and algorithms.

In the following text Algorithms and Data structure which are marked in bold are very important. Learn every algorithm/data structure with it’s time & space complexity, stable, in place, and where it is useful.

What to study?

Step 0 :

  • Understand about pointers in C++, structures or classes
  • Learn how to calculate worst case, best case , average case time complexities

Step 1 :

  • Learn few basic sorting algorithms along with their use case and time complexity.
    • Bubble sort
    • Insertion sort
    • Selection sort
  • Learn searching algorithms along with time complexity.
    • Linear Search
    • Binary Search

Step 2 :

  • Stack
  • Queue
  • Single Linked List (Insert at front,back,middle; Delete at front back middle)
  • Double Linked List
  • Circular Linked List

Step 3 :

  • Learn the following approaches in algorithms
    • Divide and Conquer (Merger Sort, Quick Sort, Binary Search are some examples)
    • Greedy method (Knapsack, Prim’s algorithm, Kruskal’s algorithm, Dijkstra, Bellmanford)
    • Dynamic programming (0/1 Knapsack, Travelling Salesman Problem, Coin change)
  • Backtracking (N Queens problem)

Step 4 :

  • Binary Tree
  • Binary Search Tree
    • Height of a Tree
    • Tree Traversal
      • BFS
      • DFS
    • Searching an element
  • AVL Tree
  • Hashing

Where to study from?

GeeksforGeeks | A computer science portal for geeks

Data Structures and Algorithms | Coursera

Video Lectures | Introduction to Algorithms (SMA 5503) | Electrical Engineering and Computer Science | MIT OpenCourseWare

Note: If detailed answer or specific approach is needed, feel free to massage me on quora.

Vaibhav Lawand

First thing you should know is how pointer works,how dynamic memory gets allocated and also basic concepts like stack unwinding etc.

Now assuming that your basics are clear, you should start with famous Thomas Cormen book; start implementing the algorithms on your own. At first, you’ll struggle but remember hard work is the key to success.

If you are not best at programming, then look for geeksforgeeks.org website. This website is the best to crack any coding interview.

Some more:

  1. Data structure course – Unlimited Online Developer, IT and Creative Training
  2. Udemy data structure course
  3. mycodeschool
  4. thenewboston – Youtube channel

Happy coding…!!!

Algo Book

https://www.amazon.com/Algorithms-Unlocked-Press-Thomas-Cormen/dp/0262518805

Jobs For ACM Programmer

Trainee Software Engineer (Python)

Vacancy

04

Job Description / Responsibility
  • Possesses excellent technical skills as well as excellent problem solving skills.
  • Implement SDLC and coordinate with other members of the team.
  • Meet deadlines and achieve intended results.
  • Designs, develops and modifies modules based on functional and system requirements.
  • Work closely with the Team Leader, Business Analyst and Product Owner for understanding the functional and system requirements.
  • Work closely with the Architecture Team to ensure architectural integrity and product quality.
  • Participate in testing process through unit testing and bug fixes.
  • Participate in daily scrum meetings
  • Participate in sprint planning
  • Work closely with the QA team, Product Management team, and the Research and Development manager to ensure quality and punctual software development
Job Nature

Full-time

Educational Requirements
  • B.Sc in Computer Science/ relevant degree/ equivalent working experience.
  • Freshers are encouraged to apply for the position.
Job Requirements
  • ACM problem solving skills will be considered as a good plus.Those who have solved 200+ ACM problems will get preference.
  • Good score on hacker Rank, UVA Online Judge, Top Coder or any other problem solving sites will be considered as a plus.
  • Clear concept of Object Oriented Programming
  • Experience with MVC frameworks.
  • Good knowledge in Javascript and working experience with jQuery.
  • Knowledge of algorithms and excellent problem-solving capability.
  • Knowledge on ORM is a plus
  • Knowledge on Python/Django is a plus
  • Knowledge on business application is a plus
Job Location

Dhaka

Salary Range
    Negotiable
Other Benefits
    As per company policy.
Job Source

Bdjobs.com Online Job Posting

Job Summary

Published on: Sep 22, 2016

Vacancy: 04

Job Nature: Full-time

Job Location: Dhaka

Salary Range: Negotiable

Application Deadline: Oct 22, 2016

Career Benefits of Competitive Programming

5 Career Benefits of Competitive Programming

Focus in Programming

http://howtobeacomputerprogrammer.blogspot.com/2017/02/top-techniques-to-increase-concentration-programming.html

CSE Motivation

Best, Average, Worst Case

cheat sheet:
http://bigocheatsheet.com/
Good for Programmers:


It’s also good:

It’s good for space complexity and cost.


Golden rules :

Not good for programmers but okay:

Will watch it later:

Asymptotiic Notation

 

অ্যালগোরিদম কমপ্লেক্সিটি(বিগ “O” নোটেশন)

http://pages.cs.wisc.edu/~vernon/cs367/notes/3.COMPLEXITY.html

http://discrete.gr/complexity/

http://50f7.blogspot.com/

For Upper Bound Lower Bound Clear:

http://cs50.wiki/Big+O+notation

Serious Programmer To Serious Programming Enterpreneur

http://blog.spoj.com/index.php/2017/01/18/spoj-talks-keshav-dhandhania/

Software Engineer/Programmer

http://jhankarmahbub.com/bolod/intro/steps.html

http://jhankarmahbub.com/dreamJob/csestudent.html

http://mashable.com/2014/12/16/warning-college-may-be-a-waste-of-your-time-and-money/#8Qo5DR9rFaq7

https://blog.hackerrank.com/3-teen-sisters-crush-coding-records-stereotypes/

C revise

 

CV/Resume tips in Bangla from Subeen Vai

Monk and Welcome Problem

Another Problem: