infoginx
BAN USER
Use two pointers.
Convert string to lowercase.
ignore punctuations, while incrementing/decrementing the start/end pointers.
compare pointers in each iteration, if there is a mismatch then return false.
In the end, if there is no mismatch then return true.
class Palindrome{
public static void main(String[] args){
isPalindrome("L*&EVe)))l");
}
private static void isPalindrome(String p){
int start = 0;
int end = p.length()-1;
String s = p.toLowerCase();
char[] arr = s.toCharArray();
while(start <= end){
if(!Character.isLetterOrDigit(arr[start])){
start++;
continue;
}
if(!Character.isLetterOrDigit(arr[end])){
end++;
continue;
}
if(arr[start]!=arr[end]){
System.out.println("False");
}
start++;
end--;
}
System.out.println("True");
}
}
You can also use a stack. Put all the characters in the stack, and then pop all those to a separate string. At the ends compare the two string. If there are equal return true, otherwise return false.
- infoginx March 14, 2018We need a frontend, which I would prefer to be made in Angular, React, or Knockoutjs.
We need access network with load balancing capabilities, for high availability.
I would personally make use of cloud computing instead of using my own premises network. I can make use of features provided by the cloud.
For storing images I would use services like S3 from AWS, or similar home-backed one.
For event e.g. LIKE, LOVE, etc I would use streaming (event processing) and messaging. I would need a distributed architecture because users can access images from anywhere, and latency is important in a timeline scroll on the app.
These sort of questions are open-ended so you can just use your wild imagination. Interviewers are normally checking your thinking abilities in terms of architecture and scalability.
If I were asked these questions, I would have responded like the following:
-Why Facebook?
World's biggest social network. Innovative people. Has a huge social impact, and it will give you an opportunity to make a difference at a global scale.
-What was the biggest technical problem that you solved?
Reaching the face-to-face interview.
-Do you have any apps on google play?
No.
-Give me a scenario where the requirements were ambiguous, what did you do?
I was asked to design URL shortening service, with two different distributed architectural patterns. I can use any two patterns I like.
I used sharding and modern multi-tier with load-balancing and scalability.
What if we restrict equality to only the reverse strings?
- infoginx March 15, 2018E.g.
hash("baaann") != hash("banana")