Wednesday, 14 December 2016

Rough Draft , Notes




Should we use foreign keys?
Pro:
 Referential integrity
Cons:
Performance hit

But the performance hit is only when there are a lot of foregin keys. Because for each row inserted,updated,deleted other tables would also be checked
However, foregin keys helps in optimizing queries and increase reading speed
By default indexes aren't created on foreign keys.
Stackoverflow Link

Jackson Json: How to prevent field serialization?
@JsonIgnore or mark the field as transient

Jacson Json vs Gson
Jackson seems to be winning the race. It has a lot of benefits over Gson and performance is also better.
Spring has default support of jackson.
http://stackoverflow.com/questions/2378402/jackson-vs-gson

What's the use of identityhashmap?
It's use is rare, it's used when objects are to be compared via reference equality == and not equals method. Thus, it kinds of break map equals contract ,
http://stackoverflow.com/questions/838528/use-cases-for-identityhashmap




Redis:
 Pipelining can give a big performance boost
Pipelining is used to save RTT(Round trip time), pipelining is nothing but a series of commands sent as one
Redis provides transactions to execute a series of commands
Write MULTI to start, now all the commands will be put in queue, enter EXEC to execute all or DISCARD to discard all. In case something went wrong in between rest will be executed. NO ROLLBACK. Redis supports NO ROLLBACK

Redis scripts are transactional by definition, in future transactions might be deprecated and only scripts will be used.

Redis Memory setting
in redis.conf: maxmemory 100mb, setting it to 0 means no limit, when limit has reached there can be several different eviction policies, noeviction, lru, volatile-lru, etc
Redis doesn't uses true lru,  only apprroximation, a set of keys, to save memory, however setting of sample size can be changed

Redis Cluster
In redis cluster, single db is available, operations involving multiple keys might not be avialable
supports upto 1000 nodes

Read: Redis in Action

Seven Databases in seven weeks
Seven Languages in seven weeks
Seven Web Frameworks in seven weeks

Java SE8 for really impatient











AngularJs

https://www.codementor.io/angularjs/tutorial/angularjs-interview-questions-sample-answers

List at least three ways to communicate between modules of your application using core AngularJS functionality.
Which means of communication between modules of your application are easily testable?
The most popular e2e testing tool for AngularJS is Protractor. There are also others which rely on similar mechanisms. Describe how e2e testing of AngularJS applications work.
When a scope is terminated, two similar “destroy” events are fired. What are they used for, and why are there two?
How do you reset a “$timeout”, and disable a “$watch()”?
Name and describe the phases of a directive definition function execution, or describe how directives are instantiated.
How does interpolation, e.g. “{{ someModel }}”, actually work?
How does the digest phase work?
List a few ways to improve performance in an AngularJS app.
What is $rootScope and how does it relate to $scope?
What is AngularJS?
What is data binding in AngularJS?
What is scope in AngularJS?
What are the controllers in AngularJS?
What are the services in AngularJS?
What are the filters in AngularJS?
Explain directives in AngularJS.
Explain templates in AngularJS.
What is routing in AngularJS?
What is deep linking in AngularJS?
What are the advantages of AngularJS?
What are the disadvantages of AngularJS?
Which are the core directives of AngularJS?
Explain AngularJS boot process.
What is MVC?
Explain ng-app directive.
Explain ng-model directive.
Explain ng-bind directive.
Explain ng-controller directive.
How AngularJS integrates with HTML?
Explain ng-init directive.
Explain ng-repeat directive.
What are AngularJS expressions?
Explain uppercase filter.
Explain lowercase filter.
Explain currency filter.
Explain filter filter.
Explain orderby filter.
Explain ng-disabled directive.
Explain ng-show directive.
Explain ng-hide directive.
Explain ng-click directive.
How angular.module works?
How to validate data in AngularJS?
Explain ng-include directive.
How to make an ajax call using Angular JS?
What is use of $routeProvider in AngularJS?
What is $rootScope?
What is scope hierarchy in AngularJS?
What is a service?
What is service method?
What is factory method?
What are the differences between service and factory methods?
Which components can be injected as a dependency in AngularJS?
What is provider?
What is constant?
Is AngularJS extensible?
On which types of component can we create a custom directive?
What is internationalization?
How to implement internationalization in AngularJS?


What is notion of directives in AngularJS?
Name some of the most commonly used directives? What is uage of ng-app, ng-controller, ng-view, ng-model etc?
Explain how MVC is achieved with AngularJS? What are the benefits of client-side MVC, in general?
What is $scope object? Who injects it? Why is it used?
What is $scope.$apply and $scope.$digest method?
What is two-way data binding? Give an example?
Give an example of dependency injection with respect to AngularJS?
What is concept of routing? Show with an example? What Angular module is required to execute routing functionality?
How could one create single-page application using AngularJS? Which provider is used to achieve this objective?
What setup may be needed to do unit testing with AngularJS? What features of Angular come handy for doing unit tests?


  1. Can the angular application be initialized on only HTML element or ANY element?
    Ans: ANY element
  2. Can an HTML page have multiple “ng-app” directive for bootstrapping multiple AngularJS application?
    Ans: Yes
  3. With more than one ng-app in an HTML document (an HTML page), are they automatically initialized? Describe the angularJS application initialization process with multiple ng-app in an HTML document/page.
    Ans: Only one AngularJS application can be auto-bootstrapped. The first ‘ng-app’ found in the document will be used to define the root element to auto-bootstrap as an application. To run multiple applications in an HTML document, one must manually bootstrap them using angular bootstrap service.
  4. Describe the steps involved in bootstrapping an angular application?
    Ans: Following steps are involved in bootstrapping the angular application:
    • Determine the element consisting of ng prefixes with “app”
    • Check whethar an angular app already exists on the element
    • Compile & link with the help of dependencies such as rootScope injected (used for linking).
  5. Can angular applications (ng-app) be nested within each other?
    Ans: No
  6. What are various possible prefixes such as “ng-” using which Angular directives (for example, ng-app) can be defined?
    Ans: “ng-“, “data-ng-“, “ng:”, “x-ng-“
  7. What are various possible ways in which angular application can be initialized?
    Ans: On an element, one could either put simply the attribute such as (ng-app, data-ng-app, ng:app, x-ng-app) or put the named attribute such as (ng-app=”demoApp”).
  8. What angular function is used to manually start up an angular application?
    Ans: angular.bootstrap
  9. Can multiple angular applications be bootstrapped using same element?
    Ans: No. An error is thrown such as “App Already Bootstrapped with this Element”
  10. At framework level, how does Angular retrieve the matching elements for processing?
    Ans: Makes use of jqLite(element) function. If jQuery is used, jQuery(element) is used by way of assigning jQuery to jqLite variable.>

