Coding is hard in the beginning, just like everything else in this world is, it is important to not give up and try. I'm not perhaps the best person to write this as this site has many coders much better than me, but as someone who started getting serious about coding not too long ago, these are the tips I would give to you based on my experience:
- You need to get good at the fundamentals first and foremost (recursion, bfs, dfs, dp, backtracking, two pointers, greedy, sliding window, sorting(comparison based, non comparison based), hashing), learn ADTs and implement them yourself (stack, queue, list, binary heap, priority queues, trees, sets/ maps, graphs(adjlist, adjmatrix), disjoint sets, maybe more advanced things like Dijkstra, Bellman-Ford, AVL, Red-black, BIT, tries, Huffman encoding and such after)
- Practice questions category wise at times when you learn something new to get a good grasp on the concepts and implementations and randomly other times to be able to identify the probelm type on your own, start putting them in boxes of what concept you used to solve them.
- Try to look at other people's code for help in implementation, especially when you don't know how to structure it yourself, but don't look at it for logic, 30 min - 1 hour is enough, if you haven't figured it out by then, there is most likely a gap in your knowledge, check an answer not to copy the answer but understand what concept was used and study it for the next few days, it is trivial to look at the solution and think, that was easy, but if you didn't have at least an idea of how to go about it, you're not ready for that question, especially if you can't even do the naïve approach, which exists for all questions but is just slow.
- Not forgetting questions is something I even don't know how to fix, but the second time around I can write it after a few minutes of thinking most of the time, other times, looking at my previous codes immediately lights a oh right I did that moment and it's generally just a minute or two before I can re write it again.
- As for revision, when you learn new things, you will notice they touch or rely on previous knowledge a lot of the time, like dp is just the topological sort of a DAG in graphs and graphs use dfs/ bfs a lot which is based on recursion which is based on stacks and queues, you see where I'm going with this?
- Also there are some question that you will have to look no matter what the first time, because they are a already famous algorithm by one of the top computer scientist, something like tarjan's algorithm for SCC or you know implementing a merge sort for the first time, or a quick sort or KMP or Boyer Moore or something like that, because let's face it, those are very hard things to come up with on your own and a top mind took years of academic research to come up with it, don't re invent the wheel, know when to learn from the past, when to make your own code.
- Most important, if it means anything to you, practice until you go to the interviews to confirm your selection, not to wait for them to select you.
P.S. don't get too hung up on what language to choose, just choose one, stick to it, learning other languages is fairly easy after you pick one up, yes going from static to dynamic to functional is slightly different matter, but still fairly easy after you know what you're doing in one language.