Journal note: π
I have started asking for referrals for a programming job, from my friends. And also actively applying for jobs. :)
Check for Palindrome
String
String str = "rar", reverseStr = "";
int strLength = str.length();
for(int i=(length-1); i > 0; i--) {
reverseStr = reverseStr + str.CharAt(i);
}
if (str.equals(reverseStr))
System.out.print("The string is Palindrome");
Number
int num = 1001, reverseNum = 0;
if (num != 0) {
reverseNum = num%10 + reverseNum * 10;
num = num / 10;
}
Transpose of a matrix
int row=2, column=3;
int[][] matrix = {{1,2,3}, {4,5,6}};
int[][] transpose = new int[column][row];
for (int i=0; i < row; i++) {
for (int j=0; j < column; j++) {
transpose[j][i] = matrix[i][j];
}
}
Top comments (0)