Monday, 12 December 2016

Java all Part II

Why we can't do subtyping in generics?

Why generics array can't be created?


What are the new features in Java 8?
-foreach,spliterator in interable interface

What is Spliterator?

What is Consumer interface?

What is Predicate interface?

What is functional interface?
An interface with exactly one abstract method becomes Functional Interface.

What is the use of functional interface?
It's greate to use it in lambda expressions.

What are Single Abstract Method interfaces(SAM)?

default vs static in interface?
We can't override static. static is indeed static, it isn't inherited, can be used directly with Interface name. So, now interface can contain static methods.

What is the use of @FunctionalInterface annotation?
We don’t need to use @FunctionalInterface annotation to mark an interface as Functional Interface. @FunctionalInterface annotation is a facility to avoid accidental addition of abstract methods in the functional interfaces. You can think of it like @Override annotation and it’s best practice to use it. 

What is map reduce?
map function transforms input like doubling each value, reduce function convert list to some value like average,sum,etc.

What new methods have been added to Collection iterface?

What new methods have been added to Iterable interface?


What new methods have been added to Map interface?

Stream vs parallel stream?

flatMap?
Flatten a stream of list of stream.


Jdbc in java8

What is jdbc-odbc bridge, why is it removed in Java8?
http://stackoverflow.com/questions/14229072/removal-of-jdbc-odbc-bridge-in-java-8


Benefits of lambda expressions?

Method reference?

Constructor reference?

Repeated annotation?

Optional?















Tuesday, 11 October 2016

Posts worth reading

https://dzone.com/articles/java-encapsulation-for-adults


Saturday, 17 September 2016

Friday, 16 September 2016

Maven All

Build tools


enter image description here




What are the most common maven plugins used?
surefire - for unit testing
dependency - for module dependency analysis
cobertura - for unit test coverage analysis
liquibase - for running database migrations
assembly - for creating single executable jars containing all the required dependencies of an app


Which maven plugins have you used?
Name: maven-javadoc-plugin
               Location: https://maven.apache.org/plugins/maven-javadoc-plugin/
               Version: 2.10.3
               License: http://www.apache.org/licenses/LICENSE-2.0

               Name: maven-compiler-plugin
               Location: https://maven.apache.org/plugins/maven-compiler-plugin/
               Version: 2.10.3
               License: http://www.apache.org/licenses/LICENSE-2.0


               Name: maven-assembly-plugin
               Location: http://maven.apache.org/plugins/maven-assembly-plugin/
               Version: 2.10.3

               License: http://www.apache.org/licenses/LICENSE-2.0

What is scope in dependency?

There are 6 scopes available:
  • compile
    This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.
  • provided
    This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.
  • runtime
    This scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath.
  • test
    This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases. This scope is not transitive.
  • system
    This scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.
  • import (only available in Maven 2.0.9 or later)
    This scope is only supported on a dependency of type pom in the <dependencyManagement> section. It indicates the dependency to be replaced with the effective list of dependencies in the specified POM's <dependencyManagement> section. Since they are replaced, dependencies with a scope of import do not actually participate in limiting the transitivity of a dependency.

Maven vs Ant?

What are repositories in Maven?

What is mojo?
Maven plain old java object

How to output debug in Maven?
Run with -e or -X parameter.

How to run ant tasks in Maven?
-Using antrun plugin
-

How do I tell Maven to use the latest version of a dependency?
For maven 2, use latest or release, dropped in maven 3 for reproducable builds.

What exactly is a Maven Snapshot and why do we need it?
A snapshot version in Maven is one that has not been released.



Tuesday, 26 July 2016

Coding (DSA) All

Write code to check a String is palindrome or not?


public class StringCheckPalindrome {
 
 public static void main(String[] args) {
  System.out.println(checkPalindrome("abc"));
  System.out.println(checkPalindrome("abccba"));
  System.out.println(checkPalindrome("aba"));
  System.out.println(checkPalindrome(""));
 }
 
 static boolean checkPalindrome(String str){
  boolean result=true;
  char[] chars = str.toCharArray();
  
  for(int i=0;i<str.length()/2;i++){
   if(chars[i]!=chars[str.length()-1-i]){
    result=false;
    break;
   }
    
  }
  return result;
  
 }

}


//Write a method which will remove any given character from a String?

public class Solution {

 public static void main(String[] args) {
  System.out.println(removeChar("abcd", 'b'));
  System.out.println(removeChar("babbcbdbb", 'b'));
 }
 
 static String removeChar(String str, char ch){
  String result = null;
  char[] chars = str.toCharArray();
  StringBuilder sb = new StringBuilder();
  for(char ch1: chars){
   if(ch1!=ch){
    sb.append(ch1);
   }
  }
  return sb.toString();
 }
}

Thursday, 14 April 2016

NoSQL All

MongoDB

CouchDB

DynamoDB

Node.js All

What is event loop?
Why node.js is used?

Sunday, 14 February 2016

MegaList

*********************************
Topics covered here:
DS & Algo
Java
Multithreading
Collections
Spring
Hibernate
Design Patterns
SQL
Web Services
OS
Networking
Puzzles
HR
Other General
*************************
Combined problems
IPC
Beautify input json
Given string and regex , give no. of times it occurs.
Find next greater number with same set of digits
Determine whether a point is inside a polygon?
Number of squares in chess , gneralize it
Tug of War problem
Given binary tree , sum of each level
Length of longest substring with no duplicat character
8 ball puzzle
Design parking lot
paging in os
regex for email
Given BST , traverse only left sub tree
Red Black Tree
AVL tree
Find the maximum number that can be formed from the digits of given number
Design elevator ,
parse xml , store outpout in json
find prime number in given range
what are cookies
how to maintain sesion
angle between hour clock and minute
Design data structure that supports insert,delete , find max , delete max in O(1)
Convert roman to integers and vice versa
Number of BST from 1 to n
Given array , create another array which contains product of all elemetns except ith aray , witout using divioson.
Implement hash tables
find maximum weight matching in bipaartite graph
3 , 7 , 5 liter milk container puzzle
sort stack using only another stack
how threading works at cpu level
thrasing?
page replacement policies?
paging?
page fault?
How a server works?
compilation vs interpretation?





