Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class NumbersWithSumK {
- public void findPair(int [] arr, int sum){
- Hashtable hashtable = new Hashtable();
- for( int i = 0; i< arr.length -1; i++){
- hashtable.put(i, arr[i]);
- }
- for(int i = 0; i <= arr.length - 1; i++){
- int element = sum - arr[i];
- if ( element.hashCode() == i) {
- System.out.println(" pair " + i + " , " );
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement