Aditya Chatterjee's Blog, page 205

June 4, 2020

Undoing Local Changes in Git when in the Working area or Staging area

Reading time: 40 minutes | Coding time: 10 minutes


Before going into our main objective "Undoing Local Changes in Git when in the Working area or Staging area", we will go through two basic concepts "Working area" and "Staging".


What is Working area?


It is the remote local space where you code on your machine. You have not added your code to git yet.


What is staging?


It means to prepare a file for a commit. You have added your file to git staging area, but not committed it yet.


Staging area l...

 •  0 comments  •  flag
Share on Twitter
Published on June 04, 2020 05:20

Explaining Blockchain intuitively to a Five year old!

Reading time: 30 minutes


What if your Interviewer asks you to explain Blockchain to her in simple English words ? What if you are developing something related to blockchain and your 5 year old cousin really comes up to you and asks you what is blockchain ?


curiouskid


If you know blockchain or you don't, these situations will surely make you think for some time, HOW DO I EXPLAIN BLOCKCHAIN TO YOU!! If you want to tackle this situation, this is probably the right article you are reading.


I would also like ...

 •  0 comments  •  flag
Share on Twitter
Published on June 04, 2020 04:31

June 3, 2020

.norm() method of Numpy library in Python

.norm() method of Numpy library in Python

.norm() method of Numpy library in Python


In Machine learning, vectors and matrixes are used extensively to represent features, targets and other parameters and hyperparameters. Calculating the length or magnitude of the vector used in a particular model is often required in several matrix operations or direct implementations in regularization methods. The length of a vector is a positive integer, that speaks on the extent of the vector in space.


In this article, you will know about vector norm and the method to apply them in Python b...

 •  0 comments  •  flag
Share on Twitter
Published on June 03, 2020 15:49

June 1, 2020

Maximum houses a Robber can rob

There are several houses in a society where the security system of two adjacent house is connected. Hence, if a robber robs two adjacent house, police is informed automatically and the robber does not want this to happen. The robber has the information of how much money is stored in each house. The robber needs to rob alternative houses to be safe.


The robber wants to know how many houses can be robbed without informing the police.


Given a list of non-negative integers representing the amount o...

 •  0 comments  •  flag
Share on Twitter
Published on June 01, 2020 05:17

May 31, 2020

Unary and Binary Operations in C++

Operators are the basic building blocks and constitute the essential part of any programming language. With the help of operators we are able to perform multiple operations. Here, in this article we are going to focus on arithmetic operations in C .


There are various arithmetic operators used for performing the arithmetic operations.


Arithmetic oprerations can be categorized into two types-



Unary arithmetic operations
Binary arithmetic operations

UNARY ARITHMETIC OPERATIONS

Operator that tak...

 •  0 comments  •  flag
Share on Twitter
Published on May 31, 2020 10:41

Implementing Binary search in C++

Binary search is a simple yet efficient searching algorithm which is used to search a particular element's position in a given sorted array/vector.

In this algorithm the targeted element is compared with middle element. If both elements are equal then position of middle element is returned and hence targeted element is found.


If both elements are unequal then if targeted element is less or more than middle element we discard the lower or upper half and the search continues by finding new middle...

 •  0 comments  •  flag
Share on Twitter
Published on May 31, 2020 10:35

Kadane's Algorithm for largest subarray sum

Kadane's Algorithm is commonly known for Finding the largest sum of a subarray in linear time O(N).


A Subarray of an n-element array is an array composed from a contiguous block of the original array's elements. For example, if array = [1,2,3] then the subarrays are [1], [2], [3], [1,2], [2,3] and [1,2,3] . Something like [1,3] would not be a subarray as it's not a contiguous subsection of the original array.


Difference between Subarray, Substring, Subset and Subsequence
1. SUBARRAY

A subar...

 •  0 comments  •  flag
Share on Twitter
Published on May 31, 2020 10:27

Reducing Time limit of code in Java

Hey Folks! Being in the world of competitive programming, every one of us often face TLE (Time Limit Exceeded) Errors. Reducing TL of one's code is one of the most crucial phase of learning for programmers.


One of the most popular platform for competetive programming is codechef.

By-default : Codechef has the TL (Time Limit) for any problem as 1 sec. Java Language has a multiplier of 2 and phython has multiplier of 5.


Java being a heavy language, does uses extra space and time for loading the f...

 •  0 comments  •  flag
Share on Twitter
Published on May 31, 2020 10:19

Binary GCD Algorithm

The Binary GCD algorithm or Stein's algorithm, is an algorithm that calculates two non-negative integer's largest common divisor by using simpler arithmetic operations than the standard euclidean algorithm and it reinstates division by numerical shifts, comparisons, and subtraction operations.




Examples: Input: x = 12,y = 72

Output : 12
Input: x = 33, y = 34

Output: 1


Algorithm

The Binary GCD Algorithm for calculating GCD of two numbers x and y can be given as follows:




If both x and y ...
 •  0 comments  •  flag
Share on Twitter
Published on May 31, 2020 07:05

String Class (java.lang.String) in Java

The java.lang.String class in Java provides a lot of methods to work on string. By the help of these methods, we can perform operations on string such as trimming, concatenating, converting, comparing, replacing strings etc.


String is a sequence of characters, for e.g. “Hello” is a string of 5 characters. In java, string is an immutable object which means it is constant and can cannot be changed once it has been created.


JAVA String Class

There are two ways to create a String object:




By strin...

 •  0 comments  •  flag
Share on Twitter
Published on May 31, 2020 06:26