Questions-to-Ask-Hiring-an-Offshore-Call-Center-Services-Provider
DS , Algo ,Bit Magic (Solve each problem in every possible way)
1. Write code to find loop in linkedlist
2. Write code to reverse a linkedlist
3. Write code to reverse a string without using any API.
4. Implement Djikstra.
5. Write code for  DFS,BFS,inorder,preorder,postorder,zigzag in tree.
6. Implement quick sort.
7. Implement merge sort.
8. Implement autosuggest feature from a list of words.
9. Implement LRU.
10. Write code to find diameter, height of tree(or binary tree?).
13. Write code to check if a number is power of 2.
14. Write code to search a number in rotated array.
21. Write code to check if a number is prime.
Find LCA(Lowest Common Ancestor) in a binary tree.
12. Write code to find number of set bits in an integer.
5. Write code to find kth element from end in a linked list ?
6. Write code to find the missing number in an integer array having 1 to 100 in random order except a number.
10. Write code to check if linkedlist is palindrome.
12. Implement Prim.
15. Write code to search a number in a sorted 2d matrix.
16. Write code to print 2d matrix in spiral order.
17. Write code to find kth largest element in an array.
18. Implement stack using queue.
19. Implement queue using stack.
20. Implement two stack using an array.
21. Implement three stacks using an array.
19. Write code to check integer is palindrome.
19. Write code to check string is palindrome.
20. Write code to find maximum continous subarray in an array.
21. Write code to find longest palindrome substring in a string.
22. Write code to find best time to buy sell stock.
22. Write code to swap two numbers.
23. Write code to find sum of digits
24. Write code to reverse an integer.
24. Write code to print first n numbers infibonacci series.
25. Write code to print nth fibonacci number.
25. Write code to add two numbers represented by a linked list.
26. Write code for bubble sort.
27. Implement radix sort.
28. Implement counting sort.
29. Implement insertion sort.
30. Implement selection sort.
31. Implement heap sort.
32. Implement bucket sort.
33. Write code to find first repeated character in a string.
34. Write code to find first unique character in a string.
How to find middle element of linkedlist in one pass?
Write code to remove duplicates from an array.
Implement BST.
Implement doubly linked list.
Implement doubly linked list using single pointer.
Write code to convert decimal to binary.
Write code to sort a map by value.
Write code to find common elements in two arrays.
Find longest substring without repeating characters.
Determine whether a point lies inside a triangle.
Nuts and bolts problem.
What is the probability that knight stays inside the chess board?
Implement stack using likedlist.
Implement queue using linkedlist.
Check for balanced paranthesis in an expression.
Sort an array containing only 0 and 1.
Sort a linkedlist containing 0,1,2.
Minimum number of platforms required at railway station.
convert word to another , one time one character , from a list of words.
Break string into dictionary words.
Find seed of a number. A number X is seed of Y if multiplying X by it's digits equates to Y.
Finds pairs of numbers with difference k  from an unsorted array.
Find number of trailing zeros in a number factorial.
Given an array containing 0 and 1 , find the largest subarray cotaining equal number of 0 and 1.
Sort an array of elements by decreasing order of frequency.
Given an array of words , group all anagrams in set
Find the min element in a sorted rotated array.
Delete all leaves from a binary tree.
Find two elements in an array whose sum is closest to zero.
Given two rectangles if they overlap or not (Imp)Find max sub square submatrix in a 2d matrix of 0 and 1 with all 1.
Minimum coin problem
Rotate an array by k
Find the level of a given node in a binary tree
Implement heap sort
Implement priority queue.
Find difference in the sum of nodes at odd level and nodes at even level of  a binary tree.
Check for children sum property of a binary tree.
Inorder predecessor in a binary tree
Inorder successor in a binary tree.
Rotate linked list by k nodes
Sort an array of 0,1,2.
Find pair of elements in an array whose sum is equal to given number.
Check whether two strings are anagram.
Given a  linked list , each node has two pointers , one point to next , another to some random node , How to copy it  ?
Get intersection point of two linked lists. (imp)
count nodes in a tree
determine if two binary trees are identical?
Implement binary search algorithm(imp)
sort an almost sorted array with two elements swapped
merge two sorted array without using extra space , assuming first array has enough space
Find minimum distance between two elements in an array
Print all the leaders in an array.
Given a 2d matrix m of 0 and 1 , if m[i][j] is 1 , fill row i and col j with 1
Replac each element of an array with next greatest element.
Find row with max 1 in sorted matrix
Find the number occuring odd number of times in an array , rest occur even number of times.
Given k sorted arrays of size n , merge them.
Find all pythogorean triplets in an array.
Convert sorted array to balanced BST.
Find LIS contigous.
Find LIS non contigous.
Find sub array whose sum equals given number.
Find max diff. between two elements in an array such that larger appears after smaller.
Find majority(occurs more than half) element in an array in O(n).
Even numbers at even pos , odd at odd in an array
Find union and intersection of two arrays.
Find smallest positive number missing from an array.
Shift zeros to end of array
Reverse linkedlist in group of k
Remove spaces from a sentence.
Reverse each word of a sentence
multiply two numbers using min. number of additions
detect cycle in graph
print bottom view of binary tree
print top view of binary treeadd two integers without using +
randomized quick sort
In a 2d matrix , a sub square matrix is painted , find minimal/optimal cost of painting the rest using a fixed block. which block to use ?
Floyd WarshallA 2d matrix containing 0,1,2 , 0 -> empty orange , 1-> fresh orange , 2-> rotten orange , how much time so that all are rotten , a rotten orane will rot adjacent (not diagonal) in one time frame.
Given a binary tree, n and k , find sum of all nodes which are k nodes away from node n.
mirror a binary tree
check if two binary trees are mirror
Convert BST to DLL.
check binary tree is bst
convert sentence like 'these are twelve pens and two shirts. convert it to 'these are 12 pens and 2 shirts'. Inline
Given linkedlist of moves of 2 players on tic tac toe , find who won
Given pile of 9 objects , Pick 1,2,or 3. 2 Players , last one to pick is looser. Give winning strategy.
Given stream of integers , give me median at any time.
Construct BST from pre and inorder
Rod cutting problem
Deletion in bst
Implement using BST
How many bits need to change to convert one num to other?
Check MSB is 0/1 ?
T9 dictionary implement



