## June 27, 2020

## June 25, 2020

## June 24, 2020

### Trailer of Aditi Rao Hydari’s Sufiyum Sujatayum released..

Amazon Prime Video today unveiled the trailer for the much-anticipated Malayalam film, Sufiyum Sujatayum, which makes its global premiere exclusively on the service and is the fourth of the seven Indian films in five languages to do so. Directed by Naranipuzha Shanavas, Sufiyum Sujatayum is produced by Vijay Babu under his banner of Friday Film House. Come this July 3, Prime members in India and more than 200 countries and territories worldwide can watch the much-awaited movie in Malayalam.

## June 22, 2020

## June 19, 2020

## June 18, 2020

### How to implement Snakes and Ladders using Java?

Let's create a SnakeNLadder.java class. Define constant WINPOINT with value 100. Each player has to start the journey from 0, roll the dice and try to reach WINPOINT.

## June 14, 2020

## June 11, 2020

### Sapient Interview Questions

**:**

__First Round__**Live coding test**

1). Asked me to create an employee class with a couple of fields like employee id, date of joining, salary age.

## June 08, 2020

### #LeetCode : Power Of Two

Given an integer, write a function to determine if it is a power of two.

Example 1:

Input: 1 Output: true Explanation: 20 = 1

## June 07, 2020

### #LeetCode : Coin Change 2

**Y**ou are given coins of different denominations and a total amount of money. Write a function to compute the number of combinations that make up that amount. You may assume that you have infinite number of each kind of coin.

**Example 1**:

Input: amount = 5, coins = [1, 2, 5]

Output: 4

Explanation: there are four ways to make up the amount:

5=5

5=2+2+1

5=2+1+1+1

5=1+1+1+1+1

## June 06, 2020

### #LeetCode :Queue Reconstruction by Height

**S**uppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in front of this person who have a height greater than or equal to h. Write an algorithm to reconstruct the queue.

**Note**:

The number of people is less than 1,100.

**Example**

Input:[[7,0], [4,4], [7,1], [5,0], [6,1], [5,2]]

Output:[[5,0], [7,0], [5,2], [6,1], [4,4], [7,1]]

## June 05, 2020

## June 04, 2020

### #LeetCode : Reverse String

**W**rite a function that reverses a string. The input string is given as an array of characters char[].

Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.

You may assume all the characters consist of printable ascii characters.

## June 03, 2020

### #LeetCode : Two City Scheduling

**T**here are 2N people a company is planning to interview. The cost of flying the i-th person to city A is costs[i][0], and the cost of flying the i-th person to city B is costs[i][1].

Return the minimum cost to fly every person to a city such that exactly N people arrive in each city.

**Example 1**:

Input: [[10,20],[30,200],[400,50],[30,20]]

Output: 110

Explanation:

The first person goes to city A for a cost of 10.

The second person goes to city A for a cost of 30.

The third person goes to city B for a cost of 50.

The fourth person goes to city B for a cost of 20.

The total minimum cost is 10 + 30 + 50 + 20 = 110 to have half the people interviewing in each city.

## June 02, 2020

### Madhuri Dixit Celebrates 25 years of Raja

**2**nd June 1995 – This was the day when Raja released, and well, history was created!

Director Indra Kumar helmed the cult entertainer which released on 2nd June, which had the powerful combination of Direction by Indra Kumar, Acting duo of 90s queen Madhuri Dixit, Sanjay Kapoor and blockbuster songs!

Produced by Ashok Thakeria and Indra Kumar the film took a massive start all over the country and not only did it recover its money in the first week itself, but the hardcore commercial romantic musical entertainer went on to collect five times its first week numbers, emerging as a bonafide blockbuster!!

### #LeetCode Delete Node in a Linked List

**W**rite a function to delete a node (except the tail) in a singly linked list, given only access to that node.

**Example 1:**

Input: head = [4,5,1,9], node = 5

Output: [4,1,9]

Explanation: You are given the second node with value 5, the linked list should become 4 -> 1 -> 9 after calling your function.

## June 01, 2020

## May 31, 2020

### #LeetCode: Edit Distance

**G**iven two words word1 and word2, find the minimum number of operations required to convert word1 to word2.

You have the following 3 operations permitted on a word:

- Insert a character
- Delete a character
- Replace a character

## May 30, 2020

### #LeetCode: K Closest Points to Origin

**W**e have a list of points on the plane. Find the K closest points to the origin (0, 0).(Here, the distance between two points on a plane is the Euclidean distance.)

You may return the answer in any order. The answer is guaranteed to be unique (except for the order that it is in.)

## May 29, 2020

### #LeetCode: Course Schedule

There are a total of numCourses courses you have to take, labeled from 0 to numCourses-1.

Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1]

Given the total number of courses and a list of prerequisite pairs, is it possible for you to finish all courses?

Input: numCourses = 2, prerequisites = [[1,0]]

Output: true

Explanation: There are a total of 2 courses to take.

To take course 1 you should have finished course 0. So it is possible.

Input: numCourses = 2, prerequisites = [[1,0],[0,1]]

Output: false

Explanation: There are a total of 2 courses to take.

To take course 1 you should have finished course 0, and to take course 0 you should

