Algorithm Run Time Analysis

Algorithm Run Time Analysis:


ARTA is nothing but how much time the algorithm takes to run or to execute.

Based on the run time of the algorithm the efficiency of the algorithm is determined , this will be the deciding factor whether your algorithm is good or bad.

Based on ARTA , a algorithm can be improved to get better efficiency compared to your previous algorithm.


Practical Use Of Recursion Methodology

Where we use Recursion in Practical ?

Recursion is  heavily used in various areas.


  • We use in Stack example : Fibonacci Series
  • We use in Trees .  For Traversal , Insertion , Deletion , Searching.
  • We use in Quick Sort and Merge Sort.
  • Divide and Conquer -> Where bigger problem is divided into smaller chunks . Smaller chunks will be similar mostly.
  • In Dynamic Programming we use recursion where we divide bigger problem and solve smaller chunks and use to solve the bigger problem. 


   

AWS BASICS

Cloud Concepts :

Cloud Services :

In general these are called as Hosted Services and broken into three categories :

1. IaaS - Infrastructure as a Service.
2. PaaS - Platform as a Service.
3. SaaS - Software as a Service.

Difference between these three services lies in level of abstraction and Virtualization provided.

There are many components which comes into picture when we are talking about.  They are

 Low Level Components         (Low Level Components)

             Servers ,  Load Balancers  , File Storage , Networking.

Components relies on Low level components (Mid Level Components)

             Runtime (Language used to code)
             OS   (Os that runs on Load balancers and servers.)

On top of all : (High Level Components)

Application Data
Data

In order to do rapid administration and rapid application development .

Cloud came into picture.


IaaS provides services for Low Level Components.

PaaS provides services for Low Level and Mid Level Components.

SaaS provides services for Low , Mid and High Level Components.


How To Install Scala On MACOS


How to Install Scala on macOS
Step 1: Check for installation of Java Development Kit (JDK)
From a Terminal window, type:
$java –version

If it is already installed, skip to step 4.

Otherwise, download and install the JDK from http://www.oracle.com/technetwork/java/javase/
downloads/index-jsp-138363.html.

Step 2: Set environment variables for Java
export JAVA_HOME=/usr/local/java-current
export PATH=$PATH:$JAVA_HOME/bin/


Step 3: Verify install
Close and re-open the Terminal window, and type:
$java –version

Sample results
java version "11.0.3" 2019-04-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.3+12-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.3+12-LTS, mixed mode)


Step 4: Install Scala and SBT

To install, you must have an installation manager such as Homebrew (available at homebrew.sh).

From a Terminal window, type:
$ brew install scala
$ brew install sbt


Step 5: Add Scala to environment variables
To set up your environment variables on a Mac, you need to add these commands to your .bash_
profile file, which is located in your home directory. (Note: make sure that you don’t have hidden
files selected.)


export SCALA_HOME=/usr/local/share/scala
export PATH=$PATH:$SCALA_HOME/bin


Close and re-open the Terminal window, and type the following to verify the install: scala -version

Spring Microservices

Microservices became a popular choice for implementing applications which need to be highly scalable , reliable and deployable.


Many high scale systems started moving towards Microservices architecture.

Ex : Amazon , Netflix , Uber , LinkedIn, Twitter etc...


Spring Framework provides required components and environment for developing microservices in a simple and easy way.

We will learn creating , packaging and deploying microservices using spring boot and spring cloud.

LRU Cache LeetCode Solution

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put.
get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.
put(key, value) - Set or insert the value if the key is not already present. When the cache reached its capacity, it should invalidate the least recently used item before inserting a new item.
The cache is initialized with a positive capacity.
Follow up:
Could you do both operations in O(1) time complexity?
Example:
LRUCache cache = new LRUCache( 2 /* capacity */ );

cache.put(1, 1);
cache.put(2, 2);
cache.get(1);       // returns 1
cache.put(3, 3);    // evicts key 2
cache.get(2);       // returns -1 (not found)
cache.put(4, 4);    // evicts key 1
cache.get(1);       // returns -1 (not found)
cache.get(3);       // returns 3
cache.get(4);       // returns 
Solution : 
class LRUCache extends LinkedHashMap<Integer,Integer>{
private int capacity;
    public LRUCache(int capacity) {
        super(capacity,0.75F,true);
        this.capacity = capacity;
    }
    
    public int get(int key) {
        return super.getOrDefault(key,-1);
    }
    
    public void put(int key, int value) {
        super.put(key,value);
    }
    
    @Override
    protected boolean removeEldestEntry(Map.Entry<Integer,Integer> eldest){
        return size() > capacity;
    }
}

/**
 * Your LRUCache object will be instantiated and called as such:
 * LRUCache obj = new LRUCache(capacity);
 * int param_1 = obj.get(key);
 * obj.put(key,value);
 */

Amazon List of LeetCode Questions

1. Two Sum

Two Sum Solution

2. LRU Cache

LRU Cache Solution

3. Number Of Islands

4.Longest Palindromic Substring

5. Lowest Common Ancestor of a Binary Tree

6. Add Two Numbers

7.Word Ladder

8. Reverse Linked List

9. Serialize and Deserialize Binary Tree

10. Valid Parentheses

11. Letter Combinations Of a Phone Number

12. Copy List With Random Pointer

13. Longest Substring With Out Repeating Characters

14. Trapping Rain Water

15. Min Stack

16. Lowest Common Ancestor Of a Binary Search Tree

17. Rotate Image

18. Best Time To Buy And Sell Stock

19. Validate Binary Search Tree

20. Word Break

21. Linked List Cycle

22. Group Anagrams

23. 3Sum

24. Product Of Array Except Self

25. Valid Anagram

26. Sliding Window Maximum

27. Search A 2D Matrix

28. Merge Two Sorted Lists

29. Merge K Sorted Lists

30. Word Ladder II

31. Kth Largest Element In An Array

32. Palindrome Linked List

33. Intersection Of Two Linked Lists

34. Subsets

35. String To Integer

36. First Unique Character In a String

37. Binary Tree Level Order Traversal

38. Count Primes

39. Gray Code

40. Two Sum Input Array Is Sorted

41. Insert Delete Get In Random O(1)

42. Binary Tree Right Side View

43. Design Twitter

44. Reverse Words In A String II

45. Rotate Function

















Featured Post

H1B Visa Stamping at US Consulate

  H1B Visa Stamping at US Consulate If you are outside of the US, you need to apply for US Visa at a US Consulate or a US Embassy and get H1...