Java
1. What is OOPS ?
2. How hashmap works in Java ? Difference between hashmap and hashtable ? What will happen if I put a key which already exists in hashmap ?
3. What is an interface ? Difference between interface and abstract class ? When to use which ?
4. Overloading vs overriding ?
5. Why string is immutable ?
6. What is difference between arraylist and linkedlist ?
7. What is difference between JDK, JRE and JVM ?
8. Why use getters and setters ?
9. Does Java support multiple inheritance ? Why or why not ?
10. What are the types of Exceptions ? How are they different ? What are the best practices for exceptions ?
11. Can we override private , static methods ?
12. What is generics , why use generics ?
13. Why can't we use polymorphism in generics ?
14. What is a thread ? What is a process ? What's the difference ?
15.  What is final keyword ? How it's used in java ?
16. What's the importance of serializableversionid ?
17. What if I put return in try block , catch block and finally block ? In which scenario finally is not executed ?
18. What is garbage collection ? How it's done ?
19. What is the use volatile , transient keywords ?
20. What is java memory model ?
21. String vs StringBuffer vs StringBuilder
22. What is thread safety ? What is race condition? What is deadlock ? What are the conditions for deadlock ? Give an example of deadlock. How to prevent deadlock ? What is livelock? Example?
23. Semaphore vs mutex vs lock vs synchronized
24. What is classloader ? Types? How classloader works ?
25. What is JVM? How does it works?
26. Can I overload main method?
27. What is ThreadLocal class? Why use it?
28. Wait vs sleep vs yield?
29. Is java compiled language or interpreted language?
30. Executor.submit vs Executor.execute?
*****************
Is java platform independent ? How ?
static class vs singleton
thread lifecycle
.throw vs throws?
Error vs exception?
What are marker interfaces? Examples?
*******
26. Difference between string created as new and as literal
what is composition, aggregation and association ?
composition vs inheritance?
How to iterate over hashmap key values ?
What if I return a constant value from hashcode method?
What are the rules of overriding ?
IF a method throws FileNotFoundException in super , can the same method in subclass throws IOException
IF a method throws NullPointerException in super , can the same method in subclass throws ArrayStoreException
Can any class be added to treemap ?
Can you access non static variable in static context?Why or why not ?
23. What is the base class of all exceptions ?
What is bytecode ?
What's the size of character in java ? Why ?
What is JIT ?
How is java secure language?
What are the features of Java language ?
Is java strongly typed ?
How java compiler compiles a java program? What about dependencies?
What should be the file name of java?
Can I write a different filename than class name?
Is empty java source file valid?
Can I print something from a program not having main method?
Why main method is static?
I have two methods of same name , one accepts string , other object , I pass argument as null , which one will be called?
same question , for string and stringbuffer
what if I declare getter , setter without declaring variable?
Is javascript part of java ?
what is constructor?
constructor vs method
is constructor inherited?
can constructor be overloaded?
can constructor be overriden?
does java provides copy constructor?
what is the first statement of any constructor?
Explain how memory is allocated by JVM?
How is java WORA ?
what is the difference between static method and non static method?
Does java support pointers? Why or why not?
How to create a virtual function in java?
Is it necessary to initialize final variable?
Can you declare main method as final?
what is static binding and dynamic binding? Difference?
what is compile time binding and runtime binding?
what is abstraction?
what is encapsulation?
abstraction vs encapsulation?
Give real life examples of abstraction,encapsulation,inheritance.
can a class be abstract and final?
is goto a keyword in java?
is const a keyword in java?
can an interface be final?
can we declare variables in interface?
Can we mark constructor as protected? What will it mean?
What are packages? What are two strategies to group classes in packages?
What is the first line in any class?
What is the order of execution in a class?
What if I import same class twice?
Should I import as java.util.* or java.util.<some class>? Difference?
What is static import?
Which package is imported by default?
Base class for error and exception?
What is exception propagation?
Can an exception be rethrown?
Can a subclass overriding method throw an exception not thrown by superlcass method?
What is intern method?
iteration vs enumeration
can we overload static methods in java
why constructor be final,static,abstract
Multithreading
1. What is a thread ? What is a process ? What's the difference ?
2. How to create a thread ? Which way do  you prefer ? What's the difference between runnable and callable ?
3.multithreading best practices
4. What is volatile keyword ?
5. What is thread safety ? What is race condition? What is deadlock ? What are the conditions for deadlock ? Give an example of deadlock. How to prevent deadlock ? What is livelock ?
6. Semaphore vs mutex vs lock vs synchronized
7. Why wait , notify , notifyAll are declared in Object class ? Why wait and notify should be called from synchronized block ? notify vs notifyAll
8. How to create immutable objects in java ?
9. sleep vs wait vs yeild
10. Write code to solve producer consumer problem.
11.write thread safe singleton
12. how threads are scheduled in java?
13. countdownlatch vs cyclicbarrier
14. How to stop a thread ?
15. what is thread pool ? How to use , why to use ?
16. threadlocal
17. submit vs execute in thread pool
18. readwritelock
19. reentrant lock
20. fork join framework
21. how to ensure sequence in multiple threads
22. start vs run
23. What is Java memory model ?
24. what is thread group ? Should we use it ?
25. green thread , native thread
whole method synchronized vs critical section synchronized ?
Java Collections:
1. What is a collection ? What is collections framework ? What are the benefits ?
2. What is the difference between collection , Collection and Collections ?
3. What are the importatnt interfaces of collections framework? Draw  the diagram for collections framework heirarchy.
4. What is the difference between ArrayList and Vector ?
5. How hashmap , hashset and treemap works ? What is the difference between HashMap , Hashtable , concurrenthashmap?
6. What is the difference between ordered and sorted ? Which two interfaces are used for providing sorting order ?
7. Why map is not part of collections framework ?
8. What Collection doesn't implement Serializable and Cloneable interface ?
9. What is the difference between fail fast and fail safe iterator ?
10. What is copyonwritearraylist and why it is used ?

Spring
1. What is spring ? Why use spring ?
2. What is IoC ? What is DI ? Types of DI ? When to use which ?
3. What are the modules in spring ?
4. What is AOP ? Why use it ?
5. What is spring MVC ?
6. What is lifecycle of bean ?
7. What is beanfactory and application context ? Differences ?
8. What are scopes of bean in spring ? Differences ?
9. Which design patters are used in spring ?
10. What are the new features in spring 4 ?
11. What is bean auto wiring? What are different types of doing that?
12. How will you resolve circular dependency in spring?
13. What is aspect, joinpoint, pointcut, advice, introduction, target?
14. What is weaving? Types?
15. how to integrate hibernate with spring ?
16. What is spring mvc? How to setup spring mvc?
17. how to develop rest web services in spring?
18. What are best practices in spring?
19. What is the difference between n-tier and MVC?
20. How is transaction management done in spring? Types? Prefer?
Difference between @Component, @Repository, @Service ?
15. What is dispatcher servlet?
16. types of IOC container in spring ? Differences ?
17.
18. how spring simplifies jdbc ?
19.
20.
21. different jdbc template ? purpose ?
22. spring aop vs aspectJ aop ?
23. does spring framework supports all join points ?
24. what is front controller class in spring mvc
25. @Controller
26. @RequestMapping
27. @PathVariable
28. ViewResolver ? Types ?
29.
30. How validation in spring ?
31. Benefits of spring tool suite ?
32. What is spring bean ?
33. Bean life cycle ?
33. Different ways of configuring spring bean ?
34.
35. what is context loader listener ?
36. what is multipart resolver and when it's used ?
37. how to handle exceptions in spring  , spring mvc  , sprin jdbc , etc?
38. does spring bean provide thread safety ?
39. can we have multiple spring configuration files ?
40. what is spring mvc interceptor ?
41. what is spring security ?
42. how to inject properties ?
43. how to use collections in spring ?
44.
45. design patterns used in spring ?
46. what is spring xml based configuration and java based configuration and annotation based? difference ? which one you prefer and use ?  (redefine it)
47. are singleton beans thread safe ?
48. Explain @Autowired
49. Explain @Qualifier
50. Explain @Inject
51. Explain @Required
52. DIfferent types of events in spring ?
53. Difference between FileSystemResource , ClassPathREsource
54. What are different implementation/types of ApplicationContext ?
57. what are inner beans ?
58. what are limitations in autowiring ?
59. how to turn on annotation wiring ?
60. what is spring dao ? (??)
61. spring aop target object ?


