sai rama krishna wrote:I forget to include sort method
Arrays.sort(digits); withing print method in my last output. After putting it i got it sorted as well correctly
That suggests to me that you need to practice some more. Don't just memorize the solution and try to regurgitate it. Understand the
thought process and
incremental nature of finding a full solution by attacking
parts of the problem, one at a time. If you forgot to add a call to
Arrays.sort() then you didn't plan out your solution that well because you skipped the part about thinking "How do I sort these things?"
Your initial planning should go something like this:
1. Get input string
2. Get individual characters
3.
Sort the characters
4. Print the characters as a pyramid
...
If you added the call to Arrays.sort() almost as an afterthought, that means you didn't have a plan like the above laid out before you started writing code.
You should always have a plan to start with, even just a simple outline and even if you know the plan is going to have to change as you learn more about what you need to do.