Profile cover photo
Profile photo
Rajesh Dixit
Rajesh's posts

Post has attachment
Interface-segregation principle
What is the point in selling a horse saddle for one who does not own a horse? The interface-segregation principle (ISP) states that no client should be forced to depend on methods it does not use. ISP splits interfaces that are very large into smaller and m...

Post has attachment
Liskov’s Substitution Principle - A SOLID principle
Derived types must be completely substitutable for their base
types. Explanation: To utilize
the principles like inheritance, we create some class hierarchies (=extends
some classes creating some derived classes). LSP
states that if a program module is usin...

Post has attachment
Singleton vs Static class in Java
What is Static class in Java? What is singleton class? How are they different? Static class is a Java class , which only contains static methods. Ex: java.lang.Math Which contains lots of utility methods for various Maths function e.g. sqrt(). No instance o...

Post has attachment
Check two trees are identical or not
Problem : Given
two binary trees, write a function to check if they are equal or not. Solution : Two
binary trees are considered equal if they are structurally identical and the
nodes have the same value. Algorithm : isTreesIdenticalRec(Node root1, Node roo...

Post has attachment
Write a method to replace all spaces in a string with ‘%20’.
Algorithm : 1.
Count the number of spaces during the first scan of the string. 2. Scan
the string from start to end for each character: If
a space is encountered, store “%20”. Else,
store the character as it is in the newly shifted location. package crack.c...

Post has attachment
Remove Duplicate from String in Java
an algorithm and write code to remove the duplicate characters in a string without using any additional buffer . To
solve this problem, we can apply the same approach as we used to check the unique
character in the string . Using one Boolean array: p...

Post has attachment
Write a function to check whether two strings are anagram of each other.
Input: str1 – “geeksforgeeks”, str2 – “geeksforgeeks” Output
= Strings are Angram Input: str1 – “geeksforgeeksk”, str2 – “lgeeksforgeeks” Output
= Strings are not Angram Approach#1: Sort
both the strings and then compare the strings. Time Complexity: O(nlog...

Post has attachment
Algorithm to check that String has all unique character
Implement an algorithm to determine if a
string has all unique characters without using any additional data structures? package crack.coding.interview; public class NoCharRptInStr {      /**        * @param str        * @return        */      private static...

Post has attachment
Object oriented design for a Restaurant
we start to design Object Oriented architecture of restaurant. Before start the
design, we need to understand how restaurant works. Components required: Customer             Name             Contact selectDish():
Dish Selects
the dish from the menu and ...

Post has attachment
PiorityQueue in Java
PiorityQueue(=belongs to the Java Collections
Framework) is an unbounded Queue implementation, which is based on  priority heap and it is an implementation
of Queue interface. It can be used to keep elements in a particular order,
according to their natural...
Wait while more posts are being loaded