Posts

Showing posts from November, 2017

DEPLOY YOUR STATIC WEBSITE ON HEROKU

Image
HOW TO DEPLOY YOUR STATIC WEBSITE ON HEROKU Before starting this tutorial I may first tell you what is “Heroku”? Heroku is a cloud platform service where we can easily upload our apps which support multiple programming languages. In the beginning heroku only supported Ruby language but after that it has given support for different languages like Php, Python, Node.js, Clojure, Scala and Go. Heroku uses git repositories to deploy apps on web. After deploying your app on heroku you will get a link which would be your application domain that would be like this: applicationname.herokuapp.com” In this tutorial I will teach you how to deploy your simple static Html, Css and JavaScript website or any other simple JavaScript application. What are Git and GitHub? To get started we must first know what Git is. Git is an open source version control system. Git is distributed revision control system which is very fast and lightweight tool. Git was developed by Linux kernel developers i…

Software Engineer Interview Questions Part-1

/*
1. Given an array which is in ascending order till some point and then descending order till end. find peak element

*/

Solution 1 :
#include <bits/stdc++.h>
using namespace std;

int peak_value(vector<int>a, int start, int end){
    if (start==end)  return a[start];
    if(start>end) return 0;
    int mid=(start+end)/2;
    if(a[mid]<a[mid+1]){
       return peak_value(a,mid+1, end);
    }else if(a[mid]>a[mid+1]){
        if((mid-1)>=0){
            if(a[mid-1]>a[mid]){
                return peak_value(a, start, mid-1);
            }else{
                return a[mid];
            }
        }else{
            return a[mid];
        }
    }
}

int find_the_peak_value(vector<int> a){
    if(a.size()==0){
        return 0;
    }else{
        cout<<"calling first peak_value function"<<endl;
        return (peak_value(a, 0, a.size()-1) );
    }
}

int main(){
    static const int arr[] = {1,2,3,4,5,3,1};
    vector<int> vec (arr, arr + sizeof(arr) / sizeof(arr[…

Combinatorics Part-1

Image
Introduction
Counting the objects that satisfy some criteria is a very common task in both TopCoder problems and in real-life situations. The myriad ways of counting the number of elements in a set is one of the main tasks in combinatorics, and I’ll try to describe some basic aspects of it in this tutorial. These methods are used in a range of applications, from discrete math and probability theory to statistics, physics, biology, and more.
Combinatorial primitives
Let’s begin with a quick overview of the basic rules and objects that we will reference later.
The rule of sum
The rule of product
For example, if we have three towns — A, B and C — and there are 3 roads from A to B and 5 roads from B to C, then we can get from A to C through B in 3*5=15 different ways.
These rules can be used for a finite collections of sets.
Permutation without repetition When we choose k objects from n-element set in such a way that the order matters and each object can be chosen only once:
For exa…