also have finished course 1. So it is impossible.

The input prerequisites is a graph represented by a list of edges, not adjacency matrices. Read more about how a graph is represented.

You may assume that there are no duplicate edges in the input prerequisites.

1 <= numCourses <= 10^5

-K Himaanshu Shuklaa.

Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1]

Given the total number of courses and a list of prerequisite pairs, is it possible for you to finish all courses?

**Example 1**:Input: numCourses = 2, prerequisites = [[1,0]]

Output: true

Explanation: There are a total of 2 courses to take.

To take course 1 you should have finished course 0. So it is possible.

**Example 2**:Input: numCourses = 2, prerequisites = [[1,0],[0,1]]

Output: false

Explanation: There are a total of 2 courses to take.

To take course 1 you should have finished course 0, and to take course 0 you should

also have finished course 1. So it is impossible.

**Constraints**:The input prerequisites is a graph represented by a list of edges, not adjacency matrices. Read more about how a graph is represented.

You may assume that there are no duplicate edges in the input prerequisites.

1 <= numCourses <= 10^5

**GIT URL:**__Java Solution of Leet Code's Course Schedule problem__

__Java Solution 1__-K Himaanshu Shuklaa.

## May 28, 2020

### #LeetCode: Counting Bits

Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.

Input: 2

Output: [0,1,1]

Input: 5

Output: [0,1,1,2,1,2]

**Example 1**:Input: 2

Output: [0,1,1]

**Example 2**:Input: 5

Output: [0,1,1,2,1,2]

## May 27, 2020

### #LeetCode: Possible Bipartition

**G**iven a set of N people (numbered 1, 2, ..., N), we would like to split everyone into two groups of any size.

Each person may dislike some other people, and they should not go into the same group.

Formally, if dislikes[i] = [a, b], it means it is not allowed to put the people numbered a and b into the same group.

Return true if and only if it is possible to split everyone into two groups in this way.

## May 26, 2020

### #LeetCode: Contiguous Array

Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.

Explanation: [0, 1] is the longest contiguous subarray with equal number of 0 and 1.

Explanation: [0, 1] (or [1, 0]) is a longest contiguous subarray with equal number of 0 and 1.

**: Input: [0,1], Output: 2**__Example 1__Explanation: [0, 1] is the longest contiguous subarray with equal number of 0 and 1.

**: Input: [0,1,0], Output: 2**__Example 2__Explanation: [0, 1] (or [1, 0]) is a longest contiguous subarray with equal number of 0 and 1.

**: The length of the given binary array will not exceed 50,000.**__Note__## May 25, 2020

### #LeetCode: Uncrossed Lines

**W**e write the integers of A and B (in the order they are given) on two separate horizontal lines.

Now, we may draw connecting lines: a straight line connecting two numbers A[i] and B[j] such that:

A[i] == B[j];

The line we draw does not intersect any other connecting (non-horizontal) line.

Note that a connecting lines cannot intersect even at the endpoints: each number can only belong to one connecting line.

Return the maximum number of connecting lines we can draw in this way.

## May 24, 2020

### #LeetCode: Construct Binary Search Tree from Preorder Traversal

**R**eturn the root node of a binary search tree that matches the given preorder traversal.

(Recall that a binary search tree is a binary tree where for every node, any descendant of node.left has a value < node.val, and any descendant of node.right has a value > node.val. Also recall that a preorder traversal displays the value of the node first, then traverses node.left, then traverses node.right.)

## May 23, 2020

### #LeetCode: Interval List Intersections

**G**iven two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted order.

Return the intersection of these two interval lists.

(Formally, a closed interval [a, b] (with a <= b) denotes the set of real numbers x with a <= x <= b. The intersection of two closed intervals is a set of real numbers that is either empty, or can be represented as a closed interval. For example, the intersection of [1, 3] and [2, 4] is [2, 3].)

## May 22, 2020

### After Gulabo Sitabo & Shakuntala Devi, 'Indoo Ki Jawaani' to be released online?

**A**fter Amitabh Bachchan and Ayushmann Khurrana starrer 'Gulabo Sitabo' and Vidya Balan's much awaited 'Shakuntala Devi', Kiara Advani's next 'Indoo Ki Jawaani' might be released online.

As per the latest buzz,

*"'Indoo Ki Jawaani' is ready and the post-production work will be completed soon. It was suppose to release worldwide on June 5th, 2020, however, due to pandemic release has been postponed. Now, Nikkhil Advani and Monisha Advani, from Emmay Entertainment want to release it on the web. They are already in talks with several OTT platforms, however nothing is finalized as of now."*

### #LeetCode: Sort Characters By Frequency

**G**iven a string, sort it in decreasing order based on the frequency of characters.

**Example 1**:

Input: "tree"

Output: "eert"

Explanation:

'e' appears twice while 'r' and 't' both appear once.

So 'e' must appear before both 'r' and 't'. Therefore "eetr" is also a valid answer.

## May 21, 2020

### #LeetCode: Count Square Submatrices with All Ones

Given a m * n matrix of ones and zeros, return how many square submatrices have all ones.

Input: matrix =

[

[0,1,1,1],

[1,1,1,1],

[0,1,1,1]

]

