Rakesh Roy
BAN USER1. For each node X in the given list,
1.1 create a corresponding node Y for the new list. Copy X's Data to Y's Data. The Y's
Next and Other both pointing to null.
1.2 Store X as key and Y as value in the map
2. Iterate over each entry in the map.
2.1 For key X , get value Y
2.2 Y> Next = map.get(X>Next)
2.3 Y>Other = map.get(X>Other)
Could you please explain this part:
Also use a hashtable that will have page number as the key and the address of the frame in the queue as the value for the key.
@Green : Should not after swapNodes(b,c); b be pointing to b.next....I mean
b = b.next; should be present after swapNodes(b,c);.....Not sure if I have missed something/ not understood your algo correctly.
Distance between two building is 1061 = 105.
Relative Speed (two people moving towards each other) = 10+5 = 15.
Time taken = 105/15 = 7
At the end of seventh minute A would have travelled 7*5 = 35 building. Initially A was in building 1, so they meet at #36.
36
 Rakesh Roy April 25, 2014Depends on situation. If thread safety is important one should choose HashTable over HashMap. If you do not need synchronization, prefer hashmap over hashtable bacause it is faster.
 Rakesh Roy April 25, 2014When you need a collection to hold key/value pairs.
 Rakesh Roy April 25, 2014A composite iterator (composite pattern) can be designed for as s solution to this problem. The main intent of Composite lets clients treat individual objects and compositions of objects uniformly. We can come up with a Composite iterator which will implement existing Iterator and internally will make use of Stack. One of the solution suggested in this thread (FlattenIterator to be precise) is in fact a composite iterator.
 Rakesh Roy January 19, 20141. Simple array implementation  operations will be O(1), but maximum size of the stack must be defined in advance and can not be changed.
2. Dynamic array implementation  Here you increment the array size as you push the element to the stack. It is too expensive to implement. For an example to push second element, you create a new array of size 2, copy old element from old array (of size 1) to new array and at index 1 (n1 in general) you add second element. Similarly for adding third element you create a new array of size 3, copy old elements from old array and at index 2 add new element. After n push the number of copy operations will be ~O(n squared). The complexity can be bettered by repeated doubling i.e. creating a new array of double the size instead of increasing the size by one.
3. Linked list implementation  This is the best approach as stack size here increases and decreases gracefully. Operations are O(1). Only that it uses extra spaces for references.
Set is a better option here. Add array element to the set and check the return value of set.add() which returns true if this set did not already contain the specified element. There is no need of calling contains() to check if the value is already present.
 Rakesh Roy December 27, 2013Node reverse(Node head){
Node temp = null;
Node next = null;
while(head != null){
next = head.getNext();
head.setNext(temp);
temp = head;
head = next;
}
return temp;
}

Rakesh Roy
December 19, 2013 @manu.machilles:
You can optimize your solution as explained below:
"abcbcbbbeeeedfaaccmmopopopn", "bedm"
1. The first call to FindSecondStringInFirst(string str1, string str2) with "abcbcbbbeeeedfaaccmmopopopn", and "bedm". And you get minWindow as beeeedfaaccmm. Now instead of making second call to FindSecondStringInFirst with "abcbcbbbeeeedfaaccmmopopop", and "bedm" , call should be with "abcbcbbbeeeedfaaccm", and "bedm".
2. Once you have the second call done with "abcbcbbbeeeedfaaccm", and "bedm", you get minWindow as beeeedfaaccm. Now the third call should be with "abcbcbbbeeeedfaacc", and "bedm" and since minWindow will be null this time, avoid further calls to FindSecondStringInFirst method. This will optimize your solution in a big way.
I hope I am clear in conveying my idea. Please let me know if you see any problem with the proposed modification to your solution.
This question was already asked: id=5428361417457664
 Rakesh Roy November 16, 2013Suppose Basket labelled "Apples" is Basket#1,
Basket labelled "Oranges" is Basket#2, and
Basket labelled "Mixed" is Basket#3.
Take a fruit from the Basket#3.
If the fruit picked is Apple, take the "Apples" label from the Basket#1 and place it on Basket#3 and we are done.
Basket#2 will be labelled with "Mixed", Basket#1 will be labelled as "Oranges" from the fact that all baskets are labelled incorrectly.
Same logic goes in case the fruit taken turns out to be Orange.
This question can be thought of as a specialized case of the generalized problem set :
Given a rod of length n, divide it into minimum number of parts such that you can generate a rod of each length from 1 to number n. For given n, 2^m<= n < 2^(m+1) , number of cuts will be m and hence numbers of parts will be m+1. In present case n=7 lies in the range [4,8), so number of cuts(divide/break) = 2 (It is true not only for 7 but all the numbers from 4 through 7) and parts = 1,2,4 (for 7).
Suppose jar 1 is labelled lemon
jar 2 > banana
jar 3 > Mix
Take a candy from the jar 3 which is labelled as Mix of both and eat.
Suppose it is lemon, take the lemon label from the jar 1 and place it on jar 3. Now we are done. jar 2 will be mix, jar 1 banana from the fact that all jars have wrong labels.
Same logic goes in case it turns out to be banana candy after eating.
Hi Ajeet,
I am not sure if I have missed some concept in your algo. But I think the piece of code :
if((window[1]  window[0]) > (orderedList.getLast().index  orderedList.getFirst().index)){
window[0] = orderedList.getFirst().index;
window[1] = orderedList.getLast().index;
}
should also be placed outside the second for loop, just to ensure that we are not missing the case where map and LL is updated during the last iteration. For an example:
S = "ADOBECODEBANC"
T = "ABC"
The minimum window if I have understood correctly should be "BANC" (last four character in S), which will be obtained if we check ((window[1]  window[0]) > (orderedList.getLast().index  orderedList.getFirst().index)) one last time after the foor loop. Correct me if I am wrong. Thanks.
Do you mean:
if(tmp >= 2 && tmp <= 9 && factors.size() == 2){ > if(tmp >= 2 && tmp <= 9 && factors.size() == N1){ as N is 3 in this case.
Here is the java implementation of the solution. Logic used has been as suggested by jvermette:
int[][] likeMatrix = { {1, 1, 1, 1, 1},
{0, 1, 0, 0, 0},
{0, 0, 1, 0, 0},
{1, 1, 1, 1, 0},
{0, 0, 0, 0, 1}};
int[] rating = converter(likeMatrix);
ArrayList<Integer> result = finalizePlayers(rating);
print(result, likeMatrix[0].length);
}
public static int[] converter(int[][] likeMatrix){
int result [] = new int[likeMatrix.length];
int rating;
for (int i = 0; i < likeMatrix.length; i++) {
rating = 0;
for (int j = 0; j < likeMatrix[0].length; j++) {
if (likeMatrix[i][j] == 1) {
rating += Math.pow(2, (likeMatrix[0].length  1  j));
}
}
result[i] = rating;
}
return result;
}
public static ArrayList<Integer> finalizePlayers(int[] rating){
ArrayList<Integer> result = new ArrayList<Integer>();
boolean match;
int item;
for (int i = 0; i < rating.length; i++) {
match = false;
for (int j = 0; j < result.size(); j++) {
item = rating[i] & result.get(j);
if(item > 0){
result.remove(j);
result.add(j, item);
match = true;
break;
}
}
if(!match){
result.add(rating[i]);
}
}
return result;
}
public static void print(ArrayList<Integer> result, int totalPlayers){
int index = 0;
System.out.println("Minimum players required are: ");
for (Integer integer : result) {
index = 0;
while(integer>0){
if((integer & 1) >0){
index = totalPlayers  index;
break;
}else{
integer = integer>>1;
index++;
}
}
System.out.print("Player# " + index + " ");
}
}

Rakesh Roy
October 26, 2013 Thanks, I got your point...
 Rakesh Roy October 23, 2013Here I have assume that one move in only two direction. For movement in all the eight directions code needs to be modified accordingly.
 Rakesh Roy October 22, 20131. Write a function of the form:
public static void findPath(int row, int col, int maxRow, int maxCol){
if(row >= maxRow  col >= maxCol){
return;
}
if(row == maxRow 1 && col == maxCol1){
numOfPaths++;
return;
}
if(visited[row][col])
return;
visited[row][col] = true;
findPath(row + 1, col, maxRow, maxCol);
findPath(row, col+1, maxRow, maxCol);
}
2. Use this function to reach from (0,0) to the cell marked gray. Suppose gray cell has coordinate as (x,y), function call in that case would be findPath(0, 0, x, y).
3. In second part use this function to reach from (x,y) to (m1, n1)
I have tried solving this question using subset sum algorithm only. My solution was posted on 17th. It is there in this thread. Only thing is I could not optimize it for space due to other priorities. Solution is working fine.
 Rakesh Roy October 22, 2013@tushar2702: Following is the output if arr[] = { 8, 39, 6} is used in your solution.
8
2
0
P.S: Anyways do not take it otherwise, I have seen people on careercup, who feel very offended if someone finds bug in their code and dislike the post/comment in return :). I think people should be happy that someone is taking his/her time out and going through their code. It can only be helpful.
index_i and index_j both should be 0 as 8 is the largest sum.
 Rakesh Roy October 21, 2013Hello everyone,
