Skip to content

Instantly share code, notes, and snippets.

$(document).ready(function() {
$('.tour').on('click','button',function() {
var tour = $(this).closest('.tour');
var discount = tour.data('discount');
var message = $('<span>Call 1-555-jquery-air for a $' + discount + ' discount.</span>');
tour.append(message);
$(this).remove();
});
});
$('button').on('click', function() {
var tour = $(this).closest('.tour');
var discount = tour.data('discount');
var message = $('<span>Call 1-555-jquery-air for a $' + discount + ' discount.</span>');
tour.append(message);
$(this).remove();
});
});
$(document).ready(function() {
$('button').on('click', function() {
var message = $('<span>Call 1-555-jquery-air to book this tour</span>');
$('.usa').append(message);
$('button').remove();
});
});
package com.tvidushi.string.skipletter;
public class PermuteString {
private static void permute(String prefix, String s){
System.out.print("["+s+"] ,");
int n=s.length();
if (n==0){
//System.out.println("-------------------------------"+prefix);
package linkList;
import java.util.*;
/*
* we are using linked list with hashmap for Lru.
* Reason behind this is ,since HashMap is able to store data and key but
* how do we get info about least recently used cache value?. For this we need to keep track all inserted data into map
* by using linked list. When inserting new values , add this value to the top of linked list. When key,value is already
/**
* Duplicates are not allowed in arr.
*/
public int search(int arr[],int search){
int low =0;
int high = arr.length-1;
while(low <= high){
int mid = (low + high)/2;
if(arr[mid] == search){
return mid;
import java.util.Arrays;
/**
* http://www.geeksforgeeks.org/count-pairs-difference-equal-k/
*
* Count all distinct pairs with difference equal to k
2.6
Given an integer array and a positive integer k, count all distinct pairs with difference equal to k.
Examples:
package com.interview.binarysearch;
/**
* missing no in arithmetic progression
* http://www.careercup.com/question?id=4798365246160896
*/
public class ArithmeticProgressionSearch {
public int search(int input[]){
int low =0;
package com.tvidushi.arrays;
import java.util.stream.Stream;
/**
* An Array element is considered peaj ,if it is not
* smaller than its neigbours
*/
public class PeakElement {
public class FirstOccurrenceOfNumberInSortedArray {
public int firstOccurrence(int input[], int x){
int low = 0;
int high = input.length-1;
while(low <= high){
int middle = (low + high)/2;
if(input[middle] == x && (middle == 0 || input[middle-1] < x)){
// if(input[middle] == x){