I have been practicing algorithms on coding sites like codewars and started to encounter algorithms that are mathematical like math symbols on some questions from changing to binary bits or Pascal triangle (mostly the kyu 4-5 questions) and I am unsure how to approach them better.

Aside from questions that involve arithmetic operations, I find myself limited in solving questions that are math intuitive and have difficulty understanding the question. My level of maths is algebra 1 ish as I havenâ€™t touched maths for almost 8 years.

For anyone who struggles with the mathetical algorithm, problem sets what would your approach be when encountering such a problem? also, would it be practical to actually pick up maths again from algebra 1 to maybe calculus level?

I did consider picking up maths again. Personally i do not hate maths , but i struggle to find the time commitment for it. I feel if i wanna learn maths i need like 6 months commitment minimum and have to push in time for it aside from practicing coding itself which dosent seem practical.

Hope to seek some advice !

Binary is an important thing to know in Programming, I donâ€™t for interviews, so you may want to check on some things of math

The more advanced math is situational, for example you would need calculus and trigonometry if you entered the field of simulations or advanced animations but donâ€™t need it for web development

I would say maybe some math could be useful to review - for example, do you know Khan Academy? They have free courses in a lot of subjects, maths included

A computer science course would also touch on the maths needed

i do know about binary but i am v slow in converting in my hand , i took classes related to OS and networking before just the problem sets needed me to convert numbers which i have to repeatedly look up how its done again.

i have attempted khan academy for algebra 1 but v slow way to work way up to advanced maths. Im not sure if its practical to go thru the entire section from algebra 1 to calculus just to solve algorithms which is why im asking.

Typically i am looking for areas to focus on which are common in interview questions , as well as practical maths that are useful for programming like discrete maths and whether they need preresquite maths to learn them.

In practice you wonâ€™t need much math beyond what you know. The examples youâ€™re looking at are slightly misleading because theyâ€™re often written to be tricksy. Codewars in particular seems to have a high percentage of problems written by people with a math background (or who have found a math trick and then applied it as a problem). In a sense I think theyâ€™re trying to look clever.

This isnâ€™t to say that math knowledge isnâ€™t important, itâ€™s just that in practice it only becomes important when you work on things that really need it (graphics is the obvious case). For the leetcode-style algorithm challenges, there are many that will have some simple mathematical trick that, if you know it, allows you reduce some loops down to a single equation. A good example is on FCC â€“ there is an challenge where youâ€™re asked to sum all numbers in a range. This has a mathematical solution, where you take the first and last value, plug it into an equation, and it gives you the answer. Or you can just loop over the values and add them up â€“ it will be a little less performant, but much easier to grok.

Being able to read mathematical notation is one thing I would say is very useful, and being able to convert that into programming language syntax. Wikipedia is very helpful here, and it means you can find a maths solution then convert it to a programming solution. And picking up the mathematical tricks as and when you need them, building up your knowledge that way, figuring out why they work, that is very useful, but be aware you might not actually use those tricks except in very specific cases.

1 Like

In the real world you probably wont be dealing with math beyond the basics **what so ever**. Unless you are working on a math related use-case, such as building a game engine, or physics calculations, you probably donâ€™t need much, if any math.

Not to say programming doesnâ€™t require math, its just different. Topics like data structures, algorithms, set theory, and Boolean algebra can all be considered â€śmathâ€ť, but still some challenges require knowledge of more advance math topics. The main reason for this is the nature of writing a challenge. Stuff like Codewars wants to test you on â€śwriting codeâ€ť, but the problems need to be complex enough to challenge you, but short enough to be written in just a few lines. Thus challenges usually require some complex approaches.

I personally hate match, never did well with math, and never want to do anything with tons of math. I do like â€śComputer Science Mathâ€ť, like the topics I mentioned above are more my speed. (Boolean Algebra sounds complex, but it isnâ€™t haha) That type of math is better to focus on simply because itâ€™s something you will used day-to-day, its to a point you probably already know most of it haha!

Just keep perspective on what you want to learn. I personally donâ€™t like Codewars too much due to it not being anything like real-world problems most of the time. Its fun every now and then, but so is setting up the architecture of an entire full stack app haha.

Goodluck, donâ€™t get hung up on the maths of things, do it if you want a challenge, or refer to external sources on solving the problems math side. Consider it getting a domain experts help on the topic, but still implement the solution yourself

3 Likes

I like to study in Codeforces and CodeChef. You can find all types of problems on both, and you can also find editorials for each problem.

Before competitive programming, I barely know how to think. Take some time to practice, you will see good improvement in short time.

Remember that you should find a study method that fits you.

If you say to me: â€śRead this book firstâ€ť, I may be very lazy about that.

Something that works out for me is searching for something I donâ€™t know how to do, then read about it. It motivates me so much, that I learn faster.

Itâ€™s all about browse through problems until you struggle at one.

Take care with problems too far away from your current knowledge.

1 Like