Is it just a matter of practice (just writing more and more complex algorithms until you get better at it) or is it better to explore already written algorithms, either through source code or through books and also are there any good books about understanding algorithms in programming?
Codility.com has a nice practical lessons with pdf explanations of different algorythms for each lesson
Have you studied computer science academically yet? If you haven't and you're starting to feel like you've plateaued with the mechanical aspects of writing algorithms, it might be time to delve into the theoretical aspects of algorithms. The hardcore math beyond algorithms, like discrete mathmatics, theory of computation, regular, context-free, and Turing-recognizable languages, etc. Algorithms study that involves proofs rather than code.
You can go a long in the software field with self-study, but it's hard to substitute self-study for a rigorous CS curriculum. You don't know what you don't know, so it's harder to discover what to learn. A CS curriculum, however, will have compiled that list for you and included exercises and tests.
Code is only one way to express an algorithm. But when you understand the fundamental ideas behind the algorithms, you'll be much more capable with capturing those ideas in code.
Here's a list of some of the textbooks that I learned from:
Discrete mathematics and its applications, Rosen
Jayme Edwards
After 20 years of working with 30+ companies, I'm sharing the healthy ways I learned to develop software. 🍃 💻
You can either read books, use sites like Leetcode or Hackerrank or my favorite - build apps, APIs, or other simple prototypes to get something to work yourself. This always forces me to learn algorithms that solve a real world problem - versus just demonstrating CS skills.