Use the following commands to list the open ports.
sudo netstat -ltn
Continue reading
Use the following commands to list the open ports.
sudo netstat -ltn
Continue reading
Problem
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Continue reading
Unix shells include Almquist shell (ash),Bourne shell (B shell, sh), C shell (csh), Bourne Again Shell (bash), Debian Almquist shell (dash), Korn shell (ksh), Public domain Korn shell (pdksh), MirBSD Korn shell (mksh), Z shell (zsh) etc. There are several ways to find out what shell we are using. Continue reading
Problem
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Continue reading
Singleton pattern is a creational design pattern. It ensures a class has only one instance created, and provides a global point of access to it. The implementation includes just-in-time initialization and initialization on first use.
Continue reading
Decorator pattern a design pattern that allows behavior to be added to an individual object without affecting the behavior of other objects from the same class. Decorators provide a flexible alternative to subclass for extending functionality. Continue reading
Software design patterns are reusable solutions to commonly occurring problems within given contexts in software design, and represent the best practices used by experienced developers. Design patterns can speed up the development process by providing tested, proven development paradigms. Continue reading
Since Java 7, the java.nio.file package adds a feature: file change notification with Watch Service API – java.nio.file.WatchService
. Watch Service API allows us to register directories with the watch service, and monitor the directories and files for any changes including creation, deletion, modification etc. The post will briefly introduce the usage of Watch Service API. Continue reading
The Observer pattern is a software design pattern in which an object (subject / Observable), maintains a list of Observers, and notifies them automatically of any state changes [wiki]. The Observer pattern falls under behavioral pattern category. Continue reading
Problem
Determine whether an integer is a palindrome. Do this without extra space.
Some hints:
1. Could negative integers be palindromes? (ie, -1)
2. If you are thinking of converting the integer to string, note the restriction of using extra space.
3. You could also try reversing an integer. However, if you have solved the problem “Reverse Integer”, you know that the reversed integer might overflow. How would you handle such case?
Continue reading