/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
/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
@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
@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
@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
@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
@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
@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
@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
@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
@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
@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
@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
@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
@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
@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
@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
@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
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
@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
@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
@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,
@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
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
@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 .
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
@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
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
@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
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
@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
@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
@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
@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
@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
@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
@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
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
/|
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;
}
@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
@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
@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
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
@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
@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
@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
@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
@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
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
@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
@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
@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
@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
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
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
@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
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
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-
@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
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
@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
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
@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
@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
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
@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
@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
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
@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
@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
@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
@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
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
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
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
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
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 ,
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
@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
--
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
@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
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;
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
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
@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
*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
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
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
@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
@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.
@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
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
@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
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
/ \ / \
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 ,
@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
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
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
I Think Trie is suitable DS for this problem , its similar Did You Mean
Feature of Google
Paste it in ur address bar
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 - 100 of 120 matches
Mail list logo