Output: 15

Explanation:

There are 10 squares of side 1.

There are 4 squares of side 2.

There is 1 square of side 3.

Total number of squares = 10 + 4 + 1 = 15.

**Example 1**:Input: matrix =

[

[0,1,1,1],

[1,1,1,1],

[0,1,1,1]

]

Output: 15

Explanation:

There are 10 squares of side 1.

There are 4 squares of side 2.

There is 1 square of side 3.

Total number of squares = 10 + 4 + 1 = 15.

## May 20, 2020

### #LeetCode: Kth Smallest Element in a BST

Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.

You may assume k is always valid, 1 ≤ k ≤ BST's total elements.

Input: root = [3,1,4,null,2], k = 1

3

/ \

1 4

\

2

Output: 1

Input: root = [5,3,6,2,4,null,null,1], k = 3

5

/ \

3 6

/ \

2 4

/

1

Output: 3

**Note**:You may assume k is always valid, 1 ≤ k ≤ BST's total elements.

**Example 1**:Input: root = [3,1,4,null,2], k = 1

3

/ \

1 4

\

2

Output: 1

**Example 2**:Input: root = [5,3,6,2,4,null,null,1], k = 3

5

/ \

3 6

/ \

2 4

/

1

Output: 3

## May 19, 2020

### #LeetCode: Online Stock Span

**W**rite a class StockSpanner which collects daily price quotes for some stock, and returns the span of that stock's price for the current day.

The span of the stock's price today is defined as the maximum number of consecutive days (starting from today and going backwards) for which the price of the stock was less than or equal to today's price.

For example, if the price of a stock over the next 7 days were [100, 80, 60, 70, 60, 75, 85], then the stock spans would be [1, 1, 1, 2, 1, 4, 6].

## May 18, 2020

### #LeetCode: Permutation in String

**G**iven two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string's permutations is the substring of the second string.

**Example 1**:

Input: s1 = "ab" s2 = "eidbaooo"

Output: True

Explanation: s2 contains one permutation of s1 ("ba").

**Example 2**:

Input:s1= "ab" s2 = "eidboaoo"

Output: False

## May 17, 2020

### Star Bharat brings forth life lessons from the epic tale of ‘Mahabharat’ for its viewers

*Yada yada hi dharmasya glanirbhavati bharata*

*Abhythanamadharmasya tadatmanam srijamyaham*

*Paritranaya sadhunang vinashay cha dushkritam*

*Dharmasangsthapanarthay sambhabami yuge yuge*

**T**his verse was described & recited centuries ago by Lord Shri Krishna in Mahabharat when Arjuna had refused to fight in the battle of Kurukshetra, but it still holds / has relevance even in today’s world. During such unprecedented times in the 21st century, it will require the best of humanity to overcome their battle against the deadly pandemic COVID - 19 and keeping in mind this thought Hindi GEC Star Bharat will soon be bringing this legendary epic tale for its viewers with the telecast of BR Chopra’s Mahabharat from 18th May,2020 onwards every day at 8pm. During such a phase, the channel wants more and more viewers to stay at home and witness the concept of Dharma and Karma entwined in a symbiotic relationship in the epic series Mahabharat.

### #LeetCode: Find All Anagrams in a String

Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.

Strings consists of lowercase English letters only and the length of both strings s and p will not be larger than 20,100.

The order of output does not matter.

Strings consists of lowercase English letters only and the length of both strings s and p will not be larger than 20,100.

The order of output does not matter.

## May 16, 2020

### #LeetCode: Odd Even Linked List

**G**iven a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.

You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity.

## May 15, 2020

### #LeetCode: Maximum Sum Circular Subarray

Given a circular array C of integers represented by A, find the maximum possible sum of a non-empty subarray of C.

Here, a circular array means the end of the array connects to the beginning of the array. (Formally, C[i] = A[i] when 0 < = i < A.length, and C[i+A.length] = C[i] when i > = 0.)

Also, a subarray may only include each element of the fixed buffer A at most once. (Formally, for a subarray C[i], C[i+1], ..., C[j], there does not exist i < = k1, k2 < = j with k1 % A.length = k2 % A.length.)

Input: [1,-2,3,-2]

Output: 3

Explanation: Subarray [3] has maximum sum 3

Here, a circular array means the end of the array connects to the beginning of the array. (Formally, C[i] = A[i] when 0 < = i < A.length, and C[i+A.length] = C[i] when i > = 0.)

Also, a subarray may only include each element of the fixed buffer A at most once. (Formally, for a subarray C[i], C[i+1], ..., C[j], there does not exist i < = k1, k2 < = j with k1 % A.length = k2 % A.length.)

**Example 1**:Input: [1,-2,3,-2]

Output: 3

Explanation: Subarray [3] has maximum sum 3

### Vidya Balan’s Shakuntala Devi Biopic to premiere on Amazon Prime Video

**A**fter Amitabh Bachchan and Ayushmann Khurrana starrer 'Gulabo Sitabo', now 'Shakuntala Devi', featuring Vidya Balan in the titular role, will premiere on Amazon Prime Video.

The film is a biopic on late mathematical wizard Shakuntala Devi, who was nicknamed the human computer for her innate ability to make complex calculations within seconds.