Hibernate
1. What is hibernate? Why use it? Benefits over JDBC?
2. How to set up hibernate?
3. What is mapping, one to one, etc and how to do it?
4. How inheritance is handled?
5. What is the difference between transient, persistent and detached objects?
6. Explain hibernate cache.
7. What is session,sessionFactory? Are they threadsafe?
8. How transaction management is done in hibernate ?
9. What's the architecture of hibernate?
10. HQL vs SQL?
11. Difference between get and load in hibernate ?
12. Why it's important to provide no argument constructor ?
13. What is the difference between save, persists, saveOrUpdate ?
14. What is named SQL query ?
13. What is the difference between session's lock and update method?
14. Explain second level cache in detail.
15. What is query cache in hibernate?
What is criteria API? Pros and cons?
16. Can we make a hibernate class entity final?
17. What is ORM? What's the use? Examples?
18. How to create sessionFactory?
19. What are POJOs , what's their significance?
20. How to invoke stored procedure in hibernate?
21. What are the types of collections in hibernte?
22. What are the four ORM levels in hibernate?
23. How primary key is created in  hibernate?
24. How can we reattach any detach objects in hibernate?
25. What are different fetching strategies of hibernate?
26. How database table is mapped with java object?
27. What is the use of version property in hibernate?
28. Does hibernate supports polymorphism?
29.
Design Patterns
1. Which design patterns have you used ?
2. What is the difference between factory , abstract factory and builder ?
3. Write code for singleton , observer ?
4. Difference between strategy and state ?
5. What are the best coding practices in Java ?
6. Design ATM , parking lot , wallet , ecommerce.
7. Question on one of the following , singleton , factory , abstract factory , builder , prototype , observer , facade , decorator, dao. Give real life example of these.
8. Code to solve producer consumer problem.
9. What is MVC and n tier ? Why use it ? Difference
10.What are the types of patterns? Differences ?
Design Chess
SQL
1. What is difference between delete and truncate ?
2. What are different types of join ?
3. A question on join , especially self join such as , How to find all employees who are also manager ?
4. How to find second highest salary ?
5. What are indexes ? Types ? Difference ? Why use index ? Pros and cons ?
6. What is primary key , foreign key , unique key , candidate key ? Differences ?
7. What is normalization ? Types ? How to achieve ? What is denormalization ?
8. What is view ? Why use it ?
9. What are types of query (correlated , subquery) ?
10. What are constraints , different type of constraint , when to use which ?
ACID?
Web Services
1. What are web services ? Why use them ?
1. What is service oriented architecture ? Benefits ?
2. What is REST ? Why use it ? What is a resource ?
3. Difference between rest and soap ? When to use which ?
4. Difference between get and post ?    Difference between put and post ?
5.What happens if RestFull resources are accessed by multiple clients ? Do you need to make it thread-safe?
Client server technology
Servlet , JSP
1. What is a servlet ? What are it's advantages ?
2. What is the difference between web server and application server ?
3. How many instances of a servlet are created? Are servlet thread safe?
4. What is the difference between servletcontext and servletconfig object ?
5. How can we create deadlock in servlet ?
6. How to do session management ?
7. What is the life cycle of a servlet ?
8. What is the difference between URL encoding and URL rewriting ?
9. How does cookies work ?
10. What is the difference between get and post ?
OS:
1. What is the difference between a process and a thread ?
2. What is a semaphore , mutex , lock ? Differences ?
3.  What is virtual memory ?
4. What is paging ? What is segmentation fault ?
5. What is banker's algorithm ?
6. When does thrasing occurs ?
7. What is deadlock ? What are the conditions for it ? How to prevent it ?
8. What are the types of scheduler ?
9. What is belady's anomaly ?
10. What is dining philosopher problem and solution ?
How ftp works
Linux:
Grep
Others
xml vs json
Networking
What is IP address?
What is MAC address?
What is MAC layer?
OSI?
TCP?
Network Address Translation?
DNS?
Checksum error correction
3 bit parity
HTML , Javascript , CSS , Web
What is HTML5 ?
What is jquery ? Why use it ?
What is the difference bewtween '==' and '===' ?
What is CSS ? Advantages ?
What is css box model ?
What is ajax ? Why and how to use it?
What is closure ? Give example?
Can you access cookie using javascript ?
How to redirect url using javascript ?
What is the use of void(0) ?
Puzzles100 floors and 2 eggs
Hats on three men , in a line , tell color
Rickety bridge , 1,2,7,10 min , one lantern , max two people on bridge
switches outside a room , how to find which one is for bulb
2 candles each burn in 30 min , how to measure 45 min
Ants are moving from corners of equilateral traingle. Probability won't collide ?
Camel and banana
100 doors , flipped as you pass
5 pirates , 100 gold coin , strategy
country people want only boy , ratio of boys to girls
100 trucks , 1000 mile...
50 red marbles , 50 blue marbles , 2 jars ,  one jar selected , one marble selected , maxiimize prob. of red marble
How many points are there on the globe where, by walking one mile south, then one mile east and then one mile north, you would reach the place where you started?
A duck that is being chased by a fox saves itself by sitting at the center of circular pond of radius r. The duck can fly from land but cannot fly from the water. Furthermore, the fox cannot swim. The fox is four times faster than the duck. Assuming that the duck and fox are perfectly smart, is it possible for the duck to ever reach the edge of the pond and fly away to its escape from the ground?
There are n houses in a row , we have to paint them in R,G,B , no two house can have same clor , each paint has cost associated , find min cost
Gold bar puzzle
25 Horses puzzle
Max number on sphere which are equidistant?
How many points can be equidistant to each other?

HR
Tell me abt yourself
Why <this company>?
Your weaknesses?
5 years?
Any question?
Why to hire you?

