May 14, 2020

#LeetCode: Implement Trie (Prefix Tree)

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

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

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

I am all for new tunes: Asha Bhosle

She has been bestowed with contagious energy, an ever-youthful persona and voice that has mesmerised audiences transcending generations. Now, Asha Bhosle is on YouTube with her channel 'Asha Bhosle Official' youthful original content, albeit with a dash of spiritualism!

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.

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

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

Example 1:
Input: [-4,-1,0,3,10]
Output: [0,1,9,16,100]

#RIP: Actor Shafique Ansari passes away

Actor Shafique Ansari, well known for his cameo appearances in Crime Patrol passed away on Sunday, May 10, 2020. We heard, the actor had been battling cancer for a few years.

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

#LeetCode:Find the Town Judge

In 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

Given 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

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

Return true if and only if the nodes corresponding to the values x and y are cousins.

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

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:रौद्र नहीं सौम्य भी है नरसिंह

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

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

"डरते नहीं बेटा ये भगवान् है," बच्चे की माँ उससे ये कहकर चुप करा रही ही ।

"नरसिंह रूप देखके डर तो स्वाभाविक है," मेरे मुँह से सहसा निकल पड़ा ।

साथ ही खड़े एक उम्र दराज़ शख्स ने मुस्कुराते हुए कहा, "स्वाभाविक नहीं है। नरसिंह अवतार देखकर तो बिलकुल भी नहीं ।"