## May 14, 2020

### #LeetCode: Implement Trie (Prefix Tree)

Implement a trie with insert, search, and startsWith methods.

Trie trie = new Trie();

trie.insert("apple");

trie.search("apple"); // returns true

trie.search("app"); // returns false

trie.startsWith("app"); // returns true

trie.insert("app");

trie.search("app"); // returns true

You may assume that all inputs are consist of lowercase letters a-z.

All inputs are guaranteed to be non-empty strings.

**Example**:Trie trie = new Trie();

trie.insert("apple");

trie.search("apple"); // returns true

trie.search("app"); // returns false

trie.startsWith("app"); // returns true

trie.insert("app");

trie.search("app"); // returns true

**Note**:You may assume that all inputs are consist of lowercase letters a-z.

All inputs are guaranteed to be non-empty strings.

### Amitabh Bachchan and Ayushmann Khurrana's ‘Gulabo Sitabo’ to premiere on Amazon Prime Video

**A**mazon Prime Video today announced the global premiere of the highly anticipated Hindi film Gulabo Sitabo exclusively on the streaming service. Directed by Shoojit Sircar, the film stars Amitabh Bachchan (Black, Piku) and Ayushmann Khurrana (Shubh Mangal Zyaada Saavdhan, Andhadhun) in the lead. The movie will premiere exclusively on the 12th of June, 2020 on Amazon Prime Video and will be available in 200 countries and territories worldwide.

## May 13, 2020

### राम जी की चिड़िया राम जी का खेत!

**आ**ज दोपहर में खाना बनाते वक़्त चावल में कुछ कीड़े दिखे, मैंने सोचा चावल फेकने से बेहतर है इन्हे धुप में रख दू। श्याम को जब मैं चावल की प्लेट खिड़की से उठाने गया तो देखा, ४-५ चिड़िया और कुछ कबूतर बड़े आराम से चावल खा रहे है। मुझे गुस्सा आ गया और मैंने ज़ोर से चिल्लाया, बिचारे चिड़िया और कबूतर डर के उड़ गए। ज्यादा नुक्सान नहीं हुआ ये सोचके मैं ख़ुश हो ही रहा था के गुरु नानक देव जी की एक बात याद आ गयी।

लॉकडाउन के तकरीबन २ हफ्ते पहले वर्सोवा के गुरुद्वारा साहिब सचखंड दरबार जाना हुआ था, वहाँ गुरु नानक देव जी से जुड़ी की खूबसूरत बात सुनने को मिली। नानक के पिता का नाम कल्यानचंद दास बेदी था, जो पेशे से पटवारी हुआ करते थे।

### #LeetCode: Remove K Digits

Given a non-negative integer number represented as a string, remove k digits from the number so that the new number is the smallest possible.

## May 12, 2020

### #LeetCode:Single Element in a Sorted Array

You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Find this single element that appears only once.

Input: [1,1,2,3,3,4,4,8,8]

Output: 2

Input: [3,3,7,7,10,11,11]

Output: 10

**Example 1**:Input: [1,1,2,3,3,4,4,8,8]

Output: 2

**Example 2**:Input: [3,3,7,7,10,11,11]

Output: 10

## May 11, 2020

### #LeetCode: Flood Fill

**A**n image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535).

Given a coordinate (sr, sc) representing the starting pixel (row and column) of the flood fill, and a pixel value newColor, "flood fill" the image.

To perform a "flood fill", consider the starting pixel, plus any pixels connected 4-directionally to the starting pixel of the same color as the starting pixel, plus any pixels connected 4-directionally to those pixels (also with the same color as the starting pixel), and so on. Replace the color of all of the aforementioned pixels with the newColor.

### #LeetCode: Squares of a Sorted Array

Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order.

Input: [-4,-1,0,3,10]

Output: [0,1,9,16,100]

**Example 1**:Input: [-4,-1,0,3,10]

Output: [0,1,9,16,100]

## May 10, 2020

### #AuntyKahoNa: On Mother’s Day Twinkle Khanna wants her kids to call her AUNTY

The actor-turned-author Twinkle Khanna shared a monologue on her Instagram page on the occasion of Mother’s Day.

In the hilarious video, which is full of MrsFunnyBones's signature sarcasm reevealed what all the mothers really want from their children instead of all the fancy greetings.

The 46-year-old author, said, what she really wants for Mother's day is a day off from responsibilities, to not be asked where is the blue t-shirt, if her kids can go to visit their friends and when the coronavirus lockdown is going to end.

The monologue, shared by Twinkle also features how she wants her kids to call her 'aunty' on mother's day and not 'mummy'.

In the hilarious video, which is full of MrsFunnyBones's signature sarcasm reevealed what all the mothers really want from their children instead of all the fancy greetings.

The 46-year-old author, said, what she really wants for Mother's day is a day off from responsibilities, to not be asked where is the blue t-shirt, if her kids can go to visit their friends and when the coronavirus lockdown is going to end.

The monologue, shared by Twinkle also features how she wants her kids to call her 'aunty' on mother's day and not 'mummy'.

### #LeetCode:Find the Town Judge