General
Trending Technologies




****************Top 10******************************8

Solve each problem in every possible way.
Top 20 DS , Algo ,Coding , Bit Magic
1. Write code to find loop in linkedlist , reverse a linkedlist , is Palindrome
2. Find LCA in a binary tree.
3. Do DFS ,BFS,inorder , preorder ,postorder ,zigzag in tree. (recursive +iterative)
4. A question on sorting among bubble , quick , merge
5. How to find middle element or kth element from end in a linked list ?
6. In an integer array, there is 1 to 100 number, out of one is duplicate, how to find ?
7. Write code to reverse a string without using any API.
8. Write a program to find diameter , height of tree.
9. How will you implement a dictionary ?
10. Implement LRU.
11. Djikstra , prim
12. Find number of set bits.
13. Check number is power of 2.
14. How to search in rotated array ?
15. Search in a sorted 2d matrix.
16. Print 2d matrix in spiral
17. Find kth largest element in array
18. Implement stack using queue , queue using stack , two stack using an array.
19. Check string/integer is palindrome.
20. A DP problem , such as find maximum subarray , longest palindrome substring , best time to buy sell stock
Top 10 Java
1. What is OOPS ?
2. How hashmap works in Java ? Difference between hashmap and hashtable ? What will happen if I put a key which already exists in hashmap ?
3. What is an interface ? Difference between interface and abstract class ? When to use which ?
4. Overloading vs overriding ?
5. Why string is immutable ?
6. What is difference between arraylist and linkedlist ?
7. What is difference between JDK, JRE and JVM ?
8. Why use getters and setters ?
9. Does Java support multiple inheritance ?
10. What are the types of Exceptions ? How are they different ?
Top 10 Multithreading
1. What is a thread ? What is a process ? What's the difference ?
2. How to create a thread ? Which way do  you prefer ? What's the difference between runnable and callable ?
3.multithreading best practices
4. What is volatile keyword ?
5. What is thread safety ? What is race condition? What is deadlock ? What are the conditions for deadlock ? Give an example of deadlock. How to prevent deadlock ? What is livelock ?
6. Semaphore vs mutex vs lock vs synchronized
7. Why wait , notify , notifyAll are declared in Object class ? Why wait and notify should be called from synchronized block ? notify vs notifyAll ?
8. How to create immutable objects in java ?
9. sleep vs wait vs yield
10. Write code to solve producer consumer problem.
Top 10 Collections
  1. What is a collection ? What is collections framework ? What are the benefits ?
  2. What is the difference between collection , Collection and Collections ?
  3. What are the importatnt interfaces of collections framework? Draw the diagram for collections framework heirarchy.
  4. What is the difference between ArrayList and Vector ?
  5. How hashmap , hashset and treemap works ? What is the difference between HashMap , Hashtable , concurrenthashmap?
  6. What is the difference between ordered and sorted ? Which two interfaces are used for providing sorting order ?
  7. Why map is not part of collections framework ?
  8. What Collection doesn't implement Serializable and Cloneable interface ?
  9. What is the difference between fail fast and fail safe iterator ?
  10. What is copyonwritearraylist and why it is used ?
Spring
1. What is spring ? Why use spring ?
2. What is IoC ? What is DI ? Types of DI ? When to use which ?
3. What are the modules in spring ?
4. What is AOP ? Why use it ?
5. What is spring MVC ?
6. What is lifecycle of bean ?
7. What is beanfactory and application context ? Differences ?
8. What are scopes of bean in spring ? Differences ?
9. Which design patters are used in spring ?
10. What are the new features in spring 4 ?
Spring MVC
1.  What is spring mvc ? Explain the architecture ?


Hibernate
1. What is hibernate ? Why use it ? Benefits over JDBC ?
2. How to set up hibernate ?
3. Difference between get and load in hibernate ?
4. What is session , sessionFactory? Are they threadsafe?
5. What is the difference between transient , persistent and detached objects ?
6. Explain hibernate cache.
7. Why it's important to provide no argument constructor ?
8. What is mapping , one to one , etc and how to do it ?
9. How inheritance is handled ?
10. How transaction management is done in hibernate ?
Design Patterns
1. Which design patterns have you used ?
2. What is the difference between factory , abstract factory and builder ?
3. Write code for singleton , observer ?
4. Difference between strategy and state ?
5. What are the best coding practices in Java ?
6. Design ATM , parking lot , wallet , ecommerce.
7. Question on one of the following , singleton , factory , abstract factory , builder , prototype , observer , facade , decorator, dao. Give real life example of these.
8. Code to solve producer consumer problem.
9. What is MVC and n tier ? Why use it ? Difference
10.What are the types of patterns? Differences ?
SQL
1. What is difference between delete and truncate ?
2. What are different types of join ?
3. A question on join , especially self join such as , How to find all employees who are also manager ?
4. How to find second highest salary ?
5. What are indexes ? Types ? Difference ? Why use index ? Pros and cons ?
6. What is primary key , foreign key , unique key , candidate key ? Differences ?
7. What is normalization ? Types ? How to achieve ? What is denormalization ?
8. What is view ? Why use it ?
9. What are types of query (correlated , subquery) ?
10. What are constraints , different type of constraint , when to use which ?
  1. What are web services ? Why use them ?
  2. What is service oriented architecture ? Benefits ?
  3. What is REST ? Characteristics ? Why use it ? What are the http methods supported by REST ? What is a resource ?
  4. Difference between rest and soap ? When to use which ?
  5. Difference between get and post ?    Difference between put and post ?
  6. What happens if RestFull resources are accessed by multiple clients ? Do you need to make it thread-safe?
  7. How to use web services with spring ?
  8. What is URI ? URI vs URL ?
  9. What is statelessness ? Pros and cons ?
  10. What are the components of REST request and response ?
Servlet , JSP
1. What is a servlet ? What are it's advantages ?
2. What is the difference between web server and application server ?
3. How many instances of a servlet are created? Are servlet thread safe?
4. What is the difference between servletcontext and servletconfig object ?
5. How can we create deadlock in servlet ?
6. How to do session management ?
7. What is the life cycle of a servlet ?
8. What is the difference between URL encoding and URL rewriting ?
9. How does cookies work ?
10. What is the difference between get and post ?

OS:
1. What is the difference between a process and a thread ?
2. What is a semaphore , mutex , lock ? Differences ?
3.  What is virtual memory ?
4. What is paging ? What is segmentation fault ?
5. What is banker's algorithm ?
6. When does thrasing occurs ?
7. What is deadlock ? What are the conditions for it ? How to prevent it ?
8. What are the types of scheduler ?
9. What is belady's anomaly ?
10. What is dining philosopher problem and solution ?

