# wgpshashank Profile

wgpshashank

Join Date:

2011-01-30

### Blogs Owned

If data Structures & Algorithm,Problem Solving Makes You excited & Gives You Pleasure the.. you can Post your question solution and comments . Happy Coding

Other Tags: Data Structure, Algorithms,, Dynamic Programming, Linked List, Binary Trees

### Latest Blog Posts

- Find firstNon repeating character in string in one passon Jul 14, 2016import java.util.LinkedHashMap;public class FirstNonRepeated { public static void main(String[] args) { LinkedHashMap<Character, Integer> linkedHashMap = new LinkedHashMap<>(); String str = "allergicToBitches"; for...
- Given: an array x of N elements, sorted in ascending order and an integer a Try to find a in x. 1. if a is in x: return its position 2. if a is not in x: return the position, where to insert a in x, such that x remains sortedon Nov 24, 2014 in Binary Search imoNote: Question is pretty simple but there are lots of test cases to cover if you find any test case is not working , feel free comment.import java.util.*;import java.lang.*;import java.io.*;/* Name of the class has to be "Main" only if the class is p...
- Given a element, find the strictly greater element in sorted array - 1st post for 2k14on Apr 2, 2014 in Binary SearchE.g. if array is // [ a, c, d, h, k, l, l, l, o, u, x, z ]//if given m -> o// if given k -> limport java.util.*;import java.lang.*;import java.io.*;/* Name of the class has to be "Main" only if the class is public. */class Ideone{ public...
- Given a stream of characters, find the first non-repeating character from stream. You need to tell the first non-repeating character in O(1) time at any moment.on Dec 9, 2013 in Google Interview...
- iven a stream of characters, find the first non-repeating character from stream. You need to tell the first non-repeating character in O(1) time at any moment.on Dec 9, 2013 in Google Interview...
- iven a stream of characters, find the first non-repeating character from stream. You need to tell the first non-repeating character in O(1) time at any moment.on Dec 9, 2013 in Google Interview...
- iven a stream of characters, find the first non-repeating character from stream. You need to tell the first non-repeating character in O(1) time at any moment.on Dec 9, 2013 in Google Interview...
- Suppose u have a square matrix of 0s and 1s only ... find the longest path of 1s available in the matrix and return that .. you can only move right and down ...on Dec 1, 2013 in Goldman Sachs InterviewFor e.g. for the below matrix 0 0 0 1 1 1 1 1 0 1 0 1 1 1 0 0 0 1 0 0 1 1 1 1 1 The path is1th -- [ 1, 0]2th -- [ 1, 1]3th -- [ 2, 1]4th -- [ 2, 2]5th -- [ 3, 2]6th -- [ 4, 2]7th -- [ 4, 3]8th -- [ 4, 4]The...
- Given an integer N, print numbers from 1 to N in lexicographic order , You are not allowed to use any library functionson Dec 1, 2013 in Bloomberg LLP...
- find the sum of array elements after kth iterationon Dec 1, 2013 in Amazon Interview Binomial Coefficientfor example if array is ar[]=4 6 8 3 6} then below will be the sum after k=0 to 3rd iterationsAfter 0th iteration, arr[ ]={4,6,8,3,6}. Sum of all elements of the array = 27After 1st iteration, arr[ ]={-2,-2,5,-3}. Sum of all elements of the array = -...
- Given a deck of nCards unique cards, cut the deck iCut cards from top and perform a perfect shuffle. A perfect shuffle begins by putting down the bottom card from the top portion of the deck followed by the bottom card from the bottom portion of the deck followed by the next card from the top portion, etc., alternating cards until one portion is used up. The remaining cards go on top. The problem is to find the number of perfect shuffles required to return the deck to its original order.on Nov 16, 2013 in FaceBook Engineering TeamExample if nCards=9 and ICut=6 then for N=123456789 , you need 3 shuffle to get the original positions , wondering how , try it now and feel free to post comment here .
- Find all 10 digit numbers which are perfect squares efficientlyon Oct 16, 2013 in Twitter Interview...
- Two players play the following game: they pick a random number N (less than 2 billion) then, starting from 1, take turns multiplying the number from the previous turn with either 2 or 9 (their choice). Whoever reaches N first wins. The candidate should write a function that given N decides who wins (first or second player)?on Oct 13, 2013 in Facebook Interview...
- Design a function f, such that: f(f(n)) == -n Where n is a 32 bit signed integer; you can't use complex numbers arithmetic. If you can't design such a function for the whole range of numbers, design it for the largest range possible.on Oct 13, 2013 in Quora...
- Two strings can be chained if the first one ends with the same character second one starts with. Given set of 'n' strings, how can we verify efficiently, whether they can be chained or not?on Oct 3, 2013 in Quorae.g. cat, dog, toad answer is YES. for tape ate ass answer is NO.
- A circular array A[1, . . . , n] is an array such that n ≥ 3 and A[1] and A[n] are considered to be adjacent elements just like A[1] and A[2], A[2] and A[3], etc., are adjacent. We are given a circular array A[1, . . . , n] of non-negative integers. For any i, j ∈ {1, 2, . . . , n} such that i != j, dist(i, j) = max {|i − j|, n − |i − j|}. Design a linear time algorithm that computes a maximum number t such that for some i, j ∈ {1, 2, . . . , n}, i != j, t = A[i] + A[j] + dist(i, j).on Oct 2, 2013 in FaceBook Engineering Team...
- Given an array of integers of size N, if M elements are removed from it the rest of the elements will be in sorted order. What is a good algorithm to find those M elements?on Sep 20, 2013 in Google Interview Quora...
- More About Rajeev Motwani : Life and Startup he didn’t loveon Sep 13, 2013startup he didn’t love Rajeev Motwani, wanted to study mathematics and become another Gauss! His father, however, persuaded him to study computer science. Little did he know how closely the two are related? He graduated with B.Tech. in comput...
- Programmers Day Special : One of Worlds Finest Programmer , Mathematician and Man Behind Google :: Rajeev Motwanion Sep 13, 2013Growing up Rajeev Motwani, wanted to study mathematics and become another Gauss! His father, however, persuaded him to study computer science. Little did he know how closely the two are related? He graduated with B.Tech. in computer science from IITK...
- Optimize the cost of concatenation of all these strings into one big string.You have n strings with their lengths. You are given an add(string s1,string s2) which would concatenate the string s2 with s1 and return s3. Optimize the cost of concatenation of all these strings into one big string.Eg: 1,5,2 are the lengths o...