To compile a particular algorithm, not a bad knowledge of the language in which you write is necessary, because depending on the use of certain tools of this language, you can write an algorithm. And good or bad it will be - it depends just on this knowledge. For example, in the OOP there are patterns — patterns of implementation for particular tasks, due to which their implementation and further support will pass with minimal problems. The code (preferably, almost necessarily) must adhere to certain design rules: for example, such as KISS, SOLID, DRY, etc.
I usually start by implementing some kind of code preparation that is not ground, so to speak, depending on the specific conditions that must be fulfilled in the code. Trying to match them, in parallel I think how the code can be improved, in what ways to make it so that it is as productive and optimized as possible. (Here we will need various knowledge)
Different knowledge helps due to its diversity to choose the best option possible.
Example:
Different methods of implementation in algorithms - https://tproger.ru/articles/computational-complexity-explained/
Many different sorting options - https://habr.com/ru/en/post/335920/
I will add, if thoughts come
абстрагируй задачу, разделяй ее на части и повторяй, пока каждое действие не станет очевидно
(this approach is also called top-down programming or hierarchical decomposition) orвозьми входные данные, представь, во что они должны превратиться и придумай последовательность элементарных шагов, которые сделают такое преобразование
). - avp