**I**n a town, there are N people labelled from 1 to N. There is a rumor that one of these people is secretly the town judge.

If the town judge exists, then:

The town judge trusts nobody.

Everybody (except for the town judge) trusts the town judge.

There is exactly one person that satisfies properties 1 and 2.

You are given trust, an array of pairs trust[i] = [a, b] representing that the person labelled a trusts the person labelled b.

## May 09, 2020

### #LeetCode: Valid Perfect Square

**G**iven a positive integer num, write a function which returns True if num is a perfect square else False.

**Note**: Do not use any built-in library function such as sqrt.

**Example 1**:

Input: 16

Output: true

**Example 2**:

Input: 14

Output: false

## May 08, 2020

### #LeetCode:Check If It Is a Straight Line

You are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. Check if these points make a straight line in the XY plane.

**Constraints**:- 2 < = coordinates.length <= 1000
- coordinates[i].length == 2
- -10 ^ 4 < = coordinates[i][0], coordinates[i][1] < = 10^4
- coordinates contains no duplicate point.

## May 07, 2020

### #LeetCode:Cousins in Binary Tree

**I**n a binary tree, the root node is at depth 0, and children of each depth k node are at depth k+1.

Two nodes of a binary tree are cousins if they have the same depth, but have different parents.

We are given the root of a binary tree with unique values, and the values x and y of two different nodes in the tree.

### #LeetCode: Find Numbers with Even Number of Digits

Given an array nums of integers, return how many of them contain an even number of digits.

Input: nums = [12,345,2,6,7896]

Output: 2

Explanation:

**Example 1**:Input: nums = [12,345,2,6,7896]

Output: 2

Explanation:

- 12 contains 2 digits (even number of digits).
- 345 contains 3 digits (odd number of digits).
- 2 contains 1 digit (odd number of digits).
- 6 contains 1 digit (odd number of digits).
- 7896 contains 4 digits (even number of digits).
- Therefore only 12 and 7896 contain an even number of digits.

## May 06, 2020

### #NarasimhaJayanti:रौद्र नहीं सौम्य भी है नरसिंह

आज वैशाख मास के शुक्ल पक्ष की चतुर्दशी है। कहते है आज ही के दिन भगवान् विष्णु ने नरसिंह अवतार लिया था, इसीलिए आज का दिन नरसिंह जयंती के रूप में बनाया जाता है।

मुझे बचपन से ये अवतार थोड़ा भयानक लगा क्यूंकि हर जगह नरसिंह जी का सिर्फ रौद्र रूप देखा। करीब करीब एक दशक पहले जब मैं जुहू के इस्कॉन टेम्पल गया तब वहाँ एक छोटे बच्चे को रोते हुए देखा, वो नरसिंह के भयावह रूप वाली मूर्ति देखकर डर गया था।

साथ ही खड़े एक उम्र दराज़ शख्स ने मुस्कुराते हुए कहा,

मुझे बचपन से ये अवतार थोड़ा भयानक लगा क्यूंकि हर जगह नरसिंह जी का सिर्फ रौद्र रूप देखा। करीब करीब एक दशक पहले जब मैं जुहू के इस्कॉन टेम्पल गया तब वहाँ एक छोटे बच्चे को रोते हुए देखा, वो नरसिंह के भयावह रूप वाली मूर्ति देखकर डर गया था।

**बच्चे की माँ उससे ये कहकर चुप करा रही ही ।***"डरते नहीं बेटा ये भगवान् है,"**मेरे मुँह से सहसा निकल पड़ा ।***"नरसिंह रूप देखके डर तो स्वाभाविक है,"**साथ ही खड़े एक उम्र दराज़ शख्स ने मुस्कुराते हुए कहा,

**"स्वाभाविक नहीं है। नरसिंह अवतार देखकर तो बिलकुल भी नहीं ।"**### #LeetCode:Majority Element

**G**iven an array of size n, find the majority element. The majority element is the element that appears more than n/2 times. You may assume that the array is non-empty and the majority element always exist in the array.

**Example 1**:

Input: [3,2,3]

Output: 3

**Example 2**:

Input: [2,2,1,1,1,2,2]

Output: 2

## May 05, 2020

### #SpringSecurity: OAuth2 Implementation with Spring Boot

**I**n this tutorial we will learn to build an authorization server using oauth2 to authenticate user's identity to provide access_token. This access_token will be used to request data from resource server.

We will be creating an authorization server and embedding the resource server inside authorization server. Authorization server will generate the tokens and resource server will validate these token.

We will be having two services, first one would be authorization server (along with resource server) and the second one would be a client, from which we will be accessing the servers.

### #Ramayan: क्या राम ने वकाई खाये थे शबरी के झूठे बेर?

**रा**मानंद सागर की रामायण में शबरी के राम मिलान वाला एपिसोड Youtube पे देख रहा था। रामानंद जी ने रामकथा बहुत साफ़, सहज, और दिल छू लेने वाले भाव से बनायी है, पर शबरी वाला एपिसोड थोड़ा थोड़ा आँखों में चुबता है।

शबरी कहती है

**उसके बाद राम शबरी को नवदा भक्ति के बारे में बताते है।**