Most of the time for anagram related questions we create a int array of 256 length.
Could you please comment if our solutions will work if strings are not consist of English alphabets. I mean if strings are in some other language (e.g., Chinese, Japanese). Will an array of 256 length will suffice in that case.
Time: O(n)
Space: 265*size of (int)
Disclaimer : Not sure it this works for alphabets other than English.
public static boolean areAnagrams(String first, String second){
if(first.length() != second.length())
return false;
int[] char_values = new int[256];
char charAt;
int uniqueCharsInFirstString = 0;
int completedCharsSecondString = 0;
for (int i = 0; i < first.length(); i++) {
charAt = first.charAt(i);
if(char_values[charAt] == 0){
uniqueCharsInFirstString++;
}
char_values[charAt]++;
}
for (int i = 0; i < second.length(); i++) {
charAt = second.charAt(i);
if(char_values[charAt] == 0)
return false;
char_values[charAt];
if(char_values[charAt] == 0){
completedCharsSecondString++;
if(uniqueCharsInFirstString == completedCharsSecondString){
return (i == second.length()1);
}
}
}
return false;
}

Rakesh Roy
October 21, 2013 @tushar2702: have you checked your solution with an array which has +ve numbers in the beginning followed by ve numbers. Something like int arr[] = { 8, 39, 6};.
 Rakesh Roy October 19, 2013Just tested with couple of other data sets : the combination of minimizeSkillGap and printSkillGroup seem to be giving exact/correct result.
 Rakesh Roy October 17, 2013Output : minimizeSkillGap(skillLevel);
