there's a solution of O(log n) where 2D matrix has n rows and n columns.
Apply binary search for the search on the diagonal. when you are left with
just one element after the search apply binary search within that elements
row and its column. you will get the element. O(log n+log n+log n). so
Hello Dave,
Was trying this
bool OnesZerosOnes(unsigned int n)
{
if( !(n 1) || !(n = n+1) ) return 0; /*step1*/
n |= n-1;/*step 2*/
return !(n (n+1)); /*step 3*/
}
for 1110011
after step 1 it becomes 1110010100=111
after step2 it becomes 111|110=111(all ones)
got it...super...
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Thu, May 17, 2012 at 8:21 PM, Ashish Goel ashg...@gmail.com wrote:
Hello Dave,
Was trying this
bool OnesZerosOnes(unsigned int n)
{
if( !(n 1) || !(n = n+1) ) return
Usual data structures and algorithmic questions. They love the guys who can
do actual coding, instead of blurting it out in pseudo-codes, since its a
telephonic interview, I think its going to be different for you.
On Wed, May 16, 2012 at 6:37 PM, rishabh shukla rockrishabh.mn...@gmail.com
We can still improve this trie idea..
say we have urls like
www.google.com
www.goodbye.com
www.google.com/transliterate
www.goodstrain.com/good
we can subdivide everything under www.goo
I mean we can store each character as a node in a trie and call it
like a URL dictionary
On Wed, May 16,
@ pankaj joshi: Hi ... The following code will do it for you. Go through
the code, execute it, if u dont get the logic revert back to me.
// code begins..
#includestdio.h
#define MAX 1
void factorialof(int);
void multiply(int);
int length = 0;
int fact[MAX];
int main(){
int
For the cases where Storing the Value is the only Concern and (Not the
Retrieval efficiency), I would Suggest Something called DFA Subset
minimization.. Google for it ... and after the final subset as said U can
use something called DAWG for the most Most Optimal solution..
On Thu, May 17, 2012
It depends on which column you are pouring the water.
For example
If you choose the shortest column to pour the water then only that column
will be filled with water.
Please correct me if I am wrong.
On Thu, May 17, 2012 at 11:27 AM, Nikhil Agarwal
nikhil.bhoja...@gmail.comwrote:
Imagine that
hope this works..
http://ideone.com/XSJRJ
On Fri, May 18, 2012 at 8:20 AM, Bhaskar Kushwaha
bhaskar.kushwaha2...@gmail.com wrote:
It depends on which column you are pouring the water.
For example
If you choose the shortest column to pour the water then only that column
will be filled with
Hii Can anyone explain to me what this code is doing??
On 17 May 2012 20:36, Ashish Goel ashg...@gmail.com wrote:
got it...super...
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Thu, May 17, 2012 at 8:21 PM, Ashish Goel
On Sat, Apr 7, 2012 at 11:24 AM, Dave dave_and_da...@juno.com wrote:
@Ashgoel: Try this:
bool OnesZerosOnes(unsigned int n)
{
if( !(n 1) || !(n = n+1) ) return 0;
n |= n-1;
return !(n (n+1));
}
Here is how it works:
!(n 1) is true if the number has trailing zeros.
If
11 matches
Mail list logo