HTML , Javascript , CSS , Web
  1. What is HTML5 ?
  2. What is jquery ? Why use it ?
  3. What is the difference bewtween '==' and '===' ?
  4. What is CSS ? Advantages ?
  5. What is css box model ?
  6. What is ajax ? Why and how to use it?
  7. What is closure ? Give example
  8. Can you access cookie using javascript ?
  9. How to redirect url using javascript ?
  10. What is the use of void(0) ?

*******************************************************
ANSWERS
*******************************************************
DS , Algo ,Coding , Bit Magic
1. Write code to find loop in linkedlist , reverse a linkedlist , is Palindrome
2. Find LCA in a binary tree.
3. Do DFS ,BFS,inorder , preorder ,postorder ,zigzag in tree. (recursive +iterative)
4. A question on sorting among bubble , quick , merge
5. How to find middle element or kth element from end in a linked list ?
6. In an integer array, there is 1 to 100 number, out of one is duplicate, how to find ?
7. Write code to reverse a string without using any API.
8. Write a program to find diameter , height of tree.
9. How will you implement a dictionary ?
10. Implement LRU.
11. Djikstra , prim
12. Find number of set bits.
13. Check number is power of 2.
14. How to search in rotated array ?
15. Search in a sorted 2d matrix.
16. Print 2d matrix in spiral
17. Find kth largest element in array
18. Implement stack using queue , queue using stack , two stack using an array.
19. Check string/integer is palindrome.
20. A DP problem , such as find maximum subarray , longest palindrome substring , best time to buy sell stock

Spring
1. What is spring ? Why use spring ?
Spring is an IoC (Inversion of Control) framework and container. It uses DI(Dependency Injection) to instantiate objects. It provides option to integrate with a lots of other frameworks such as struts , hibernate , etc.
Spring provides many benefits :
a) It provides IoC container which leads to loose coupled code. Loosely coupled code has many benefits , it's easy to modify , easy to test.
b) It is very less intrusive and most of the functionalites can be achieved by just using POJOs.
c) Most of the functionalites are now can be achieved by using annotation which makes development very easy.
d) It provides easy integration to lot of other frameworks such as hibernate ,  redis , struts , etc.
e) It provides MVC support.
f) It provides better exception handling.
f) It provides templates which reduces a lot of boilerplate code.
2. What is IoC ? What is DI ? Types of DI ? When to use which ?
IoC stands for Inversion of Control. It refers to the change in flow of program from code to some external entity such as xml. In this situation objects are instatiated by an external entity and then injected into the code thus creating loosely coupled code.
DI stands for Dependency Injection. It's a way to achieve inversion of control. In this , objects are injected by some external entity such as xml. There are two types of DI:
a)
3. What are the modules in spring ?
4. What is AOP ? Why use it ?
5. What is spring MVC ?
6. What is lifecycle of bean ?
7. What is beanfactory and application context ? Differences ?
8. What are scopes of bean in spring ? Differences ?
9. Which design patters are used in spring ?
10. What are the new features in spring 4 ?
Hibernate
1. What is hibernate ? Why use it ?
2. How to set up hibernate ?
3. Difference between get and load in hibernate ?
4. What is session , sessionFactory ? Are they threadsafe ?
5. What is the difference between transient , persistent and detached objects ?
6. Explain hibernate cache.
7. Why it's important to provide no argument constructor ?
8. What is mapping , one to one , etc and how to do it ?
9. How inheritance is handled ?
10.
Design Patterns
1. Which design patterns have you used ?
2. What is the difference between factory , abstract factory and builder ?
3. Write code for singleton , observer ?
4. Difference between strategy and state ?
5. What are the best coding practices in Java ?
6. Design ATM , parking lot , wallet , ecommerce.
7. Question on one of the following , singleton , factory , abstract factory , builder , prototype , observer , facade , decorator. Give real life example of these.
8. Code to solve producer consumer problem.
9. What is MVC and n tier ? Why use it ? Difference
10.
SQL
1. What is difference between delete and truncate ?
2. What are different types of join ?
3. A question on join , especially self join such as , How to find all employees who are also manager ?
4. How to find second highest salary ?
5. What are indexes ? Types ? Difference ? Why use index ? Pros and cons ?
6. What is primary key , foreign key , unique key , candidate key ? Differences ?
7. What is normalization ? Types ? How to achieve ? What is denormalization ?
8. What is view ? Why use it ?
9. What are types of query (correlated , subquery) ?
10. What are constraints , different type of constraint , when to use which ?
Web Services
1. What is service oriented architecture ? Benefits ?
2. What is REST ? Why use it ?
3. Difference between rest and soap ? When to use which ?
4. Difference between get and post ?
Servlet , JSP
1.
OS:
What is the difference between a process and a thread ?
What is a semaphore , mutex , lock ? Differences ?
HTML , Javascript , CSS , Web





***************************************Top 10 ends **********************




Saturday, 13 February 2016

DSA All

