import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) throws IOException {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
StringBuffer sb = new StringBuffer();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
for(byte T = Byte.parseByte(br.readLine()); T > 0; --T){
final char[] C = br.readLine().toCharArray();
final int N = C.length;
int c = -1;
for(int i = 0, j = N-1; i < j; ++i, --j){
if (C[i] != C[j]){
c = isPalindrome(C, i+1, j+1) ? i : j;
break;
}
}
sb.append(c + "\n");
}
System.out.print(sb);
}
private static boolean isPalindrome(final char[] C, final int A, final int B){
for(int i = A, j = B-1; i < j; ++i, --j){
if (C[i] != C[j]){
return false;
}
}
return true;
}
}
enterprise application development, architecture , business analysis and programming
Showing posts with label interviews. Show all posts
Showing posts with label interviews. Show all posts
Thursday, 17 November 2016
Palindrome Index - Algorithm Solution
Labels:
codility,
hackerrank,
interviews,
java,
project euler
The Love-Letter Mystery - Algorithm Solution in JAVA 8
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int numTestCases = s.nextInt();
while (numTestCases > 0) {
String word = s.next();
System.out.println(getNumRotations(word));
--numTestCases;
}
s.close();
}
public static int getNumRotations(String word) {
char[] wordArr = word.toCharArray();
int count = 0;
int j = word.length() - 1;
for(int i = 0; i < wordArr.length / 2; i++, j--){
count += Math.abs((int)(wordArr[i] - wordArr[j]));
}
return count;
}
}
Labels:
hackerrank,
interviews,
java,
project euler
Monday, 22 December 2014
Bridging Architectural Concepts
All of these below details are very important and have to learn if you are Architect of any of that like (Application Architect, Solution Architect, Enterprise Architect, Cloud Architect, Infrastructure Architect, System Architect.
- Envision – Software Architecture
- Model – Design Patterns
- Blueprint – Construction and Design Principles
- Nomenclature – Terms to communicate intent
Software Architecture
- Web Server – A pipeline Architecture
- SOA – A component Architecture
- Client/Server – A layered architecture
- Single Tier – A monolithic Architecture
- Cloud – A tier network Architecture
Design Principles
- Abstraction
- Encapsulation
- Cohesion
- Coupling
- Complexity
Design Patterns
- Creation al, Structural and Behavioural
- Event Driven – Observer
- Plug-INS- Abstract Factory
- Domain / Active Record / Table Module – Layer Patterns
- Algorithm – Strategy
Construction Patterns
- Inheritance Design
- Component Design
- Layered Design
- Tier Design
- Deliver Methodology
- Delivery Methodology
- Software architecture erosion
What type of Architect you are and what you have to learn?
- Application Architect - You have to strong in Construction patterns
- Solution Architect - You have to strong in Design Patterns and Principles
- Enterprise Architect - You have to strong in Architecture Patterns & Construction
- Cloud Architect - You have to strong in Architecture, Construction & Tier
- Infrastructure Architect - You have to know Construction pattern
- System Architect - same as Solution Architect
Labels:
architect,
interviews,
web
Subscribe to:
Posts (Atom)