Interview Programs for 0 to 5 years experience
Interview Programs for 0 to 5 years experience
package com.binarytree;
class ListNode {
private Integer value;
private Integer key;
private ListNode next;
if (entry.getKey().equals(key)) {
entry.setValue(key);
} else {
entry.setNext(new ListNode(key, value));
}
}
size++;
}
if (entry.getKey().equals(key)) {
if (prev == null) {
hashTable[hash] = entry.getNext();
} else {
prev.setNext(entry.getNext());
}
}
}
size--;
}
hashtable.put(4, 1);
hashtable.put(44, 3);
hashtable.put(444, 5);
hashtable.display();
int value = hashtable.get(444);
System.out.println(value);
hashtable.remove(4);
hashtable.display();
}
O/P:
Key: 4 Value: 1
Key: 44 Value: 3
Key: 444 Value: 5
5
Key: 44 Value: 3
Key: 444 Value: 5
Longest Palindrome
package com.binarytree;
import java.util.ArrayList;
import java.util.List;
}
O/P:
}
}
}
}
}
O/P:
package com.test;
import java.util.Stack;
O/P:
Not Matched
Print Values in Zig Zag manner.
package com.test;
O/P:
4386712
***************************************************************************
Print Stars
package com.test;
for(int i = 0;i<5;i++){
for(int j = 0;j<=i;j++){
System.out.print("*");
}
System.out.println();
}
}
}
O/P:
*
**
***
****
*****
*
**
***
****
*****
*
**
***
****
package com.test;
import java.util.Scanner;
}
O/P: hseraN ubab cba
package com.binarytree;
}
O/P:
Print 3rd and 5th char in String and 5th char should be Upper character
package com.test;
}
O/P: rSaUtApT
package com.test;
}
O/P: 31 9 21
package com.test;
import java.util.Scanner;
package com.test;
Reverse Number
package com.test;
root.left = rootl;
root.right = rootr;
root.left.left = rootll;
root.left.right = rootlr;
root.right.left = rootrl;
root.right.right = rootrr;
connectSameNode(root);
String r = root.nextRight!=null?root.nextRight.data:"null";
String r2 = root.left.nextRight!=null?root.left.nextRight.data:"null";
String r3 = root.right.nextRight!=null?root.right.nextRight.data:"null";
String r4 = root.left.left.nextRight!=null?root.left.left.nextRight.data:"null";
String r5 = root.left.right.nextRight!=null?root.left.right.nextRight.data:"null";
String r6 = root.right.left.nextRight!=null?root.right.left.nextRight.data:"null";
String r7 = root.right.right.nextRight!=null?root.right.right.nextRight.data:"null";
System.out.println("A->"+r);
System.out.println("B->"+r2);
System.out.println("C->"+r3);
System.out.println("D->"+r4);
System.out.println("E->"+r5);
System.out.println("F->"+r6);
System.out.println("G->"+r7);
3. Number Format