@naveen :read the his doubt properly...he was expecting 5 10 15 but was
getting 8 32 96...and dats the correction required which i made
On Fri, Jun 8, 2012 at 8:08 AM, Navin Kumar algorithm.i...@gmail.comwrote:
@Mahendra: for ur above code with t=(a2)+a o/p will be 5,10, 15 as i
explained
You don't need to use BigNum or long int for this program.
Both n k should be less than 1000.
Since there is no restriction on k,you don't need Bignum
Since both n,k are restricted,you don't need bignum.
if n5, simply reject the input and return false
On Fri, Jun 8, 2012 at 11:01 AM, Dave
Ignore the last post.
Updated:
You don't need to use BigNum or long int for this program.
Both n k should be less than 1000.
you need bignum only if there would be no restriction on k.
Since both n,k are restricted, you don't need bignum.
if n5( 5^5 1000), simply reject the input and return
Things like sensor data coming from CAN/MoST from the car is collected and
analysed in real time to avoid collisions, off-lane movement, distance
maintenance, auto parking(including parallel), slippage on road/snow, GPS
integration for perfect location and location specific data (like
#include stdafx.h
#include iostream
using namespace std;
const int len = 20;
const int maxCount = 127;
int rle(char* pStr, int length, char* pNew) {
if (!pStr) return -1;
if (length 3) return -1;
int i = 0;
int k = 0;
char p1 = pStr[i++];
char p2 = pStr[i++];
char p3 = pStr[i++];
int pos=0;
@sengar: sorry dude...i got his doubt.Though my explanation was correct. I
think now everybody's doubt is clear.By the way thanx for correcting me.
On Fri, Jun 8, 2012 at 11:48 AM, sengar.mahi sengar.m...@gmail.com wrote:
@naveen :read the his doubt properly...he was expecting 5 10 15 but was
Hi,
I came across Data Structures and Algorithms Made Easy: Data Structure and
Algorithmic Puzzles
Request for feedback if it is worth purchase.
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
--
You received this message because you are subscribed
Its a book worth have.
On Fri, Jun 8, 2012 at 1:44 PM, Ashish Goel ashg...@gmail.com wrote:
Hi,
I came across Data Structures and Algorithms Made Easy: Data Structure and
Algorithmic Puzzles
Request for feedback if it is worth purchase.
Best Regards
Ashish Goel
Think positive and
how can we find 1st repeating character in string???
e.g. if the string is abba it should return 'b' and not 'a'.
note: hashing will give the answer as 'a'
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
you will have to note time for of occurence of a character for all chars
On Fri, Jun 8, 2012 at 2:15 PM, himanshu kansal himanshukansal...@gmail.com
wrote:
how can we find 1st repeating character in string???
e.g. if the string is abba it should return 'b' and not 'a'.
note: hashing
howcome hashing will result in wrong output..??
if(isHashed(str[i])
{
character found.
break.
}
else
hash(str[i]);
On Fri, Jun 8, 2012 at 2:15 PM, himanshu kansal himanshukansal...@gmail.com
wrote:
how can we find 1st repeating character in string???
e.g. if the string is abba
anybody having the ebook ?
On Friday, 8 June 2012 13:44:18 UTC+5:30, ashgoel wrote:
Hi,
I came across Data Structures and Algorithms Made Easy: Data Structure
and Algorithmic Puzzles
Request for feedback if it is worth purchase.
Best Regards
Ashish Goel
Think positive and find fuel
This is MS Q and hasing will give the right answer. walk over the string,
if it is present in hashTable, it is first repeated character. This is
single pass.
However, if you do another pass, your answer would be a which is first
char that is repeated whereas b is first character to occur first
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Fri, Jun 8, 2012 at 12:54 PM, Ashish Goel ashg...@gmail.com wrote:
#include stdafx.h
#include iostream
using namespace std;
const int len = 20;
const int maxCount = 127;
int rle(char* pStr,
But you can use unordered map something like what boost does ..
http://boost.cowic.de/rc/pdf/unordered.pdf
Cheers.
On Friday, June 8, 2012 5:38:56 PM UTC+8, ashgoel wrote:
This is MS Q and hasing will give the right answer. walk over the string,
if it is present in hashTable, it is first
Using Spiral-Anderson rule,
1:- const char * a - a is a pointer to char const (character which is
constant , the value pointed by the pointer is constant)
2:- char * const a - a is a const pointer to char (pointer is constant, it
always point to same memory location)
3:- char const * a - a is a
Its one of the best book.
If u r planning for some big jobs thn u should read this book
SDE 1
Amazon India development Center
On Fri, Jun 8, 2012 at 2:45 PM, Ramindar Singh ramin...@gmail.com wrote:
anybody having the ebook ?
On Friday, 8 June 2012 13:44:18 UTC+5:30, ashgoel wrote:
Hi,
@mehender exactly bro.
program --
#include stdio.h
#define PrintInt(expr) printf(%s : %d\n,#expr,(expr))
int FiveTimes(int a)
{
int t;
t = (a2) + a; // change - added parenthesis.
return t;
}
int main()
{
int a = 1, b = 2,c = 3;
In a string try to loop through all character and count the occurances
(incrementing by 1 whenever that character occurs)... store it in hash
(initialize the hash to 0)... when the count of any char equals 2 break
from the loop that char is first repeating char.
-- RK :)
On Fri, Jun 8, 2012 at
Use the below function, that will return first repeated character of
string or null;
Note: blank space is also consider as character... you can add exception to
avoid such case
char firstRepeatChar(char *str)
{
int arr[256] = {0};
for(int i = 0; str[i] != '\0'; i++)
{
arr[str[i]] +=1;
the output will be correct it will not be incorrect in hashing case .
On Fri, Jun 8, 2012 at 2:38 PM, atul anand atul.87fri...@gmail.com wrote:
howcome hashing will result in wrong output..??
if(isHashed(str[i])
{
character found.
break.
}
else
hash(str[i]);
On Fri, Jun
lets say we have an array COUNT[256] which is initialized to zero.
1) traverse the string S from 0 to length-1
2) if COUNT[S[i] - '0'] == 0 , increment COUNT[S[i] - '0'] = 1;
3) else print the first repeating character.
-Mahesh
On Fri, Jun 8, 2012 at 2:26 PM, Anika Jain
Hi,
I have been reading this book these days
Book have very nice collection of problems which are very much needed for
interview preparation.
This is for not for those who is expecting to learn basics.
On Fri, Jun 8, 2012 at 1:46 PM, rajesh singarapu rajesh0...@gmail.comwrote:
Its a book
you may use look up table for each character like this :
int table[255]={0};
for(int i=0;str[i];i++)
{
if( table[str[i]] )
return true;
else
{
table[str[i]]=1;
}
}
return false;
On Fri, Jun 8, 2012 at 2:26 PM, Anika Jain anika.jai...@gmail.com wrote:
you will have to note
Given a list of integers n, we have to find the length of largest
zigazg subsequence in the list i.e,zigzag subsequence is defined
as if the first number is increasing then the 2nd one should be
decreasing or vice versa..
for eg : if list[n]={1,10,5,9,8,12,20} then,
largest zigzag
The key doesn't lies in the way it will be solved.It is how efficiently you
implement the hash table.do we really need an integer array ( 4*256 bytes)
just to record the first occurrence of a character?
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com
On Fri,
no hashtable needed , a bitmap is sufficient
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Fri, Jun 8, 2012 at 4:04 PM, saurabh singh saurab...@gmail.com wrote:
The key doesn't lies in the way it will be solved.It is how efficiently
you
O(n) is straight forward
bool increase = true;
int j = 0;
result[j++]=a[0];
for (int i=1;in;i++)
{
if ((increase)
{
if (result[j-1]a[i]))
{
result[j++] = a[i];
increase = false;
}
}
else {
if (result[j-1] a[i]))
{
result[j++] = a[i];
increase =
Thats what the question is about to find the maximum subsequence.
i too tried your code with the sample 10,4,12,4,1,43,21,4,1,5,7,23,9
ur code gave the result 10 12 4 43 21 23;
but the correct optimized o/p should have been with length 7 as
4,12,1,43,21,23,9
On
we should use dp
On Fri, Jun 8, 2012 at 5:39 PM, Ratan success.rata...@gmail.com wrote:
Thats what the question is about to find the maximum subsequence.
i too tried your code with the sample 10,4,12,4,1,43,21,4,1,5,7,23,9
ur code gave the result 10 12 4 43 21
#includestdio.h
int main()
{
int Seq[100],i,j,n,Max,tmp;
int zzlen[100][2];
scanf(%d,n);
for(i = 0 ; i n ; i++) { scanf(%d,Seq[i]); zzlen[i][0] =
1;zzlen[i][1] = 0;}
Max = 1;
for(i = 1 ; i n ; i++)
{
for(j = i-1 ; j = 0 ; j--)
{
if(Seq[i]
order of hashing and counting is important
eg. abba
if we do hashing by characters 'a' is stored before 'b'
and count of both is 2 at the end and when we process this we give result
'a' (because 'a' comes before 'b' )which is wrong
because 'b' is the first repeated character.
Thanks Regards
@srikanth: can u frame out the recursive function for the solution
proposed in DP . i was actually finding difficulty in this..
On Fri, Jun 8, 2012 at 5:40 PM, srikanth reddy malipatel
srikk...@gmail.com wrote:
#includestdio.h
int main()
{
int Seq[100],i,j,n,Max,tmp;
int
Does anybody has its ebook ? Please upload it
--
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/-/AETPnqJps7AJ.
To post to this group, send email to
A sorted array of integers is rotated unknown times. find an item in
O(logn) time and O(1) space complexity.
for example : 1,2,3,7,10,14 ---rotated 3 times-- 7,10,14,1,2,3
find 2 in O(logn) time in O(1) space complexity
Regards
Hassan H. Monfared
--
You received this message because you
@Hassan: This is not possible without additional conditions. E.g., you
cannot find the 1 in the array {0,0,0,...,0,1,0,0,...,0} in less than O(n)
time.
But with the condition that the elements of the array are pairwise
distinct, you can use a binary search to find k such that a[k-1] a[0]
Yes,
Thanks Dave. for non-distinct items It's not possible.
On Fri, Jun 8, 2012 at 6:44 PM, Dave dave_and_da...@juno.com wrote:
@Hassan: This is not possible without additional conditions. E.g., you
cannot find the 1 in the array {0,0,0,...,0,1,0,0,...,0} in less than O(n)
time.
But with
@all: my bad...i ws confused while posting the ques.
hashing can gv either a or bonly thing tht matters is hw u implement
hashing and counting
thanx i hv got the soln
On Fri, Jun 8, 2012 at 4:33 PM, Saurabh Yadav saurabh...@gmail.com wrote:
order of hashing and counting is
is it possible to override struct definition in c
in header.h header file i have
eg
typedef struct a
{
int ab ;
}
nw in .c file i have included header.h
typedef struct a
{
char c ;
int b;
}
and giving following def i m getting an error ...
*'struct type redefinition'*
So anyways in c
More post:
http://marathoncode.blogspot.com.br/2012/06/qual-e-o-melhor-comentario-no-codigo.html
http://marathoncode.blogspot.com.br/2012/06/importancia-de-algoritmos-eficientes.html
http://marathoncode.blogspot.com.br/2012/06/um-professor-em-minha-vida.html
No.
In C++ you can't either. You can declare a new class that _extends_ a
previous one, but you can't change a declaration once it's complete.
On Jun 8, 11:38 am, HARSHIT PAHUJA hpahuja.mn...@gmail.com wrote:
is it possible to override struct definition in c
in header.h header file i
@saurabh: why would u count all??? just see while counting if the bitmap is
set.. then return the char.
On Fri, Jun 8, 2012 at 4:33 PM, Saurabh Yadav saurabh...@gmail.com wrote:
order of hashing and counting is important
eg. abba
if we do hashing by characters 'a' is stored before 'b'
and
It is easy.. find the point where it is rotated to get 14-1 O(log(n))
since 214 that means u have to find it in subarray [123].. do a binary
search here o(long(n))
final 2*O(log(n))...
On Fri, Jun 8, 2012 at 7:44 PM, Dave dave_and_da...@juno.com wrote:
@Hassan: This is not possible without
ya...hashing is rt method but, we have to implement it by using self
referential structure
i think ..stilll we can solve this problem by using arrayslike
int arr[256]={0};
int main()
{
char str[]=abba;
.
.
for(i=0;str[i]!=NULL;i++)
{
if(arr[(str[i]-'0')]==1)
{
printf(first
is it like this :
Ex:
rose
open
send
end
this is a rectangle having valid words.and available in dictionary
tooo...
On Wed, Jun 6, 2012 at 11:46 AM, Ashish Goel ashg...@gmail.com wrote:
Gene, you are right, the rectangle is valid if rotated by 90 degrees too.
Best Regards
Ashish
i was explaining the general idea which we generally use with hashing i.e.
hashing and counting the all the char and then find which is the repeated
character
yes u r correct , for the correct solution we should return when we found
bitmap set , which is the actual solution :)
On Fri, Jun 8,
If one wants to start with basics of Data Structures and Algorithms and
then move to advanced, how should one start with.
I mean, which books to read first so that one gets basics clear. And then
to move to advanced level, what more to do(like books to read,training in
USACO, practice in
47 matches
Mail list logo