April 30, 2020

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

Check 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.

April 28, 2020

#LeetCode: First Unique Number

You 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.

#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

Given 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..

Ullu 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.

April 25, 2020

#LeetCode: Java Solution of Jump Game problem

Given 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.

Part 6: Elastic Search Interview Questions And Answers(Hands On)

Explain Bool Query in ElasticSearch.
A query that matches documents matching boolean combinations of other queries is called Bool Query. It is built using one or more boolean clauses, each clause with a typed occurrence. 

  • must: The clause (query) must appear in matching documents and will contribute to the score.
  • filter: The clause (query) must appear in matching documents. However unlike must the score of the query will be ignored. Filter clauses are executed in filter context, meaning that scoring is ignored and clauses are considered for caching.
  • should: The clause (query) should appear in the matching document.
  • must_not: The clause (query) must not appear in the matching documents. Clauses are executed in filter context meaning that scoring is ignored and clauses are considered for caching. Because scoring is ignored, a score of 0 for all documents is returned.

What is the difference between MUST and SHOULD bool query?
must means: The clause (query) must appear in matching documents. These clauses must match, like logical AND.
should means: At least one of these clauses must match, like logical OR.

In other words, results will have to be matched by all the queries present in the must clause or match at least one of the should clauses if there is no must clause.

What is the difference between MUST and FILTER bool query?
The must contributes to the score. In filter, the score of the query is ignored.

In both must and filter, the clause(query) must appear in matching documents. This is the reason for getting same result.

Examples:
To get list of all the bank accounts, execute:
GET bank/account/_search

To get all the bank acconuts from California (State will be CA):
GET bank/account/_search
{
  "query": {
    "match": {"state": "CA"}
  }
}

To get all the bank acconuts of Techade from California (State will be CA)
GET bank/account/_search
{
  "query": {
    "bool": {
      "must": [
        { "match": {"state": "CA"} },
        { "match": {"employer": "Techade"}}
      ]
    }
  }
}

To get all the bank acconuts not from Techade and outside California (State will be CA)
GET bank/account/_search
{
  "query": {
    "bool": {
      "must_not": [
        { "match": {"state": "CA"} },
        { "match": {"employer": "Techade"}}
      ]
    }
  }
}

-K Himaanshu Shuklaa..

Part 5: Elastic Search Interview Questions And Answers(Hands On)

How to check health of cluster and node?
Start ElasticSearch and Kibana, and then open Kibana dashboard (you can open it with this URL  http://localhost:5601/app/kibana#/dev_tools/console)

to check health of cluster execute:
GET _cat/health?v

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.