*"हे राम मुझे नीच कुल में उत्त्पन ये शरीर छोड़ने की आज्ञा देने से पहले मुझे भक्ति का ज्ञान प्रदान करो प्रभु।"*रामानंद की रामायण के मखमली क़ालीन जैसी लगती है। शबरी का बार बार खुद को 'नीच' कहने वाले संवाद इस मखमली क़ालीन पर टाट के पैबंद जैसे लगते है।

### #LeetCode: First Unique Character in a String

**G**iven a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.

**Examples**:

s = "leetcode"

return 0.

s = "loveleetcode",

return 2.

## May 04, 2020

### #LeetCode: Max Consecutive Ones

Given a binary array, find the maximum number of consecutive 1s in this array.

Input: [1,1,0,1,1,1]

Output: 3

The input array will only contain 0 and 1.

The length of input array is a positive integer and will not exceed 10,000

**Example 1**:Input: [1,1,0,1,1,1]

Output: 3

**Explanation**: The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3.**Note**:The input array will only contain 0 and 1.

The length of input array is a positive integer and will not exceed 10,000

### #LeetCode: Number Complement

**G**iven a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.

**Example 1**:

Input: 5

Output: 2

Explanation: The binary representation of 5 is 101 (no leading zero bits), and its complement is 010. So you need to output 2.

### #SpringSecurity: What is the difference between access and refresh token?

__Access Token__- An access token is a string representing an authorization issued to the client. Tokens represent specific scopes and duration of access, granted by the resource owner, and enforced by the resource server and authorization server.
- An access token is put in the Authorization header of our request and it usually looks like 'Bearer h090Yuuyuiyv'. It is verified by the API, which the client is calling.
- Access token are usually in JWT format, but you can use any other format.
- Access tokens are usually short lived, because it is difficult (although not impossible) to centrally revoke access tokens.
- The responsibility of access token is to access data before it gets expired.

### #SpringSecurity:Oauth 2.0 Roles

**O**Auth 2 is an authorization method to provide access to protected resources over the HTTP protocol.

It enables a third-party application to obtain limited access to an HTTP service:

a). Either on behalf of a resource owner by orchestrating an approval interaction between the resource owner and the HTTP service

b). Or by allowing the third-party application to obtain access on its own behalf.

## May 03, 2020

### #LeetCode: Ransom Note

**G**iven an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; otherwise, it will return false.

Each letter in the magazine string can only be used once in your ransom note.

## May 02, 2020

### #LeetCode: Jewels and Stones

You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels.

The letters in J are guaranteed distinct, and all characters in J and S are letters. Letters are case sensitive, so "a" is considered a different type of stone from "A".

The letters in J are guaranteed distinct, and all characters in J and S are letters. Letters are case sensitive, so "a" is considered a different type of stone from "A".

### #Ramayan: कैसे हुआ था सीता का जन्म?

आज कही पढ़ा

**'धार्मिक मान्यता है कि इस दिन प्रभु श्रीराम और माता जानकी को विधि-विधान पूर्वक पूजा आराधना करने से व्रती को अमोघ फल की प्राप्ति होती है साथ ही व्रती को मनोवांछित फलों की भी प्राप्ति होती है'।**थोड़ा हास्यास्पद लगा, जन्मदिन सीता का और पूजा राम के साथ? बताये ज़रा क्या ऐसी कोई धार्मिक मान्यता है जो कहती हो राम नवमी के दिन राम-सीता की पूजा या फिर जन्माष्टमी के दिन कृष्णा के साथ राधा की आराधना करना चाहिए? खैर जाने दीजिये, पुरुष प्रधान समाज में ऐसा मुमकिन कहा?

कभी समय मिले तो वाल्मीकि रामायण पढ़ियेगा, पुरुष प्रधानता की अनेक मिसाल मिल जायेगी।

शायद इसीलिए वाल्मीकि जी ने सर्ग ६६(छियासठ) में सिर्फ दो श्लोको (१३-१४) में सीता की उत्पत्ति के बारे में संक्षेप में वर्णन किया है, हलाकि राम जन्म विस्तार में बताया गया है।

## May 01, 2020

### #SpringSecurity: What’s the difference OAuth 1.0 and OAuth 2.0?

**O**Auth 2.0 is a completely new protocol, and this release is not backwards-compatible with OAuth 1.0.

### #LeetCode: First Bad Version

**Y**ou are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.

Suppose you have n versions [1, 2, ..., n] and you want to find out the first bad one, which causes all the following ones to be bad.

You are given an API bool isBadVersion(version) which will return whether version is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.

### Memorable on-screen characters played by birthday-girl Anushka Sharma

Over the years, the Hindi film industry has been consistently blessed with some exceptionally talented artists and one such mention-worthy name is Anushka Sharma. She made her quintessential debut with Shah Rukh Khan in Rab Ne Bana Di Jodi and has not looked back ever since. From conning a con artist in Ladies vs. Ricky Bahl, to bringing to life a soldier’s story in Jab Tak Hain Jaan and working her magic in Sui Dhaga, Pari, Sulta and Ae Dil Hai Mushkil, the actress has secured a special place in the viewers’ hearts with her commendable, versatile performance. She recently announced her digital debut as producer of upcoming Amazon Original Series Paatal Lok that is set to release on 15th May.

