May 06, 2020

#LeetCode:Majority Element

Given 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

#NarasimhaJayanti

Happy Birthday Dear Adorable ЁЯМ╝

May 05, 2020

#SpringSecurity: OAuth2 Implementation with Spring Boot

In 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

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

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

Given 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

OAuth 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

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

#Ramayan: рдХैрд╕े рд╣ुрдЖ рдеा рд╕ीрддा рдХा рдЬрди्рдо?

рдЖрдЬ рдмैрд╕ाрдЦ рдоाрд╕ рдХे рд╢ुрдХ्рд▓ рдкрдХ्рд╖ рдХी рдирд╡рдоी рддिрдеि рд╣ै, рдкौрд░ाрдгिрдХ рдЧ्рд░ंрдеों рдХे рдЕрдиुрд╕ाрд░ рдЖрдЬ рдХे рджिрди рд╕ीрддा рдХी рдЙрдд्рдкрдд्рддि рд╣ुрдИ рдеी।

рдЖрдЬ рдХрд╣ी рдкреЭा 'рдзाрд░्рдоिрдХ рдоाрди्рдпрддा рд╣ै рдХि рдЗрд╕ рджिрди рдк्рд░рднु рд╢्рд░ीрд░ाрдо рдФрд░ рдоाрддा рдЬाрдирдХी рдХो рд╡िрдзि-рд╡िрдзाрди рдкूрд░्рд╡рдХ рдкूрдЬा рдЖрд░ाрдзрдиा рдХрд░рдиे рд╕े рд╡्рд░рддी рдХो рдЕрдоोрдШ рдлрд▓ рдХी рдк्рд░ाрдк्рддि рд╣ोрддी рд╣ै рд╕ाрде рд╣ी рд╡्рд░рддी рдХो рдордиोрд╡ांрдЫिрдд рдлрд▓ों рдХी рднी рдк्рд░ाрдк्рддि рд╣ोрддी рд╣ै'। 

рдеोреЬा рд╣ाрд╕्рдпाрд╕्рдкрдж рд▓рдЧा, рдЬрди्рдорджिрди рд╕ीрддा рдХा рдФрд░ рдкूрдЬा рд░ाрдо рдХे рд╕ाрде? рдмрддाрдпे реЫрд░ा рдХ्рдпा рдРрд╕ी рдХोрдИ рдзाрд░्рдоिрдХ рдоाрди्рдпрддा рд╣ै рдЬो рдХрд╣рддी рд╣ो рд░ाрдо рдирд╡рдоी рдХे рджिрди рд░ाрдо-рд╕ीрддा рдХी рдкूрдЬा рдпा рдлिрд░ рдЬрди्рдоाрд╖्рдЯрдоी рдХे рджिрди рдХृрд╖्рдгा рдХे рд╕ाрде рд░ाрдзा рдХी рдЖрд░ाрдзрдиा рдХрд░рдиा рдЪाрд╣िрдП? рдЦैрд░ рдЬाрдиे рджीрдЬिрдпे, рдкुрд░ुрд╖ рдк्рд░рдзाрди рд╕рдоाрдЬ рдоें рдРрд╕ा рдоुрдордХिрди рдХрд╣ा?

рдХрднी рд╕рдордп рдоिрд▓े рддो рд╡ाрд▓्рдоीрдХि рд░ाрдоाрдпрдг рдкреЭिрдпेрдЧा, рдкुрд░ुрд╖ рдк्рд░рдзाрдирддा рдХी рдЕрдиेрдХ рдоिрд╕ाрд▓ рдоिрд▓ рдЬाрдпेрдЧी।

рд╢ाрдпрдж рдЗрд╕ीрд▓िрдП рд╡ाрд▓्рдоीрдХि рдЬी рдиे рд╕рд░्рдЧ ремрем(рдЫिрдпाрд╕рда) рдоें рд╕िрд░्рдл рджो рд╢्рд▓ोрдХो (резрей-резрек) рдоें рд╕ीрддा рдХी рдЙрдд्рдкрдд्рддि рдХे рдмाрд░े рдоें рд╕ंрдХ्рд╖ेрдк рдоें рд╡рд░्рдгрди рдХिрдпा рд╣ै, рд╣рд▓ाрдХि рд░ाрдо рдЬрди्рдо рд╡िрд╕्рддाрд░ рдоें рдмрддाрдпा рдЧрдпा рд╣ै।

May 01, 2020

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


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

#LeetCode: First Bad Version

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

Jai Maharashtra says Amrita Rao

Actress Amrita Rao who prides in been born and brought up in Mumbai, took time during the lockdown for her special salutations to the State on the occasion of Maharashtra Day. May 1st is annually marked to commemorate the creation of Maharashtra from the State of Bombay on May 1, in the year 1960.

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.