DS , Algo ,Bit Magic (Solve each problem in every possible way)
Write code to find loop in linkedlist.
Write code to reverse a linkedlist.
Write code to reverse a string without using any API.
Implement Djikstra.
Write code for  DFS,BFS,inorder,preorder,postorder,zigzag in tree.
Implement quick sort.
Implement merge sort.
Implement autosuggest feature from a list of words.
Implement LRU.
Check if a tree is BST?
Print numbers in order using two threads.
Write code to find diameter, height of tree(or binary tree?).
Write code to check if a number is power of 2.
Write code to search a number in rotated array.
Write code to check if a number is prime.
Find LCA(Lowest Common Ancestor) in a binary tree.
12. Write code to find number of set bits in an integer.
5. Write code to find kth element from end in a linked list ?
6. Write code to find the missing number in an integer array having 1 to 100 in random order except a number.
10. Write code to check if linkedlist is palindrome.
12. Implement Prim.
15. Write code to search a number in a sorted 2d matrix.
16. Write code to print 2d matrix in spiral order.
17. Write code to find kth largest element in an array.
18. Implement stack using queue.
19. Implement queue using stack.
20. Implement two stack using an array.
21. Implement three stacks using an array.
19. Write code to check integer is palindrome.
19. Write code to check string is palindrome.
20. Write code to find maximum continous subarray in an array.
21. Write code to find longest palindrome substring in a string.
22. Write code to find best time to buy sell stock.
22. Write code to swap two numbers.
23. Write code to find sum of digits
24. Write code to reverse an integer.
24. Write code to print first n numbers infibonacci series.
25. Write code to print nth fibonacci number.
25. Write code to add two numbers represented by a linked list.
26. Write code for bubble sort.
27. Implement radix sort.
28. Implement counting sort.
29. Implement insertion sort.
30. Implement selection sort.
31. Implement heap sort.
32. Implement bucket sort.
33. Write code to find first repeated character in a string.
34. Write code to find first unique character in a string.
How to find middle element of linkedlist in one pass?
Write code to remove duplicates from an array.
Implement BST.
Implement doubly linked list.
Implement doubly linked list using single pointer.
Write code to convert decimal to binary.
Write code to sort a map by value.
Write code to find common elements in two arrays.
Find longest substring without repeating characters.
Determine whether a point lies inside a triangle.
Nuts and bolts problem.
What is the probability that knight stays inside the chess board?
Implement stack using likedlist.
Implement queue using linkedlist.
Check for balanced paranthesis in an expression.
Sort an array containing only 0 and 1.
Sort a linkedlist containing 0,1,2.
Minimum number of platforms required at railway station.
convert word to another , one time one character , from a list of words.
Break string into dictionary words.
Find seed of a number. A number X is seed of Y if multiplying X by it's digits equates to Y.
Finds pairs of numbers with difference k  from an unsorted array.
Find number of trailing zeros in a number factorial.
Given an array containing 0 and 1 , find the largest subarray cotaining equal number of 0 and 1.
Sort an array of elements by decreasing order of frequency.
Given an array of words , group all anagrams in set
Find the min element in a sorted rotated array.
Delete all leaves from a binary tree.
Find two elements in an array whose sum is closest to zero.
Given two rectangles if they overlap or not (Imp)Find max sub square submatrix in a 2d matrix of 0 and 1 with all 1.
Minimum coin problem
Rotate an array by k
Find the level of a given node in a binary tree
Implement heap sort
Implement priority queue.
Find difference in the sum of nodes at odd level and nodes at even level of  a binary tree.
Check for children sum property of a binary tree.
Inorder predecessor in a binary tree
Inorder successor in a binary tree.
Rotate linked list by k nodes
Sort an array of 0,1,2.
Find pair of elements in an array whose sum is equal to given number.
Check whether two strings are anagram.
Given a  linked list , each node has two pointers , one point to next , another to some random node , How to copy it  ?
Get intersection point of two linked lists. (imp)
count nodes in a tree
determine if two binary trees are identical?
Implement binary search algorithm(imp)
sort an almost sorted array with two elements swapped
merge two sorted array without using extra space , assuming first array has enough space
Find minimum distance between two elements in an array
Print all the leaders in an array.
Given a 2d matrix m of 0 and 1 , if m[i][j] is 1 , fill row i and col j with 1
Replac each element of an array with next greatest element.
Find row with max 1 in sorted matrix
Find the number occuring odd number of times in an array , rest occur even number of times.
Given k sorted arrays of size n , merge them.
Find all pythogorean triplets in an array.
Convert sorted array to balanced BST.
Find LIS contigous.
Find LIS non contigous.
Find sub array whose sum equals given number.
Find max diff. between two elements in an array such that larger appears after smaller.
Find majority(occurs more than half) element in an array in O(n).
Even numbers at even pos , odd at odd in an array
Find union and intersection of two arrays.
Find smallest positive number missing from an array.
Shift zeros to end of array
Reverse linkedlist in group of k
Remove spaces from a sentence.
Reverse each word of a sentence
multiply two numbers using min. number of additions
detect cycle in graph
print bottom view of binary tree
print top view of binary treeadd two integers without using +
randomized quick sort
In a 2d matrix , a sub square matrix is painted , find minimal/optimal cost of painting the rest using a fixed block. which block to use ?
Floyd WarshallA 2d matrix containing 0,1,2 , 0 -> empty orange , 1-> fresh orange , 2-> rotten orange , how much time so that all are rotten , a rotten orane will rot adjacent (not diagonal) in one time frame.
Given a binary tree, n and k , find sum of all nodes which are k nodes away from node n.
mirror a binary tree
check if two binary trees are mirror
Convert BST to DLL.
check binary tree is bst
convert sentence like 'these are twelve pens and two shirts. convert it to 'these are 12 pens and 2 shirts'. Inline
Given linkedlist of moves of 2 players on tic tac toe , find who won
Given pile of 9 objects , Pick 1,2,or 3. 2 Players , last one to pick is looser. Give winning strategy.
Given stream of integers , give me median at any time.
Construct BST from pre and inorder
Rod cutting problem
Deletion in bst
Implement using BST
How many bits need to change to convert one num to other?
Check MSB is 0/1 ?
T9 dictionary implement

*****************************ANSWERS******************************

1. Write code to find loop in linkedlist

package dsa;


public class LoopInLinkedList {
 
 class Node{
  int data;
  Node next;
  
  Node(int data){
   this.data=data;
  }
 }
 
 Node head;
 Node tail;
 
 void add(int i){
  Node temp = new Node(i);
  if(head==null){
   head = temp;
  }else{
   temp.next=head;
   head=temp;
  }
 }
 void createLoop(){
  Node temp = new Node(1);
  head=temp;
  tail=temp;
  temp = new Node(2);
  Node node2=temp;
  tail.next=temp;
  tail=temp;
  temp = new Node(3);
  tail.next=temp;
  tail=temp;
  temp = new Node(4);
  tail.next=temp;
  tail=temp;
  temp = new Node(5);
  tail.next=node2;
  tail=temp;
  
 }

 void findLoop(){
  Node slow = head;
  Node fast = head.next;
  
  while(true){
   slow = slow.next;
   fast = fast.next.next;
   if(slow==fast){
    System.out.println("Loop found");
    break;
   }
  }
 }
 
 public static void main(String[] args) {
  LoopInLinkedList l = new LoopInLinkedList();
  l.createLoop();
  l.findLoop();
 }

}


2. Write code to reverse a linkedlist

3. Write code to reverse a string without using any API.
package strings;


public class ReverseString {
 
 static String reverse1(String str){
  StringBuilder sb = new StringBuilder(str);
  return sb.reverse().toString();
 }
 
 static String reverse2(String str){
  char[] arr = str.toCharArray();
  char temp='a';
  for(int i=0;i<=arr.length/2;i++){
   temp = arr[i];
   arr[i]=arr[arr.length-1-i];
   arr[arr.length-1-i]=temp;
  }
  return new String(arr);
 }
 
 public static void main(String[] args) {
  System.out.println(reverse1("Hello how are you?"));
  System.out.println(reverse2("Hello how are you?"));
 }

}

4. Implement Djikstra.
5. Write code for  DFS,BFS,inorder,preorder,postorder,zigzag in tree.
6. Implement quick sort.
7. Implement merge sort.
8. Implement autosuggest feature from a list of words.
9. Implement LRU.
10. Write code to find diameter, height of tree(or binary tree?).