Relative Content

Tag Archive for javastring

How to reduce the time complexity of my code?

class Solution { static String revStr(String s) { String ans = “”; for(int i = s.length()-1; i >= 0; i–) { ans += s.charAt(i); } return ans; } } I was solving a question to reverse a string and my output was correct, but it was taking longer than expected, and I can’t figure out […]

Java Program to reverse the two number and find its sum

This Java Program we Reverse two Number and find the Sum of its Digits Using while Loop.While loop checks the condition first and then executes the statement here first we find the reminder and then Multiply reverse number by 10 and add remainder of number.Dividing number by 10 to access digit position.after that we sum the both reverse number.
Javatechnote.com