top of page
Search
Android Drag View example with source code
Create Class such as 1)DragActivity.java import android.app.Activity; import android.os.Bundle; import android.util.Log; import...

Abhinaw Tripathi
May 26, 201620 min read
14 views
0 comments
Structural Design Pattern
What is Structural Design Pattern? Ans: Structural DP,s are used for structuring code and objects.It also can be described as how objects...

Abhinaw Tripathi
May 26, 20161 min read
4 views
0 comments
Write code to partition a linked list around a value x, such that all nodes less than x come before
Approach: We iterate through the linked list ,inserting elements into our before list or our after list.Once we reach the end of the...

Abhinaw Tripathi
May 26, 20161 min read
28 views
0 comments
Delete a node in the middle of a singly linked list,given only access to that node.
Very simple problem but there is only issue with the solution is if the node to be deleted is the last node in the linked list. public...

Abhinaw Tripathi
May 26, 20161 min read
1 view
0 comments
Write an algorithm to find the k'th to last element of a singly linked list.
We can approach this problem in two ways one using recursive way and other using non recursive way.if you will use recursive way then its...

Abhinaw Tripathi
May 26, 20161 min read
3 views
0 comments
Linked List Programming Question and its Best Solution by Abhinaw
Question: Write code to remove duplicates from an unsorted linked list.if temporary buffer is not allowed. Solution: In order to solve...

Abhinaw Tripathi
May 26, 20161 min read
5 views
0 comments
Tutorial on Prototype Design Pattern
As the name suggests Prototype means making a clone. and Cloning is the operation of replicating an object.The cloned object the copy is...

Abhinaw Tripathi
May 26, 20162 min read
3 views
0 comments
Tutorial on Singleton Design Pattern
This design pattern is used when only one instance of an object is needed throughout the lifetime of an application.The singleton class...
Abhinav Tripathi
May 25, 20162 min read
3 views
0 comments
Amazon Interview Question: Assume you have a method isSubstring which checks if one word is a substr
Let say you have two string s1 and s2 ,write code to check if s2 is a rotation of s1 using only one call to isSubstring(eg. "WaterBottle"...

Abhinaw Tripathi
May 25, 20161 min read
104 views
0 comments
Very Common Problem on Matrix,if an element in an MXN matrix is 0,its entire row and column are set
Solution: public void setZero(int[][] matrix) { boolean[] row= new boolean[matrix.length]; boolean[] row= new...

Abhinaw Tripathi
May 25, 20161 min read
4 views
0 comments


Write a method to rotate the image by 90 degree.(In place operation is required).
Let say you have an image represented by an NXN matrix where each pixel in the image is 4 byte.So rotate this image in place by 90...

Abhinaw Tripathi
May 25, 20161 min read
3 views
0 comments
Write a method to perform basic string compression eg. aabcccccaaa.Should become the ouput a2b1c5a3.
Bad Solution: public String compressBad(String str) { String mystr= ""; char last=str.charAt(0); int count = 1; for(int i=1; i<...

Abhinaw Tripathi
May 25, 20161 min read
13 views
0 comments
Write a method to replace all spaces with %20 in a String.(Note-Perform in place operation only.)
public void replaceSpaces(Char[] str, int length) { int spaceCount=0; int newLength,i; for(i=0;i<lenght;i++) { if(str[i] == ' ') {...

Abhinaw Tripathi
May 25, 20161 min read
6 views
0 comments
How will you check,given two strings are permutation of the other.
Example: "god" permutation will be "dog" Solution: public String sort(String s) { char[] content = s.toCharArray();...

Abhinaw Tripathi
May 25, 20161 min read
2 views
0 comments
Programming Questions on String and its Best Solution with its complexity
Question: Write an algorithm to find if a string has all unique characters.what if you cannot use additional data-structure?. Solution: i...

Abhinaw Tripathi
May 25, 20161 min read
5 views
0 comments
Builder Design Pattern
As the name suggest it self that builds complex objects from simple one step by step and the object creation process should be generic So...
Abhinav Tripathi
May 24, 20161 min read
5 views
0 comments
Abstract Factory Design Pattern
Abstract Factory is a factory object that returns one of several factories.Modularization is a big issue in today's...
Abhinav
May 24, 20161 min read
1 view
0 comments
Creational Design Patterns
This design pattern is all about the class instantiation.These design patterns tries to create objects in a manner suitable to the...
Abhinav Tripathi
May 24, 20161 min read
7 views
0 comments
Lets talk about Software Design-Patterns
What are Design Patterns? Design Pattern is a used and tested solution for a know problem.In simple words you can say a general reusable...
Abhinav Tripathi
May 24, 20162 min read
1 view
0 comments
Which Design Pattern should be used instead of using Traditional Constructor and why?
Replace Constructor with Factory Method Pattern.Why lets take a case Suppose you have class like class Employee { Employee(int type) {...
Abhinav Tripathi
May 23, 20161 min read
2 views
0 comments
bottom of page