Minimum skill diffrerence is 0
leftMask: 6, and rightMask: 2
Array A: 24 1 15
Array B: 25 2 4 9
Output : minimizeSkillGap(input);
Minimum skill diffrerence is 0
leftMask: 6, and rightMask: 1
Array A: 20 20 20
Array B: 1 29 30
@Bruteforce22: Couple of points: 1. the method minimizeSkillGap has code duplicated if and else part to take care of even and odd number of elements. This part can be refactored. There is a lot of code and you may have to spend some time, so better copy and paste into eclipse in case you do not want to waste time.
public static void minimizeSkillGap(int[] v) {
int minDiff = Integer.MAX_VALUE;
int tempDiff = 0;
int leftMask = 0;
int rightMask = 0;
int sum = 0, N = v.length;
int tempSum = 0;
for (int j : v) {
sum += j;
}
int firstHalf, secodnHalf;
if (N % 2 == 0) {
firstHalf = N / 2;
secodnHalf = N / 2;
ArrayList<HashMap<Integer, Integer>> hash = new ArrayList<HashMap<Integer, Integer>>();
for (int i = 0; i <= firstHalf; i++)
hash.add(new HashMap<Integer, Integer>());
int mask, numSubSets = 1 << firstHalf;
for (mask = 0; mask < numSubSets; mask++) {
int subsetSize = 0;
int subsetSum = 0;
for (int i = 0; i < firstHalf; i++) {
if ((mask & 1 << i) > 0) {
subsetSum += v[i];
subsetSize++;
}
}
hash.get(subsetSize).put(mask, subsetSum);
}
for (mask = 0; mask < numSubSets; mask++) {
int subsetSize = 0;
int subsetSum = 0;
int remSize = 0;
for (int i = 0; i < secodnHalf; i++) {
if ((mask & 1 << i) > 0) {
subsetSum += v[i + firstHalf];
subsetSize++;
}
}
remSize = secodnHalf  subsetSize;
// remSum = halfSum  subsetSum;
for (Integer key : hash.get(remSize).keySet()) {
tempSum = subsetSum + hash.get(remSize).get(key);
tempDiff = Math.abs(sum  2 * tempSum);
if (tempDiff < minDiff) {
minDiff = tempDiff;
leftMask = key;
rightMask = mask;
}
}
}
System.out.println("Minimum skill diffrerence is " + minDiff);
printSkillGroup(v, leftMask, rightMask);
} else {
firstHalf = N / 2 + 1;
secodnHalf = N / 2;
ArrayList<HashMap<Integer, Integer>> hash = new ArrayList<HashMap<Integer, Integer>>();
for (int i = 0; i <= firstHalf; i++)
hash.add(new HashMap<Integer, Integer>());
int mask, numSubSets = 1 << firstHalf;
for (mask = 0; mask < numSubSets; mask++) {
int subsetSize = 0;
int subsetSum = 0;
for (int i = 0; i < firstHalf; i++) {
if ((mask & 1 << i) > 0) {
subsetSum += v[i];
subsetSize++;
}
}
hash.get(subsetSize).put(mask, subsetSum);
}
numSubSets = 1 << secodnHalf;
for (mask = 0; mask < numSubSets; mask++) {
int subsetSize = 0;
int subsetSum = 0;
int remSize = 0;
for (int i = 0; i < secodnHalf; i++) {
if ((mask & 1 << i) > 0) {
subsetSum += v[i + firstHalf];
subsetSize++;
}
}
remSize = secodnHalf  subsetSize;
for (Integer key : hash.get(remSize).keySet()) {
tempSum = subsetSum + hash.get(remSize).get(key);
tempDiff = Math.abs(sum  2 * tempSum);
if (tempDiff < minDiff) {
minDiff = tempDiff;
leftMask = key;
rightMask = mask;
}
}
remSize = firstHalf  subsetSize;
subsetSum = 0;
for (Integer key : hash.get(remSize).keySet()) {
tempSum = subsetSum + hash.get(remSize).get(key);
tempDiff = Math.abs(sum  2 * tempSum);
if (tempDiff < minDiff) {
minDiff = tempDiff;
leftMask = key;
rightMask = mask;
}
}
}
System.out.println("Minimum skill diffrerence is " + minDiff);
printSkillGroup(v, leftMask, rightMask);
}
}
static void printSkillGroup(int[] v, int leftMask, int rightMask) {
System.out.println("leftMask: " + leftMask + ", and rightMask: "
+ rightMask);
int i;
int halfLength = 0;
if(v.length % 2 ==0){
halfLength = v.length / 2;
}else{
halfLength = v.length / 2 + 1;
}
ArrayList<Integer> a = new ArrayList<Integer>();
ArrayList<Integer> b = new ArrayList<Integer>();
for (i = 0; i < halfLength; i++) {
if ((leftMask & 1 << i) > 0) {
a.add(v[i]);
} else {
b.add(v[i]);
}
if(i + halfLength == v.length)
continue;
if ((rightMask & 1 << i) > 0) {
a.add(v[i + halfLength]);
} else {
b.add(v[i + halfLength]);
}
}
System.out.print("Array A: ");
for (Integer value : a)
System.out.print(value + " ");
System.out.print("\nArray B: ");
for (Integer value : b)
System.out.print(value + " ");
System.out.println("");
}
Test
public static void main(String[] args) {
final int input[] = { 1, 20, 20, 20, 29, 30 };
final int skillLevel[] = {25,24,15,9,2,1,4};
minimizeSkillGap(skillLevel);
minimizeSkillGap(input);
}

Rakesh Roy
October 17, 2013 Can I assume that your question is : Given an array of integers(skill level) of length n. Suppose sum of the elements of the array is "sum". Divide the elements into two groups of n/2 (if n is even, else n/2 and n/2 + 1) elements such that their group sum is equal to sum/2 if possible else as close to sum/2 as possible.
 Rakesh Roy October 16, 2013I have my LinkedList class whose data is int type.
public class LinkedList {
private int data;
private LinkedList next;
public int getData() {
return data;
}
public void setData(int data) {
this.data = data;
}
public LinkedList getNext() {
return next;
}
public void setNext(LinkedList next) {
this.next = next;
}
}
public static LinkedList mergeListsIterative(LinkedList a, LinkedList b){
LinkedList head = null;
if(a == null)
return b;
else if(b == null)
return a;
if( a.getData() <= b.getData()){
head = a;
}else{
head = b;
b = a;
a= head;
}
LinkedList temp;
while((a.getNext() != null) && b != null){
if(a.getNext().getData() <= b.getData()){
a = a.getNext();
}else{
temp = a.getNext();
a.setNext(b);
b = temp;
}
}
if(a.getNext() == null){
a.setNext(b);
}
return head;
}

