Kaushik Lele
BAN USERHi I am Kaushik. I have around 8 years of software development experience in Java/J2EE technologies.
I am author of 3 popuplar blogs that help learn Indian languages Marathi and Gujarati through English and Hindi.
I like to learn Languages. I know English, Hindi, Marathi, Tamil and Gujarati languages. I am now learning German.
Is nested string considered invalid e.g abc(def(ghi)jkl)mno ? How is it interpreted ?
- Kaushik Lele October 31, 2016why (1,5) (1,3) is not considered as collision ?
- Kaushik Lele October 31, 2016Question is very brief. Lot of things to assume. And based on assumptions scenario will vary and hence answers.
- Kaushik Lele October 31, 2016What is the reason/idea behind second pass ? Why are we selecting T/S and probing all servers again ?
- Kaushik Lele October 31, 2016What is the reason/idea behind second pass ? Why are we selecting T/S and probing all servers again ?
- Kaushik Lele October 31, 2016But what is locket meant for ? What is its relation of locker with delivery ?
What is criteria to decide id locker is closest to zip code?
What probability are we talking about ? "Equal probability for each" means ??
- Kaushik Lele October 30, 2016If I understood @sergey 's comment above; every finite array has loop in it.
If there are N elements in array then only at the max (N-1) times you can go to distinct position.
At (N-1)th hop you have already visited all the indexes. Hence when you take Nth hop, you will land on one of the reviosuly visited place. Thus it is a loop.
1) Check if traffic has increased. Is it normal/expected increase (say Diwali festival season) or unexpected. If it it is unexpected then analyze further if there is any suspicious from particular geographical area, phishing attack etc.
2) Check Server performance; any application server crashes ; memory issues observed
3) Check Database performance; DB server outage; memory issue;network connectivit issue.
If particular operation is taking long time to process then need to fine tune queries.
4) Overall network performance. Any outage; increased latency etc.
Can you please elaborate the functionality of lockers ?
- Kaushik Lele October 30, 2016We can solve the problem in recursive way, but it is dynamic programming so that we won't solve the same problem again and again.
e.g. consider string "abcd". We will make "ab" as prefix and try combination of "cd". Then we will make "ba" as prefix and try combination of "cd". So we are trying combinations of "cd" twice.
So as soon as we complete finding combination of sub-string it should be stored and reused.
Sort the array and give kth element.
- Kaushik Lele April 15, 2016Question is not fully clear. What is "stable marriage problem" ? Can you elaborate what exactly we need to match and how did you come up with the answer.
- Kaushik Lele February 07, 2016To avoid duplicates; we need to check if character is already considered as first character.
So I maintain a set of characters. Before considering that character as first character; I add it into set. If addition is not successful then it means it is already considered. So I skip characters.
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
public class FindCombinaitons {
public static void main(String[] args) {
ArrayList<String> outputList = findCombinations("abca");
System.out.println(outputList);
}
public static ArrayList<String> findCombinations(String inut){
ArrayList<String> combinations = new ArrayList<>();
if(inut.length()<=0) return null;
if(inut.length()==1) {
combinations.add(inut);
return combinations;
}
Set<Character> alreadyConsidered = new HashSet<Character>();
for(int i =0;i<inut.length();i++){
char ch = inut.charAt(i);
if(alreadyConsidered.add(ch)) { // Add into set is successfull means it is not already considered
String firstPart = inut.substring(0,i) ;
String secondPart = inut.substring(i+1);
//System.out.println("i="+i+" firstPart="+firstPart + " secondPart="+secondPart);
ArrayList<String> tempList= findCombinations(firstPart+secondPart);
for(String s:tempList){
combinations.add(ch+s);
}
}
}
return combinations;
}
}
Outpur for abca is
[abca, abac, acba, acab, aabc, aacb,
baca, baac, bcaa,
caba, caab, cbaa]
Output for "aaa" is "aaa"
- Kaushik Lele October 03, 2014@tony To avoid duplicates; we need to check if character is already considered as first character.
So I maintain a set of characters. Before considering that character as first character; I add it into set. If addition is not successful then it means it is already considered. So I skip characters.
package stringsequennce;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
public class FindCombinaitons {
public static void main(String[] args) {
ArrayList<String> outputList = findCombinations("abca");
System.out.println(outputList);
}
public static ArrayList<String> findCombinations(String inut){
ArrayList<String> combinations = new ArrayList<>();
if(inut.length()<=0) return null;
if(inut.length()==1) {
combinations.add(inut);
return combinations;
}
Set<Character> alreadyConsidered = new HashSet<Character>();
for(int i =0;i<inut.length();i++){
char ch = inut.charAt(i);
if(alreadyConsidered.add(ch)) { // Add into set is successfull means it is not already considered
String firstPart = inut.substring(0,i) ;
String secondPart = inut.substring(i+1);
//System.out.println("i="+i+" firstPart="+firstPart + " secondPart="+secondPart);
ArrayList<String> tempList= findCombinations(firstPart+secondPart);
for(String s:tempList){
combinations.add(ch+s);
}
}
}
return combinations;
}
}
Outpur for abca is
[abca, abac, acba, acab, aabc, aacb,
baca, baac, bcaa,
caba, caab, cbaa]
We can achieve it using recursion. We will place every letter in input as first letter and append it with every combination of remaining letters.
e.g. "abc" is input
The "a" is first element & combinations of other letters are "bc","cb". So complete combinations are "abc","acb".
The "b" is first element & combinations of other letters are "ac","ca". So complete combinations are "bac","bca".
The "c" is first element & combinations of other letters are "ab","ba". So complete combinations are "cab","cba".
So complete combinations are "abc","acb","bac","bca","cab","cba".
import java.util.ArrayList;
public class FindCombinaitons {
public static void main(String[] args) {
ArrayList<String> outputList = findCombinations("abc");
System.out.println(outputList);
}
public static ArrayList<String> findCombinations(String inut){
ArrayList<String> combinations = new ArrayList<>();
if(inut.length()<=0) return null;
if(inut.length()==1) {
combinations.add(inut);
return combinations;
}
for(int i =0;i<inut.length();i++){
char ch = inut.charAt(i);
String firstPart = inut.substring(0,i) ;
String secondPart = inut.substring(i+1);
//System.out.println("i="+i+" firstPart="+firstPart + " secondPart="+secondPart);
ArrayList<String> tempList= findCombinations(firstPart+secondPart);
for(String s:tempList){
combinations.add(ch+s);
}
}
return combinations;
}
}
Above java code can be further optimized using StringBuffer etc. but I have not used here so that users of other language will also understand it quickly.
- Kaushik Lele September 28, 2014Code is correct. But we do not need two pointers i1 and i2. As both start at 0 and both increment at same time. So i1 and i2 always have same values.
int i1 = 0;
while(i1 < len && i1 < arr[i].length() && arr[0].charAt(i1) == arr[i].charAt(i1)){
i1++;
}
len = i1;
Does in handle error condition ? Is nested string considered invalid e.g abc(def(ghi)jkl)mno ? How is it interpreted ?
- Kaushik Lele October 31, 2016