Someone else applied for a patent, and I invented something with similar principle. Can I apply?

The patent protects the technical scheme, that is, the specific implementation. Even if the principle is the same, the implementation may be somewhat different. In this case, you can consider applying.

In addition, as long as there are differences, the patented technical solutions are usually different, so "almost" does not mean "the same", not to mention that you are only similar in principle, not in realization.