The first sentence is correct, but the issue of: "When do we generally use articles before noun and when we don't?" occupies whole chapters of grammar books, so it can't be answered fully here.
Basically, it depends on whether the noun functions as a count noun or uncount noun. Most nouns are either one or the other.
Computers can be counted, therefore computer is a count noun. Luck on the other hand cannot be counted (You cannot say: I had three lucks yesterday), so luck is an uncount noun.
There is a group of nouns that can be either count or uncount depending on the context. So, for example: hair meaning the hair on you head is uncount (She has nice hair) but can be counted when referring to individual hairs (Waiter, there are two hairs in my soup).
The noun time is in this group. It has several meanings, some of which function grammatically as count nouns and others as uncount nouns.
- I have been to Japan two times. [count]
- I don't have time to help you [uncount]
- I hope you have a good time. [count]
- It's time to go. [uncount]
- You need to move with the times. [count]
- He's doing time for murder. [uncount].
I suggest you use an online dictionary that tells you whether a noun is count or uncount in the context in which you are using it. One such dictionary is:
You can then consult one of the numerous online explanation pages such as the following to determine which article, if any, you need: