Re: [algogeeks] Re: Adobe Noida Interview Question

2012-04-29 Thread WgpShashank
/Cracking-The-Code/148241881919895 Google+ http://gplus.to/wgpshashank Twitter https://twitter.com/wgpshashankhttps://twitter.com/#%21/wgpshashank * On Sunday, April 1, 2012 9:52:11 PM UTC+7, atul007 wrote: Q2 can be done using KMP algo or suffix tree On Sun, Apr 1, 2012 at 1:12 PM, Decipher

[algogeeks] Re: [Combinatorics] count possible number of binary search trees, given number of nodes

2012-02-14 Thread WgpShashank
/pages/Cracking-The-Code/148241881919895 Google+ http://gplus.to/wgpshashank Twitter https://twitter.com/wgpshashankhttps://twitter.com/#%21/wgpshashank Puzzled Guy @ http://ashutosh7s.blogspot.com** **FB Page http://www.facebook.com/Puzzles.For.Puzzled.Minds* . -- You received this message because

[algogeeks] Re: Find all longest increasing subsequence of length k

2012-02-08 Thread WgpShashank
@atul , its application of LIS LCS problem , isn't it ? Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/x2c4hvfZCuUJ. To post to this

[algogeeks] Re: Java Tree Datastructure

2012-02-07 Thread WgpShashank
@DT Use BFS (Queue) , try it. -- *Thanks Shashank Mani Narayan Computer Science Engineering Birla Institute of Technology,Mesra ** Founder Cracking The Code Lab http://shashank7s.blogspot.com/* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

[algogeeks] Re: In a char string, find min distance between 2 letters, O(n) time, O(1) space.

2012-02-05 Thread WgpShashank
@ashsih ..here is algo 1st Traverse array from left side and stop if either *a* or *b *are found. Store index of this first occurrence in a variable say first then Now traverse *array *after the index *first*. If the element at current index *i* matches with either x or y then check if it is

Re: [algogeeks] nyone having pointer in c ebook..plz mail me...

2012-02-05 Thread WgpShashank
@Saurabh People Can Ask for Free Materials until it violates copyright law , if someone has they can help each other through personal mail, there is nothing wrong in this . *Thanks Shashank Mani Narayan Computer Science Engineering Birla Institute of Technology,Mesra ** Founder Cracking

[algogeeks] Re: Spoj ABCPATH

2012-02-05 Thread WgpShashank
@trinity tell the link of problem ? *Thanks Shashank Mani Narayan Computer Science Engineering Birla Institute of Technology,Mesra ** Founder Cracking The Code Lab http://shashank7s.blogspot.com/* -- You received this message because you are subscribed to the Google Groups Algorithm

[algogeeks] Re: Disjoint Set data structure

2012-02-05 Thread WgpShashank
@Karthik ..You Can Look http://en.wikipedia.org/wiki/Ackermann_function#Inverse *Thanks Shashank Mani Narayan Computer Science Engineering Birla Institute of Technology,Mesra ** Founder Cracking The Code Lab http://shashank7s.blogspot.com/* -- You received this message because you are

[algogeeks] Re: spell check

2012-02-05 Thread WgpShashank
@ravi .. why don't try with TRIE -- *Thanks Shashank Mani Narayan Computer Science Engineering Birla Institute of Technology,Mesra ** Founder Cracking The Code Lab http://shashank7s.blogspot.com/* -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] Re: In a char string, find min distance between 2 letters, O(n) time, O(1) space.

2012-02-05 Thread WgpShashank
@harsahl that won't work in duplicate case :) @ashish ..my will produce correct result , no need of using extra variable here is main function i am talking about int minDist(char arr[], int n, char x, char y) { int i = 0; int min_dist = INT_MAX; int first; // Find the first

[algogeeks] Re: Director Round MS Google

2012-02-02 Thread WgpShashank
@ashish ..R U perparing for this :) :D :) Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/o6zWz6mrB3sJ. To post to this group, send email

Re: [algogeeks] Lets Discuss About Some More Practical Application of Data Structure Algorithm , Problem Solving - How You WIll The Mutual Friends Between each m*n friends

2012-01-25 Thread WgpShashank
@Mani Good Analysis .. SO in that case if there more then one path exist we wants to to find path of maximum length , because we wants to show maximum friends which are mutual between A D , isn't it makes clear . so till we have only discussed about the designing part some approaches ,,not

Re: [algogeeks] vertical level sum in Binary tree

2012-01-24 Thread WgpShashank
@all , i think linked list will be the best data structure for this. isn't it ? Thanks Shashank Mani CSE,BIT Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] Re: Generate all possible binary trees given in-order traversal

2012-01-24 Thread WgpShashank
@Lucifier . Hope u studied from Wiki Check it http://en.wikipedia.org/wiki/Catalan_number#Applications_in_combinatorics Correct me if i am missing something ? Thanks Shashank Mani -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view

[algogeeks] Re: Generate all possible binary trees given in-order traversal

2012-01-23 Thread WgpShashank
@Lucifier Catelan NUmber will gives Number of *Full binary Trees* not BInary Tree ? isn't it ? Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] Lets Discuss About Some More Practical Application of Data Structure Algorithm , Problem Solving - How You WIll The Mutual Friends Between each m*n friends

2012-01-22 Thread WgpShashank
@Ayush . But as discussed BFS will not efficient solution for this isn't it ? u can easily visualize it ? Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] Lets Discuss About Some More Practical Application of Data Structure Algorithm , Problem Solving - How You WIll The Mutual Friends Between each m*n friends

2012-01-19 Thread WgpShashank
@Ayush ..Mutual Friends Means common friends between you person you are viewing profile . e.g. Mutual friends are the people who are friends with both you and the person whose profile you are viewing. For instance, if you are friends with shashank, and Mark is friends with Shashank, then

[algogeeks] Re: SUFFIX TREE

2012-01-19 Thread WgpShashank
@Utkarsh , Hope It Help http://shashank7s.blogspot.com/2011/09/get-rid-off-suffix-tree-online.html Thanks Shashank Mani CSE, BIT Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] Lets Discuss About Some More Practical Application of Data Structure Algorithm , Problem Solving - How You WIll The Mutual Friends Between each m*n friends

2012-01-18 Thread WgpShashank
I Know Some of We are aware of the same, but i wants to discuss all possible approach to solve the problem , then follow ups comes . Thanks Shashank Mani Narayan Computer Science BIrla Institute of Technology Mesra -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Lets Discuss About Some More Practical Application of Data Structure Algorithm , Problem Solving - How You WIll The Mutual Friends Between each m*n friends

2012-01-18 Thread WgpShashank
@atul .. yeah bfs may not work or less efficient . ..assume graph of m*n nodes , m,n are very large .. one simple thing we can do find the path between any given two nodes i,j , if path exist list out all the nodes we encounter , one imprtant thinsg to be noticed is that , path can be of 1

[algogeeks] Re: check Similar array

2012-01-17 Thread WgpShashank
@sravan . u missed man ..read again what i said , u r calculating 3^a[i] , where is 3 comes in to picture , no array has has 3 ?? correct , its should be 2^a[i] , then we search 2 in 2nd array if found 2 the go ahead, read the algo suggested above , its should work . let me know whats your

Re: [algogeeks] Re: sqrt function...

2012-01-17 Thread WgpShashank
@all Using Newton's method as described above, the time complexity of calculating a root of a function f(x) with n-digit precision, provided that a good initial approximation is known, is O((\log n) F(n)) where F(n) is the cost of calculating f(x)/f'(x)\, with n-digit precision. However,

Re: [algogeeks] Re: check Similar array

2012-01-17 Thread WgpShashank
@atul.. let me tell you ., i told that we can send u took two array arr[]={2,0,0,0} arr2[]={2,-2,1,0}; take 2 as a base in 1st array , calculate sum (exclduing 2 ), calculate base^arr[i] that gives sum1= 3 sorting not allowed , just search linearly 2 in 2nd array e.g. search the same

[algogeeks] Re: data structures for text editor

2012-01-16 Thread WgpShashank
check rope for wiki . Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/HXhD39wH1D0J. To post to this group, send email to

[algogeeks] Re: check Similar array

2012-01-09 Thread WgpShashank
@sravan i didn't get how my approach will fail , can u check for the exmple u said ? if u sum the 1st array using 2 as base then sum will be 3 (exculding 2 , although it won't metter ) , then u search that elemnt in 2nd array , u won;t find u return -1 , say these array are not similer .

[algogeeks] Re: check Similar array

2012-01-05 Thread WgpShashank
1st of all Happy New Year to All :) Must be both have same length also test some other test cases, :) Let me share things striking in mind , if you calculate the sum of power of 1st array by taking any number as base , remaining all the numbers as exponent so if take 3 as base calculate

[algogeeks] Re: Find the path in two nodes of a binary search tree

2012-01-05 Thread WgpShashank
@top coder , if its given that that you have to nodes as input , 1st find the two nodes , store their address then do any traversal to get the path between them , inorder will good . i ams assuming you wants to print the path between two such nodes. hope it suffices :) let me know if approach

[algogeeks] Re: Best way to rank sentences based on similarity from a set of Documents

2012-01-05 Thread WgpShashank
HI Anantha , I had similer discussion long time back , although its not full final but similer ,i hope it will gives you some idea . http://www.linkedin.com/groups/Detecting-Duplicate-Documents-1210167%2ES%2E55684470?qid=eb015784-36a3-498d-8441-558ace3b4038trk=group_items_see_more-0-b-ttl

[algogeeks] Re: Find even length palindrome.

2012-01-05 Thread WgpShashank
@atul , its should be the either 1st even length palindrome or largest even length palindrome in question , so here we go while making problem more generic ,* given a string find the largest palindrome in that string * So As I Coded it Some Times Back , Have a Look

Re: [algogeeks] Re: Find even length palindrome.

2012-01-05 Thread WgpShashank
you can use Suffix Tree for more better efficiency Thanks Shashank Mani Computer Science Birla Institute of Technology,Mesra *http://shashank7s.blogspot.com* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the

[algogeeks] Re: finding all combination

2012-01-05 Thread WgpShashank
@atul ,FYI, another naive approach will to generate the all subset of given set , thats the power set , has complexity O(n*2^n) , obviously not better then upper one , but still you can try to figure out the sum problem , you will get some relation to DP. Thanks Shashank Mani Computer

Re: [algogeeks] Re: Find the path in two nodes of a binary search tree

2012-01-05 Thread WgpShashank
@atul ,, why it won;t work , any clarification ? Thanks Shashank Mani Computer Science Birla Institute of Technology,Mesra *http://shashank7s.blogspot.com* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web

Re: [algogeeks] Re: check Similar array

2012-01-05 Thread WgpShashank
@atul..no need to sorting , complexity will be O(nlogn) only , sorting makes searching easy so said to sort , u can linearly search that elemnt in 2nd array it will take O(m) in above case . finally complexity will be O(nlogn) only Let me know if anything wrong or missed something ? Thanks

[algogeeks] Re: A graph problem

2012-01-05 Thread WgpShashank
@Saurabh DFS Should Work Here, Start from any room i , visit next room connected to it .. then to this room so on , once you back track you will back to the starting node ,this way you can find out .min.umber of room he need to visit will be 2 times of traversal isn't it ? posting the

[algogeeks] Re: Reverse n-Ary Tree and Return List of Leaf Nodes as Output - FYI Google MV

2011-12-21 Thread WgpShashank
@all just a small bug found after discussing with one of the friend , i forgot to put the for loop , in 2nd if condition . Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] Re: Kth element of the Increasing Sequence

2011-12-21 Thread WgpShashank
@Samm, Don't you think quadratic approach will be naive ? we can use comparator while checking .thining how we can do it more better ? Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] suggest algo

2011-12-21 Thread WgpShashank
@atul approach sounds good but we have to check for each time counts updated isn't it , though even can sort the hash table return top k number . also as i know we have splay tree , even google uses it , to get most frequent item . Thanks Shashank. -- You received this message because

[algogeeks] Reverse n-Ary Tree and Return List of Leaf Nodes as Output - FYI Google MV

2011-12-20 Thread WgpShashank
Hey Guys , whats do u think the to solve the problem ? my thinking to use recursion or stack , i tried but i think its not correct has lot of bugs ,, let me know some modification or your pseudo code ? Tree will be like 1 /|

[algogeeks] Re: Reverse n-Ary Tree and Return List of Leaf Nodes as Output - FYI Google MV

2011-12-20 Thread WgpShashank
here is my code ListNode list=new LinkeListNode(); public ListNode reverseTreeandReturnListContainingAllLeafNOdes(Node n) { int i=0; static int j=0; if(n==null) { n=n.children[++j]; return null; }

Re: [algogeeks] Re: Reverse n-Ary Tree and Return List of Leaf Nodes as Output - FYI Google MV

2011-12-20 Thread WgpShashank
@Ankur , we need to reverse the pointer for each node so that points to their parents. thats what reversal a n-Ary tree means hope it help . have a look at my code , its just thought i approached using preorder traversal , but not getting correct answer , seems like missing something

[algogeeks] Re: Reverse n-Ary Tree and Return List of Leaf Nodes as Output - FYI Google MV

2011-12-20 Thread WgpShashank
@all Reversing the N-ary tree means reversing the pointer nodes pointing to , as i shown above , children back points to their parents .. here is is structure of N-Ary Tree we can think of Class Node { String label; ListNode children; } you can try in any language C/C++/java etc. Thanks

Re: [algogeeks] Re: Reverse n-Ary Tree and Return List of Leaf Nodes as Output - FYI Google MV

2011-12-20 Thread WgpShashank
@atul,, yeah , but can you write some proper psuedo code/ Algorithm then we can discus more about test cases. Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] correctness of point inside polygon: algorithm ?

2011-12-18 Thread WgpShashank
Would anyone will interested to discuss ? Algo is simple but i am wondering about correctness of http://en.wikipedia.org/wiki/Point_in_polygon algorithm ? Thanks Shashank CSE, BIT Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

[algogeeks] Re: given a stream of numbers FIND MEDIAN

2011-12-18 Thread WgpShashank
@lucifier thought to post the same post , saw the post little bit late . though other approaches exist ,its the most efficient till we have. nice job :) Thanks Shashank CSE, BIT Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view

Re: [algogeeks] Re: Suggest Algo for this Question

2011-12-15 Thread WgpShashank
@sunny why we look at all k number which are greater then x , correct ? Lets think in this way we wants to check if kth smallest element in heap thats =x isn't it ? so if root of mean heap is greater then x then none other elements will less then x so we terminate . else our algorithm will

Re: [algogeeks] Re: doubt in TSUM

2011-12-15 Thread WgpShashank
@anubhaw ..its like spoon feeding , never mind u could have googled it :D http://www.google.co.in/search?q=3+sumie=utf-8oe=utf-8aq=trls=org.mozilla:en-US:officialclient=firefox-a Thanks Shashank Mani CSE, BIT Mesra http://shashank7s.blogspot.com/ -- You received this message because you are

[algogeeks] Re: find numbers if pair wise sums are given

2011-12-14 Thread WgpShashank
@all , a Naive Approach with Quadratic Time will be for each i=1 to n , check if i and a[i]-i makes given sum , so for each each number we will do the thus can achieve the solution ...i am just thinking about if we can do it linear time ..will post if able to do it :) Thanks Shashank CSe BIT

Re: [algogeeks] Re: Suggest Algo for this Question

2011-12-14 Thread WgpShashank
@sunny it will 3k not 2k ? u forgot to count the root element so over all time complexity will O(3K)=O(K) correct me if am wrong ? Thanks Shashank Mani CSE, BIT Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion

Re: [algogeeks] Re: Suggest Algo for this Question

2011-12-14 Thread WgpShashank
more clarification , why number of comparisons are 3k , because we are looking for only those nodes which are less then x and each nodea can max 2 childs , so tottal 3k comparisons . so it will O(3K) . Thanks Shashank CSE , BIT Mesra -- You received this message because you are subscribed

[algogeeks] Re: doubt in TSUM

2011-12-14 Thread WgpShashank
@anubhaw ..check wiki for O(N^2) algorithm ..u will get the logic Thanks Shashank Mani CSE , BIT Mesra http://shashank7s.blogspot.com/ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] Re: Dynamic programming question

2011-12-14 Thread WgpShashank
@Azhar , 1st Try to formulate the recursive relation , then draw recursive tree , then u willl know why it need DP to solve efficiently , then u can memozation to solve the same . Hope it help. Thanks Shashank Mani CSE ,BIT Mesra http://shashank7s.blogspot.com/ -- You received this

[algogeeks] Re: Dynamic programming question

2011-12-14 Thread WgpShashank
@Azhar , also for 1st question u r trying Array DS will suffices. Its Standard Coin Change Problem , u need to solve subproblem 1st , store it in extra array to avoid recalculation , if u are able to produce the sum less given sum then u can use same approach to reach desired sum . it uses the

Re: [algogeeks] A binary tree question

2011-12-11 Thread WgpShashank
@atul zig-zag mean spiral traversal of tree e.g. alternate the level while traversing , if previous traversal is left to right , then next level will be right to left . @aman .quest has little ambiguity its says successor but ebvery nodes can have we can ore-order , inorder ,postorder

[algogeeks] Re: Maximal possible subsets Algorithm

2011-12-05 Thread WgpShashank
efficiently ? correct if is missed anything ? Thanks Shashank Computer Science BIT Mesra http://www.facebook.com/wgpshashank http://shashank7s.blogspot.com/ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] Re: Number Theory (Power of 3 )

2011-12-05 Thread WgpShashank
Mesra http://www.facebook.com/wgpshashank http://shashank7s.blogspot.com/ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/jhoet1Yl3F0J. To post to this group

[algogeeks] Re: Removing Duplicates In array and Linked list

2011-12-04 Thread WgpShashank
@kumar ,dave .. there is ony one way to do it if numbers are in range , otherwise its not possible yo remove the duplicates from both array linkedlist which are unsorted ? what's u say ? Thanks Shashank Computer Science, BIT Mesra -- You received this message because you are subscribed to

[algogeeks] Re: Convert N-Ary Tree to Singly Linked List

2011-11-01 Thread WgpShashank
Let me know if Anyone Has Other Approach/Algo/Code to Solve the same or any bug in my code ?? Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] Convert N-Ary Tree to Singly Linked List

2011-10-31 Thread WgpShashank
structure of n-ary tree Class:Node String:label ListNode children Method ListNode TreeToLinkedList(Node n) { return list; } return List of all nodes; [image: image.png]Pics Taken From Google Image . N-Ary Tree Output head-

Re: [algogeeks] Re: What Data Structure to use ?

2011-10-31 Thread WgpShashank
@Mohit Space Overhead Will be more if m,n are large isn't it ? Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/Z9zOwDig0mMJ. To post to this

[algogeeks] Re: Minimize bins

2011-10-31 Thread WgpShashank
Search For Bin Packing Problem on Wiki . Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/qM4k1vJneRoJ. To post to this group, send email

Re: [algogeeks] Microsoft Question

2011-10-31 Thread WgpShashank
@Anup You Seems to Active Member , u remembered that :) +1 to You. Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/qRJslcZjhboJ. To post to

[algogeeks] Re: What Data Structure to use ?

2011-10-30 Thread WgpShashank
We Will Use Closed Addressing or Open hashing based approach which called saperate chaining and i think it will be sufficient solve it .isn't it Here is Approach. Let we have m students n course . Each student course have unique ID identified by it as well.we can use Associate data

Re: [algogeeks] Re: finding anagrams in file

2011-10-19 Thread WgpShashank
@Marcelo all , Yes it will be definitely O(nmlogm) . Thanks Shashank CSE,BIT Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/aP1bCH0v_nYJ. To post to

[algogeeks] Re: Please Mention Your Info. Name/Collage/Country and Reason for Joining Algogeek to Minimize Spamming

2011-10-18 Thread WgpShashank
@all Its Obvious ,I Didn't tell for old users or active members , i said for who are joining or joined recently , so that we can detect easily who is posting off topic :) Anyways It Was Just Message , Thread Will be Closed :) Thanks Shashank CSE,BIT Mesra -- You received this message

[algogeeks] Re: finding anagrams in file

2011-10-18 Thread WgpShashank
Sort the all the string , Calculate hash-value , if the two has same hash vale they have to be anagram. put in group on the basis of anagram. leme know if i missed anything ? TC O(nlogm) n =number of words m is length of max string Shashank CSE,BIT Mesra -- You received this message because

Re: [algogeeks] print vertical sums of a binary tree

2011-10-18 Thread WgpShashank
@Ankur NO Need of Two Array , Only One will be Suffice :) Just Initialized array with 0 for all nodes initiallly Thanks Shashank CSE,BIT Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] Amazon Question - Find Pythagorean triplet in an unsorted array

2011-10-17 Thread WgpShashank
@wladimir , its PPT (Pythagoras triplets ) but its number theory based approach http://en.wikipedia.org/wiki/Pythagorean_triple might not be good idea Here is approach : * * *Euclid's formula*[1]http://en.wikipedia.org/wiki/Pythagorean_triple#cite_note-0 is a fundamental formula for

[algogeeks] Please Mention Your Info. Name/Collage/Country and Reason for Joining Algogeek to Minimize Spamming

2011-10-17 Thread WgpShashank
Hey Guys , to Minimize Spamming Maintaining Quality of Group we Need Support from You. Please Mind Above Message. Happy Learning :) Thanks Team Algogeek -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the

Re: [algogeeks] Re: Adobe

2011-10-15 Thread WgpShashank
@Rahul, We Are Working On It Will Try to Eliminate the people if found they are doing same thing again FYI:Google Docs is not Under Our Control, We Can't Implement our algorithm to filter out interview related thread to other group, if it would have been possible we just need to write small

Re: [algogeeks] Re: Inplace Array Convertion

2011-10-15 Thread WgpShashank
@Anika , You Already Have Permission to Post All Algorithms Realted Questions/Queries Thanks Shashank CSE,BIT Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] Re: Adobe

2011-10-14 Thread WgpShashank
@All Join Interview-Street Group For Detailed Discussion About Interview Process of Particular Company , if You Have particular question wants to discuss here , put that directly , All Interview Related Task Now Shifted Interview-Street Group until Whole Thing is Done , You Can Search The

[algogeeks] Re: amazon ques

2011-10-01 Thread WgpShashank
@All Why don't try with combination of* hash-table Array* , It Will Work , try it out :P Thanks Shashank Mani CSE, BIT Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] Re: You have given a number N. You need to find out total number of set bits from 0 to N.

2011-09-11 Thread WgpShashank
Hope it will Help http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel You will Foun How it Can be done in O(1) Thanks Shashank Mani Narayan Computer Science Birla Institute of Technology,Mesra -- You received this message because you are subscribed to the Google Groups

[algogeeks] Re: ACM

2011-09-09 Thread WgpShashank
Yes It Will Great to Discuss Such Probs Here ::) Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/PEgb5PWqS0cJ. To post to this group, send

[algogeeks] Re: subarray wid sum=k

2011-09-02 Thread WgpShashank
I Think We can Use HashTable , as Its Sub-Array you are asking about , its obviously contiguous :D Calculate prefix sum , store it in hashtable as key current index as value , once prefix sum=k, print subarray , also keep track of prev index , so that we can print array from prev_i9ndex to

[algogeeks] Re: Adding Two no without using any operator...??

2011-09-02 Thread WgpShashank
Discussed Several time , Search Threads here is one of the link https://groups.google.com/forum/#!searchin/algogeeks/add$20two$20number$20/algogeeks/laWTN1xiwx0/lYoidUsr7mIJ Thanks Shashank Mani Computer Science Birla Institute of Technology Mesra -- You received this message because you

Re: [algogeeks] convert a string into another in minimum number of steps

2011-09-02 Thread WgpShashank
Yes Edit Distance is Most Efficient Algorithms Implemented So far and we all know this :P , but Sukran is saying Trie ? seems odd initially but let me analyze it ,Seems Good to me but we need to store length of strings in advance so that while inserting in trie wherever 1st mismatch occurs ,

Re: [algogeeks] Find the Max from each sub-array of size k

2011-09-02 Thread WgpShashank
Hi Anup , here is naive approach There is a sliding window of size w which is moving from the very left of the array to the very right. You can only see the w numbers in the window. Each time the sliding window moves rightwards by one position. Following is an example: The array is [1 3 -1

[algogeeks] Re: Find Max Sum Value Pairs

2011-09-02 Thread WgpShashank
@Dave Correct , Missed to Provide the Correct Time Complexity in Worst Case it Will be O(N^2) , as we need to find out n such maximum pair , will think about O(N0) Algo, if able to do it, will post the Algo here Thanks Shashank Mani Computer Science Birla Institute of Technology,Mesra --

[algogeeks] Re: Need algorithm asap

2011-09-02 Thread WgpShashank
Piyush Has Correct Idea, If You Have N elements in Set/Array You Will Have Maximum 2^n Subsets (Power Set), Now Problem Reduced to generate the all such subsets , it will take O(2^n*n ) time , Now number of Valid Bipartitions are exactly n/2 . Note: Power Set includes 0 as well Correct me

Re: [algogeeks] Re: subarray wid sum=k

2011-09-02 Thread WgpShashank
@bharat , I never Said that subarray can't start from middle or have to start from 0th index :) Shashank Mani Computer Science Birla Institute of Technology,Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on

Re: [algogeeks] Re: subarray wid sum=k

2011-09-02 Thread WgpShashank
Yes Neha, I Never Said That SubArray has to be Started from 0th index,else What Will be the advantage of this saying subarray anyways, here O(N) time O(N) space solution int prefix_sum = 0; hash_mapint,int find_subarray; int start_index = -1, end_index = -1; for (int i = 0,;i n;

[algogeeks] Re: There is an array and the distance between any two consequent elements is one(+1 or -1) and given a number. You have to check whether the number is in array or not with minimum complex

2011-08-31 Thread WgpShashank
Complexity Can't be reduced only number of comparisons can be reduced e.g. we can only jump either left or right from current position depending upon distance between current desired element but worst case will be O(N) as Dave explained :) Shashank Computer Science Birla Institute of

[algogeeks] Re: matrix finding immediate neighour

2011-08-25 Thread WgpShashank
If i got the question correct then its Simple Straightforward, We need to Check All neighbors, With Boundary conditions public static ListInteger findLocalMaxima(Integer a[][]) { ListInteger locals = new ArrayListInteger(); int row=a.length; for (int i = 0; i row;i++) { int

[algogeeks] Re: calculate a/b without using ‘*’, ‘/’’ and ‘%’

2011-08-25 Thread WgpShashank
@Dave Yup, but Overall Complexity Will remain O(log(Quotient)) as y=logn^k=klogn=O(logn) where k is constant isn't it ? Also case of -Ive Numbers Can be handled easily :) *Thanks Shashank Mani Computer Science Birla Institute of Technology Mesra* -- You received this message because you

[algogeeks] An Interesting DP Question

2011-08-25 Thread WgpShashank
*Hey Geeks, Sharing an Interesting Question here Given an array of integers (+ive,-ive 0 as well) , you have to tell number of ways you can select longest increasing sub-sequences of size k where k=n(size of array) from that array , also print those sub-sequences. * example 1 4 6 2 5 k=3

[algogeeks] Another DP Question on String Palindrom

2011-08-25 Thread WgpShashank
Given a string, and split it into as few strings as possible such that each string is a palindrome.Example ABAABABA Greedy algorithm: ABAABA + B + A = 3 palindromes Correct answer: ABA + ABABA = 2 palindromes so one thing sure Greedy Wont Works here , so it sounds perfect DP problem ? Thanks

[algogeeks] Re: vertical sum

2011-08-25 Thread WgpShashank
Hi Nikhil, have a Look let me know if anything missed or any better way to make it efficient ? http://shashank7s.blogspot.com/2011/02/wap-to-findout-vrtical-sum-of-nodes.html Thanks Shashank Mani Computer Science Birla Institute of Technology Mesra -- You received this message because you

[algogeeks] Re: Adobe Interview - 20/08/2011

2011-08-25 Thread WgpShashank
@Diye True :) Shashank CSE,BIT Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/O_KMuq1YK_0J. To post to this group, send email to

[algogeeks] Re: calculate a/b without using ‘*’, ‘/’’ and ‘%’

2011-08-25 Thread WgpShashank
@Dave True :) *Thanks Shashank Mani Computer Science Birla Institute of Technology Mesra* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/mSeEd-_wRcMJ.

Re: [algogeeks] Re: matrix finding immediate neighour

2011-08-25 Thread WgpShashank
@Sharvan ..Yes We Can do That and yes i forgot that intead of locals.add(a[i][j]) , we need tow write locals.add(i+j) Hope its fine now :) *Thanks Shashank Mani Computer Science Birla Institute of Technology Mesra* -- You received this message because you are subscribed to the Google

[algogeeks] Re: finding string in matrix grid

2011-08-25 Thread WgpShashank
An Simple Algorithm Can be use Matrix or Graph (BFS Will Work) , We Need to Visualize the problem :) This Problem is similar to finding neighbor solution that i posted the matrix-local maxima problem Problem Solving Apparoach we start matching from the first element; if it matched we matched

[algogeeks] Re: calculate a/b without using ‘*’, ‘/’’ and ‘%’

2011-08-23 Thread WgpShashank
@Dave , You are right , i mean to say we reduce the number of instruction or comparisons executed by the program. ,Never Mind here is recursive code for doing the same , Algorithm is already explained #includeiostream using namespace std; int dividend,divisor,remainder; int division(int

[algogeeks] Re: amazon q

2011-08-22 Thread WgpShashank
Only Balanced BST (its guaranteed that we can search element in o(logn) , i am assuming its maxheap .In a max heap, the smallest element is always present at a leaf node. So we need to check for all leaf nodes for the minimum value. Worst case complexity will be O(n) 12 / \ / \ 8 7 / \ / \

[algogeeks] Re: Longest palindrome

2011-08-22 Thread WgpShashank
Hey Geeks I think question can be solved by many ways . some of the algorithms are i have implemented aware of are - 1st. Algo Generate all palindromes (even odd length ) of given string while keep tracking of their length in last just compare max (evenlength_palindrome ,

Re: [algogeeks] Re: calculate a/b without using ‘*’, ‘/’’ and ‘%’

2011-08-20 Thread WgpShashank
@Lucky sorry for delay, I am saying compelxity will be number if bits required to represent quioutent , i think you just try with exmple i have given @Dave I didn't See The Whole Code but i think Logic Will Remain The Same.i Think You forgot to give algorithm :P also we can reduce the line of

[algogeeks] Re: longest repeated substring

2011-08-19 Thread WgpShashank
Hi Mac, Problem Have Discussed Several Time across various forums ,here one of the possible solution using Suffix Array in O(N^2) http://shashank7s.blogspot.com/2011/06/longest-repeated-substring-eg-maximum.html Hope it will be helpful, let me know for if any test case its not working or any

[algogeeks] Re: calculate a/b without using ‘*’, ‘/’’ and ‘%’

2011-08-19 Thread WgpShashank
We can use bit logic to reduce the time complexity to O(logn) where n is Quotient Algorithm will be as follow as we know 1. Left shifting an unsigned number by 1 multiplies that number by 2. 2. Right shifting an unsigned number by 1 divides that number by 2. Therefore the procedure for the

[algogeeks] Re: Question from Google interview

2011-08-19 Thread WgpShashank
I Think Trie is suitable DS for this problem , its similar Did You Mean Feature of Google Paste it in ur address bar

[algogeeks] Re: |a-b| + |b-c| + |c-a|

2011-08-18 Thread WgpShashank
Hey Mac, Coded it Sometimes back , Have a Look(i know its naive way :D) so let me know if anything wrong , we can use Min-Heap to make solution efficient isn't it ? http://shashank7s.blogspot.com/2011/06/given-3-arrays-pick-3-nos-one-from-each.html Thanks Shashank Mani Computer Science

  1   2   >