Skip to main content

Posts

Showing posts from March, 2015

What is the difference between Node.js and AJAX?

Node.js - Node.js is an Asynchronous single threaded server. - Node.js runs on V8  environment. - Can not access DOM objects in Node.js. AJAX stands for A synchronous J avascript A nd X ML. - It is a client side technology usually used for updating part of the page on the client side dynamically i.e. without reloading the whole page hence, these type of pages are also called as dynamic pages. - Also, it saves sending lot of data from client to server and vice-versa.

Pangram : Problem on hackerrank

This is a problem mentioned on Hackerrank. Below is my attempt to solve this problem. Problem Statement Roy wanted to increase his typing speed for programming contests. So, his friend advised him to type the sentence "The quick brown fox jumps over the lazy dog" repeatedly because it is a pangram. ( pangrams are sentences constructed by using every letter of the alphabet at least once. ) After typing the sentence several times, Roy became bored with it. So he started to look for other pangrams. Given a sentence s , tell Roy if it is a pangram or not. import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution {     public static void main(String[] args) {         Scanner in = new Scanner(System.in);         char[] str = in.nextLine().toCharArray();         boolean[] resultArr = new boolean[26]; int smallMax = 'z'; int capMax = 'Z'; for (int i = 0; i < s

Insertion Sort

  Insertion sort is like picking a card from a set of unsorted cards and comparing it   to all the cards present on the left for higher or smaller values and inserting this   card into right position. After every pass, the picked value reaches at its right position.     for e.g.   input : 10,5,3,4,12,1,13   after First Pass :   -> 5,10,3,4,12,1,13   after Second Pass:   -> 3,5,10,4,12,1,13   after Third Pass:   -> 3,4,5,10,12,1,13   in fourth pass when the pointer is pointing to 12 there is not need to move it since   it is already greater than the immediate next element i.e. 10:   -> 3,4,5,10,12,1,13   after fifth Pass:   -> 1,3,4,5,10,12,13   in sixth pass also there is no need to move the elements   and you get your output     It's time complexity is O(n^2) but still it performance much faster than bubble sort and   slightly better than selection sort.     Below is the code for same. public class InsertionSort { public static vo