Rakesh Roy
October 14, 2013 push() and pop() are already O(1). To implement a Stack to ensure O(1) getMin(), one would need to have two stacks: 1. mainStack, 2. minimumStack and push, pop and getminimum needs to be implemented as below:
public void push(int data){
mainStack.push(data);
if(minimumStack.isEmpty()  minimumStack.top() >= data){
minimumStack.push(data);
}
}
public int pop(){
if(mainSTack.isEmpty())
return 1;
int minTop = minimumStack.top();
int mainTop = mainStack.top();
if(mainTop == minTop)
minimumStack.pop();
return mainStack.pop();
}
public int getMinimum(){
return minimumStack.top()
}

Rakesh Roy
October 14, 2013 The output of the following code is:
[ice,cie,]
[star,rats,arts,]
public class AnagramTest {
/**
* @param args
*/
public static void main(String[] args) {
String[] myWords={"star", "rats", "ice", "cie", "arts"};
List<String> mylist = Arrays.asList(myWords);
anagramBuckets(mylist);
}
public static void anagramBuckets(List<String> input){
Map<String, List<String>> map = new HashMap<String, List<String>>();
ArrayList<String> arrayList;
String temp;
boolean alreadyPresent;
if(input.size()>1){
String first = input.get(0);
arrayList = new ArrayList<String>();
arrayList.add(first);
map.put(first, arrayList);
for (int i = 1; i < input.size(); i++) {
temp = input.get(i);
alreadyPresent = false;
for (String string : map.keySet()) {
if(areAnagrams(temp, string)){
map.get(string).add(temp);
alreadyPresent = true;
}
}
if(!alreadyPresent){
arrayList = new ArrayList<String>();
arrayList.add(temp);
map.put(temp, arrayList);
}
}
}
for (String string : map.keySet()) {
System.out.print("[");
for (String string1 : (ArrayList<String>)map.get(string)) {
System.out.print(string1+",");
}
System.out.println("]");
}
}
public static boolean areAnagrams(String first, String second){
if(first.length() != second.length())
return false;
int[] char_values = new int[256];
char charAt;
int uniqueCharsInFirstString = 0;
int completedCharsSecondString = 0;
for (int i = 0; i < first.length(); i++) {
charAt = first.charAt(i);
if(char_values[charAt] == 0){
uniqueCharsInFirstString++;
}
char_values[charAt]++;
}
for (int i = 0; i < second.length(); i++) {
charAt = second.charAt(i);
if(char_values[charAt] == 0)
return false;
char_values[charAt];
if(char_values[charAt] == 0){
completedCharsSecondString++;
if(uniqueCharsInFirstString == completedCharsSecondString){
return (i == second.length()1);
}
}
}
return false;
}
}

Rakesh Roy
October 12, 2013 Letter can be thought of as a=1; b=2;.......z=26.
Movie name can be iterated upon character by character.
After calculating/finding the value of a letter, move can be made.
From the grid width we can find out the row and column of the letter.
For an example, movie id "vh". v is 22 and h is 8.
Suppose grid width is 13.
22/13 = 1(r1) (second column) and 22%13 = 9(c1)(9th column)
so, v is drrrrrrrr!.
Now h
8/13 = 0 (r2) and 8%13 = 8(c2)
r2r1 = 01 = 1 means u and c2c1 = 89=1 means l
so ul!
and vh is drrrrrrrr!ul!
public class SpiralPrint2DArray {
/**
* @param args
*/
public static void main(String[] args) {
int[][] A = { { 1, 2, 3, 4 },
{ 12, 13, 14, 5 },
{ 11, 16, 15, 6 },
{ 10, 9, 8, 7 } };
int[][] A1 = { { 1, 12, 3, 4 },
{ 2, 13, 14, 15 },
{ 7, 9, 5, 6 },
{ 10, 16, 8, 11 } };
printSpiral(A); //Prints 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
System.out.println();
printSpiral(A1);//1, 12, 3, 4, 15, 6, 11, 8, 16, 10, 7, 2, 13, 14, 5, 9,
}
public static void printSpiral(int[][] A) {
int rowStart = 0;
int colStart = 0;
int rowEnd = A.length;
int colEnd = A[0].length;
do {
for (int i = colStart; i < rowEnd; i++) {
System.out.print(A[rowStart][i] + ", ");
}
// current row is done and no more need to process it
rowStart++;
for (int i = rowStart; i < colEnd; i++) {
System.out.print(A[i][colEnd  1] + ", ");
}
// current column is done and no more need to process it
colEnd;
if (rowStart < rowEnd) {
for (int i = colEnd  1; i >= colStart; i) {
System.out.print(A[rowEnd  1][i] + ", ");
}
rowEnd;
}
if (colStart < colEnd) {
for (int i = rowEnd  1; i >= rowStart; i) {
System.out.print(A[i][colStart] + ", ");
}
colStart++;
}
} while (rowStart < rowEnd && colStart < colEnd);
}
}

Rakesh Roy
October 10, 2013 There is no mention of data sorting in the question. It is just a coincidence (IMHO) that spiral printing is resulting in the sorting data. So, I guess your solution is not a generic one. For and example if the input is
[1,12,3,4]
[2,13,14,15]
[7,9,5,6]
[10,16,8,11]
spiral printing would result in 1, 12, 3, 4, 15,6,11,8,16,10,7,2,13,14,5,9.
but your solution which is sorting also will result in 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16.
Apology if something has been overlooked by me.
There is a difference between two subparts and two subparts with equal number of elements.
 Rakesh Roy October 10, 2013I tried with couple of examples and the below code snippet was giving correct result. It is not an elegant snippet though.
public static void main(String[] args) {
// TODO Autogenerated method stub
//int[] A = {8,9,6,0,3,9}; //Maximum sum is: 23 of the elements from index 0 to 5
//int[] A = {11, 12,28,26}; //Maximum sum is: 26 of the elements from index 3 to 3
int[] A = {11, 16,28,31, 30, 31}; // Maximum sum is: 32 of the elements from index 3 to 5
int sum = 0;
int maxSum = 0;
int indexIL = 0;
int indexI = 0;
int indexF = 0;
for (int i = 0; i < A.length; i++) {
sum += A[i];
if(sum>maxSum){
maxSum = sum;
indexF = i;
if(indexIL>indexI)
indexI = indexIL;
}
if(sum<0){
sum = 0;
indexIL = i+1;
}
}
System.out.println("Maximum sum is: "+ maxSum + " of the elements from index "+ indexI + " to "+ indexF );
}

Rakesh Roy
October 09, 2013 @azizahmad45
Just wanted to check if prev pointer is required??? I think tail pointer is enough and prev can be avoided without affecting the result. In the else part we can do:
tail.next = current.next;
current = current>next;
Suppose I have been given root of the skewed BinaryTree:
//Helper function to find size of tree
int size(BinaryTreeNode root){
if(root == null) return 0;
else{
retrun(size(root.getLeft()) + 1+ size(root.getRight());
}
}
// Inorder traversal
int[] inrderTraversal(BinaryTreeNode root){
int[] inOrder = new int[size(root)];
int index = 0;
if(root != null){
inrderTraversal(root.getLeft());
inOrder[index++] = root.getData();
inrderTraversal(root.getRight());
}
}
// Minimum height tree creation
BinaryTreeNode buildBalancedTree(int[] inOrder, int start, int end){
BinaryTreeNode treeNode;
if(start>end) return null;
treeNode = new BinaryTreeNode();
if(start == end){
treeNode.setData(inOrder[start]);
treeNode.setLeft(null);
treeNode.setRight(null);
}else{
int mid = start + (endstart)/2;
treeNode.setData(inOrder[mid]);
treeNode.setLeft(buildBalancedTree(inOrder, start, mid1));
treeNode.setRight(buildBalancedTree(inOrder, mid+1,end));
}
return treeNode;
}
// testing the APIs, rrot is the root of skewed binary tree in question
int n = size(root);
int startIndex= 0;
int[] inOrder = inrderTraversal(root);
BinaryTreeNode balancedTree = buildBalancedTree(inOrder, 0, n1);

Rakesh Roy
October 07, 2013
Repkaylafgioia, Cloud Support Associate at Absolute Softech Ltd
Hi, I am Kayla from Elkins USA. I am working as Project management and I have professional 3year experience in ...
RepHi, I’m Jamie from the Portsmouth USA and I am working as an account manager. I work for a ...
The sum of three areas can never be less than the initial triangle area.
 Rakesh Roy June 07, 2014