## April 30, 2020

### #LeetCode: Check valid sequence from root to leaves in a BTree

**C**heck If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree

Given a binary tree where each path going from the root to any leaf form a valid sequence, check if a given string is a valid sequence in such binary tree.

We get the given string from the concatenation of an array of integers arr and the concatenation of all values of the nodes along a path results in a sequence in the given binary tree.

### #LeetCode: Binary Tree Maximum Path Sum

Given a non-empty binary tree, find the maximum path sum.

For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need to go through the root.

For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need to go through the root.

## April 28, 2020

### #LeetCode: First Unique Number

**Y**ou have a queue of integers, you need to retrieve the first unique integer in the queue.

Implement the FirstUnique class:

- FirstUnique(int[] nums) Initializes the object with the numbers in the queue.
- int showFirstUnique() returns the value of the first unique integer of the queue, and returns -1 if there is no such integer.
- void add(int value) insert value to the queue.

### #JWT: Part 3 - Spring Boot project with Spring Security and JWT Example

We will develop a Spring boot project with Spring security and JWt from scratch.

Objectives:

1). Create an API which will authenticate the user details and generate JWT token.

2). Functionality which will verify each request for the valid JWT.

Objectives:

1). Create an API which will authenticate the user details and generate JWT token.

2). Functionality which will verify each request for the valid JWT.

### #JWT: Part 2 - JWT Structure

__What is JWT token?__JWT (JSON Web Token) is a safe, compact, and self-contained way of transmitting information between multiple parties in the form of a JSON object. It is used for authorization.

### #JWT: Part 1 - Authorization Strategies, Real Life examples of Session and JWT Token

__Authorization Strategies__HTTP is a stateless protocol that's why we need to send all the desired information each time, so that the server can authorize the request.

Let's say you are logged in tinder, while login you need to enter your user name and password. Tinder will verify if you are a valid user or not, if yes, it will start showing potential matches. Now if you right or left swipe on any profile, or do anything else on Tinder, it will send a request again to the Tinder server. Since HTTP is stateless, with each request you will asked to enter your credentials, which is quite irritating. To solve this problem, the session is managed.

## April 27, 2020

### #LeetCode: Maximal Square

**G**iven a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.

**Example**:

Input:

1 0 1 0 0

1 0 1 1 1

1 1 1 1 1

1 0 0 1 0

Output: 4

## April 26, 2020

### Yash Pandit and Khushi Mukherjee roped in for Ullu App's Love Festival..

**U**llu App is coming up with another interesting web-series which is based on partner exchange. The online streaming platform is all set to release another story of 'Riti Riwaj', which is titled 'Love Festival'. We heard, Yash Pandit and Khushi Mukherjee are roped in to play husband and wife in the series.

### #LeetCode: Longest Common Subsequence

Given two strings text1 and text2, return the length of their longest common subsequence.

A subsequence of a string is a new string generated from the original string with some characters(can be none) deleted without changing the relative order of the remaining characters. (eg, "ace" is a subsequence of "abcde" while "aec" is not). A common subsequence of two strings is a subsequence that is common to both strings.

If there is no common subsequence, return 0.

A subsequence of a string is a new string generated from the original string with some characters(can be none) deleted without changing the relative order of the remaining characters. (eg, "ace" is a subsequence of "abcde" while "aec" is not). A common subsequence of two strings is a subsequence that is common to both strings.

If there is no common subsequence, return 0.

## April 25, 2020

### #LeetCode: Java Solution of Jump Game problem

**G**iven an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if you are able to reach the last index.

## April 17, 2020

### Veronica Vanij bags Ullu App's Smartphone

Online Streaming platform Ullu App is leaving no stone unturned to woo the viewers during quarantine. They are making the lockdown experience better with a varied offers and new editions of shows. Recently they launched the season 2 of its popular show Kavita Bhabhi, which received a massive response. Now they are gearing up to stream short film titled Smartphone.

## April 16, 2020

### Part 4: Elastic Search Interview Questions And Answers

__What is ELK Stack and its contents?__Enterprises, large or small nowadays come across information in the form of reports, data and customer follow-ups and historical, current orders as well as customer reviews from the online and offline logs. It is essential to store and analyze these logs which will help predict valuable feedback for the businesses.

### Part 3: Elastic Search Interview Questions And Answers

__What is an Elasticsearch Analyzer? What are the various types of analyzers in Elasticsearch?__Analyzers are used for Text analysis, it can be either built-in analyzer or custom analyzer.

The analyzer consists of zero or more character filters, at least one Tokenizer and zero or more Token filters.

### Part 2: Elastic Search Interview Questions And Answers

__Explain the procedure to add or create an index in Elasticsearch Cluster?__To add a new index, create an index API option should be used. The parameters required to create the index is Configuration setting of an index, Fields mapping in the index as well as Index aliases.

### Part 1: Elastic Search Interview Questions And Answers

__Explain in brief about Elasticsearch?__Elasticsearch is an open-source, RESTful, scalable, built on Apache Lucene library, document-based search engine. It stores retrieve and manage textual, numerical, geospatial, structured and unstructured data in the form of JSON documents using CRUD REST API or ingestion tools such as Logstash.

## April 14, 2020

### How to pass command line arguments in Python?

__Handling command line arguments with Python__- There are number of different ways of handling command line arguments in Python 3.
- 'sys' module is the built-in way.
- We can also use getopt module, which handles both short and long options, including the evaluation of the parameter values.
- argparse module, which is derived from the optparse module available up to Python 2.7, we can also use it to handle command line arguments.
- The other method is using the docopt module, which is available on GitHub.

## April 02, 2020

### #Collections: Part 5 (Hashmap implementation in pre-Java 8 and Java 8)

__What is the difference in Hashmap implementation in pre-Java 8 and Java 8?__**There is no change to how the Java developer uses and implements HashMap < K, V > . In Java 8, they have made some internal change in HashMap, well that changes not only affect HashMap but also, LinkedHashMap, and ConcurrentHashMap.**

a). The alternative String hash function added in Java 7 has been removed in Java 8. The default hash formula on strings was optimized to being both faster and allow for less clashes on average. Thus if your key is a string (some someone’s name in a contacts list), it should calculate that hash faster than before and the likelihood that it would calculate a hash pointing to the same bucket is less.

b). Buckets containing a large number of colliding keys will store their entries in a balanced tree instead of a linked list after certain threshold is reached.

### #Collections: Part 4 (How ConcurrentHashMap Works Internally in Java?)

__What is ConcurrentHashMap?__ConcurrentHashMap class is introduced in JDK 1.5, which implements ConcurrentMap as well as Serializable interface also.

ConcureentHashMap is enhancement of HashMap and allow concurrent access to the map. Segment, which is internal data structure and part of map is locked while adding or updating the map. Due to this the ConcurrentHashMap allows concurrent threads to read the value without locking at all. This data structure was introduced to improve performance.

## April 01, 2020

### Part 1: Node JS Tutorial-var vs let vs const in JavaScript

**W**hile declaring any variable we can use either var, let or const. In JavaScript, variables are initialized with the value of undefined when they are created. What that means is if we try to log the declaration variable, we’ll get undefined. e.g:

*var name;*

*console.log(name); // this will print 'undefined'*

### Part 2: Node JS Tutorial- Understanding npm

__Write your own module__Open visual studio code, create a new file with the name my-module.js. Let's create another file module-demo.js. We will declare a variable inside my-module.js and try to access it from module-demo.js.

In my-module.js, we have declared variable mytext.

### How to Convert PDF to Image using Python?

We can user pdf2image library in Python 3 for converting image. This library wraps pdftoppm and pdftocairo to convert PDF to an image object.

### #Collections: Part 3- All about PriorityQueue in Java

__What is PriorityQueue in Java?__- A queue follows First-In-First-Out algorithm, in case of PriorityQueue queue elements are processed according to the priority (ordered as per their natural ordering or based on a custom Comparator supplied at the time of creation).
- The PriorityQueue is based on the priority heap.
- The elements of the PriorityQueue are ordered according to the natural ordering, or by a Comparator provided at queue construction time, depending on which constructor is used.
- We can’t create PriorityQueue of Objects that are non-comparable
- PriorityQueue in Java doesn’t permit null.
- PriorityQueue are unbound queues.
- The head of this queue is the least element with respect to the specified ordering. If multiple elements are tied for least value, the head is one of those elements — ties are broken arbitrarily.
- The queue retrieval operations poll, remove, peek, and element access the element at the head of the queue.
- PriorityQueue inherits methods from AbstractQueue, AbstractCollection, Collection and Object class.

__PriorityQueue Constructors__**PriorityQueue()**: Creates a PriorityQueue with the default initial capacity (which is 11) that orders its elements according to their natural ordering.**PriorityQueue(Collection**: It creates a PriorityQueue containing the elements in the specified collection.c) **PriorityQueue(int initialCapacity)**: Creates a PriorityQueue with the specified initial capacity that orders its elements according to their natural ordering.**PriorityQueue(int initialCapacity, Comparator**: Creates a PriorityQueue with the specified initial capacity that orders its elements according to the specified comparator.comparator) **PriorityQueue(PriorityQueue**: Creates a PriorityQueue containing the elements in the another priority queue.c) **PriorityQueue(SortedSet**: Creates a PriorityQueue containing the elements in the specified sorted set.c)

__PriorityQueue operations__- boolean add(E element)inserts the specified element into this priority queue.
- boolean offer(E e) method is used to insert a specific element into the priority queue.
- public peek() retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
- public poll()retrieves and removes the head of this queue, or returns null if this queue is empty.
- public remove() removes a single instance of the specified element from this queue, if it is present. When we remove an element from the priority queue, the least element according to the specified ordering is removed first.
- Iterator iterator() returns an iterator over the elements in this queue.
- boolean contains(Object o) method returns true if this queue contains the specified element
- void clear() is used to remove all of the contents of the priority queue.
- int size() return the number of elements present in the set.
- toArray() is used to return an array containing all of the elements in this queue.
- Comparator comparator() method is used to return the comparator that can be used to order the elements of the queue.

**GIT URL:**

__PriorityQueue Example in Java__