);
vc.push_back(2);
cout endl longest_sequence(vc);
return 0;
}
NIshant Pandey
Cell : 9911258345
Voice Mail : +91 124 451 2130
On Mon, Jan 27, 2014 at 4:29 PM, Amol Sharma amolsharm...@gmail.com wrote:
Given an array of positive numbers arranged in any order. You have to find
the length of longest
);
Permute(str,start+1,end);
swap(str,start,i);
}
}
}
int main()
{
char Str[]=aba;
Permute(Str,0,strlen(Str)-1);
return 0;
}
NIshant Pandey
Cell : 9911258345
Voice Mail : +91 124 451 2130
On Tue, Jan 7, 2014 at 4:44 PM, kumar raja rajkumar.cs...@gmail.com wrote:
This u
...@gmail.comwrote:
From StackOverflow,
---
fgets() can decode UTF-8 encoded files if you use Visual Studio 2005 and
up. Change your code like this:
infile = fopen(inname, r, ccs=UTF-8);
On Sat, Nov 23, 2013 at 8:25 PM, Nishant Pandey
nishant.bits.me...@gmail.com wrote
+ 2]; /* 2 Extra for \0 \n */
memset(buff,0,sizeof(buff));
/* fgets reads max one less than provided length so adding 1 */
while (NULL != fgets(buff,MAX_BUFF+1,fd))
printf(%d\n, non_ascii_count(buff));
return 0;
}
On Tue, Nov 26, 2013 at 7:43 PM, Nishant Pandey
nishant.bits.me
if you use Visual Studio 2005 and
up. Change your code like this:
infile = fopen(inname, r, ccs=UTF-8);
On Sat, Nov 23, 2013 at 8:25 PM, Nishant Pandey
nishant.bits.me...@gmail.com wrote:
Q) *C program* that reads multiple UTF-8 encoded strings from STDIN (1
string per line), count all *non
Q) *C program* that reads multiple UTF-8 encoded strings from STDIN (1
string per line), count all *non-ascii* characters (ascii characters are
with ordinal decimal 0 to 127) and print the total non-ascii character
count to STDOUT (1 number per line).
Contraint :
- You cannot use any
juat want to ask why the last region was not flipped from o to x?
On Tue, Jun 11, 2013 at 11:57 PM, Don dondod...@gmail.com wrote:
// Flip a region including location (x,y) from from to to.
// Returns true if region is surrounded.
bool flip(char board[][], int n, int x, int y, char from,
does that means displaying only boundary elements of tree and if yes in
which order ?
*My Answer* :
I think it would be something like doing preorder travesal of left subree
with boundary elements and leaf elements of left subtree + post order
traversal of right subtree with boundary element and
17:52, rohit jangid rohit.nsi...@gmail.com wrote:
you are doing it correct.
On Sat, May 25, 2013 at 5:37 PM, Nishant Pandey
nishant.bits.me...@gmail.com wrote:
I am not getting the y priority Q is getting used for this question, as
in case of P Queue, things are arranged as per
.
On Sun, May 26, 2013 at 9:36 AM, Ravi Ranjan ravi.cool2...@gmail.comwrote:
Rope
On Sat, May 25, 2013 at 10:24 PM, Nishant Pandey
nishant.bits.me...@gmail.com wrote:
In one of the interview it was asked, can some one suggest good DS for
this.
Thanks
--
You received this message
The solution could be given in this way.
1) In one pass get the end index of both array says e1 and e2.
2) now in next pass compare elements at e1 and e2 .
a) if a(e1) a(e2) swap the elements and then decreament e1 and e2 both.
b) if a(e1) a(e2) decreament e2.
c) if a(e1) == a(e2) then
@DOn can u explain ur first algo, it would be helpful.
On Wed, May 22, 2013 at 7:28 PM, Don dondod...@gmail.com wrote:
My program works with any numbers.
Don
On May 22, 3:45 am, Pramida Tumma pramida.tu...@gmail.com wrote:
This above program works only if the array contains consecutive
I am not getting the y priority Q is getting used for this question, as in
case of P Queue, things are arranged as per the priority so when we will
insert the data we can simply increament the priority.
Algo would be like this :
Enque(q, data) {
push(q, data, increrase the prioroty);
}
int
In one of the interview it was asked, can some one suggest good DS for this.
Thanks
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
I have a list of N teams T1, T2, T3 … Tn. Each of these teams has played a
match against every other team. I have a function displayResult(Team T1,
Team T2), it returns the team which won the match between any two given
teams T1 and T2.
I have to write the teams in an order such the (n-1)th team
the ranking should be A,B,C. But based on
the third game, C should be ranked higher than A.
Don
On May 23, 11:06 am, Nishant Pandey nishant.bits.me...@gmail.com
wrote:
I have a list of N teams T1, T2, T3 … Tn. Each of these teams has played
a
match against every other team. I have
I want to implement rope data stucture from scratch in c , is there any
good material that can help me implement this with ease.
Thanks
Nishant
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To unsubscribe from this group and stop receiving
with 1 = k = n, proving that the
algorithm produces the desired result.
Dave
On Sunday, May 5, 2013 7:44:01 AM UTC-5, Nishant Pandey wrote:
Hi Guys,
In this problem i am wondering how it will be done without extra memory
space, though we can easily do it with hashing and random funcs
i think u should utilize the property of XOR, this would help.
On Wed, May 8, 2013 at 12:02 AM, MAC macatad...@gmail.com wrote:
I was asked this in recent amazon onsite interview and asked o write code
Given an Array of integers . N elements occur k times and one element
occurs b times, in
This is my code snippet
#include iostream.h
#include string
#include set
#include map
#include vector
#include sstream
#include cctype
using namespace std;
void work() {
mapstring, int name_age;
mapint,string index_name;
mapint,string index_name_temp;
std::map int, string ::iterator it;
Hi Guys,
In this problem i am wondering how it will be done without extra memory
space, though we can easily do it with hashing and random funcs().
Is there any solution for this , Please help.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
Guys i am looking for optimize algorithm for this, please help.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To unsubscribe from this group and stop receiving emails from it, send an email
to algogeeks+unsubscr...@googlegroups.com.
For
the code is simply utilizing the xor property as u know xor sets on odd one
so, if any array would have numbers odd times repeated
their bit will only stay in xor operation else will get nulify.
so in first loop bit of 1 and 3 are set, to seperate them we need to
divide them using any of their
int main() {
int a[] = {1,2,2,3,3,3,4,4};
int size = sizeof(a)/sizeof(a[0]);
int xorr=0;
for(int i=0;isize;i++) {
xorr^=a[i];
}
int x=0,y=0;
int xor1=xorr ~(xorr-1);
for(int i=0;isize;i++) {
if(xor1 a[i]) x^=a[i];
else y^=a[i];
}
cout xy;
}
in this 1 and 3 would be output. as it
what the issue with this , while doing inorder traversal check if left and
right both are null its ur leaf node else keep traversing.
If i couldn't understood ur problem , please explain again.
On Sat, Mar 16, 2013 at 7:44 PM, Megha Agrawal megha1...@iiitd.ac.inwrote:
Hello all,
Is it
-right)) cout root-data;
}
*
*let me knw if anything seems confusing.
On Sun, Mar 10, 2013 at 4:59 PM, Nishant Pandey
nishant.bits.me...@gmail.com wrote:
i have few questions regarding ur problems pratik :
1) A tree with only parent pointer, how to find LCA?
Doubt : do u mean only root
i have few questions regarding ur problems pratik :
1) A tree with only parent pointer, how to find LCA?
Doubt : do u mean only root of the tree is given , i am assuming root along
with two nodes address whose lca need to
find too is given , i am right ?
2) Find top k searched elements
some thing like would work.
int find(int x ) {
int p = sqrt(x/2);
int total=0;
float y;
for( int i=0;i=p;i++) {
y=sqrt(x*x-i*i);
if( y(int) == y) total++;
}
return total;
}
find(
}
On Thu, Feb 14, 2013 at 10:22 AM, Shachindra A C sachindr...@gmail.comwrote:
Guneesh,
Thanks for the
i think what aditya suggested is cool but in that instead of going for
largest element we need to search smallest value and its index would he
number we are looking for.
On Sun, Feb 24, 2013 at 7:45 PM, Dave dave_and_da...@juno.com wrote:
@Marti: If you know m and k, and if m is even and k is
+1 for above approach , its called memotization .. it helps reducing
redundant recursive call for the same matter.
On Thu, Feb 21, 2013 at 2:29 PM, Karthikeyan V.B kartmu...@gmail.comwrote:
Assuming that u can either move down or right,
Using Dynamic Programming,
a DP equation can be framed
what would happen of the input is like this : 5, 5, 66, 66, 7, 1, 1, 77,7
i think in this case the moment window reaches to point (66,7,1) it will
take 7 as unique number but
that too window will not move any futhur , but 7 is not unique .
Please comment if i misunderstood ur explanation .
i already said this is not possible , in my intial draft , as we dont have
any information of memory owner in called function , just have base address
which is address of single element of the array .
On Wed, Jan 30, 2013 at 1:55 PM, Prem Krishna Chettri hprem...@gmail.comwrote:
@Piyush ..
i think this is not possible as you are passing only base address of the
int array to it , there is not information about the owner .
On Mon, Jan 28, 2013 at 3:44 PM, Anil Sharma anilsharmau...@gmail.comwrote:
How to calculate the size/lenght of an int array which is passed as an
ONLY argument
no i am using C for this implementation , can you suggest me algo for this
On Tue, Jan 8, 2013 at 5:55 PM, Sachin Maheshwari
sachin.maheshw...@gmail.com wrote:
If you are using Java, you can go with LinkedHashMap.
On Sat, Jan 5, 2013 at 6:40 PM, Nishant Pandey
nishant.bits.me
Give a Data structure to store Name-value pair like name-age
abc,12
xyz,34...
such than insert(name,value), value = search(name), name = nthentry(n),
delete(name); all can be perfomed in O(1).
Note:- after deletion order should be maintained.Ex.
ds,12
df,78
teu,54
etr,12
If delete(df) is called
i think arr[10] and int *arr are two different declaration when ,when
compiler tried to link with the memory of int arr[10] it could nt find it ,
as u have declraed it to be integer type pointer , and in file 1 it could
find integer pointer .
On Wed, Oct 24, 2012 at 11:06 PM, rahul sharma
can some body please explain voting algo to me .
On Wed, Jul 11, 2012 at 12:42 PM, Navin Kumar algorithm.i...@gmail.comwrote:
@sachin:
http://valis.cs.uiuc.edu/~sariel/research/CG/applets/linear_prog/median.html
On Wed, Jul 11, 2012 at 12:28 PM, sachin goyal
both the distance means distance between the two linked list some thing
like this :
struct node *temp1,*temp2;
temp1 = head1;
temp2 = head2;
int l1 = get_dist(head1);
int l2 = get_dist(head2);
int ds = abs(l1-l2);
if( l1 l2 )
{
for(int i=0;ids;i++)
{
function call
//swap()
flag[str[i]=1;
}
done
On 7/3/12, Nishant Pandey nishant.bits.me...@gmail.com wrote:
1) Find all permutations of a string.
2) Improve it so that the permutations are not repeated, Eg= string is
Answer should be just once not 4! times
get the size of both the linked list say d1,d2 ;
get their diff like df=abs(d1-d2);
now take 2 pointers both poiting to the start of both the linked list .
go to bigger list now move this pointer until both the distance becomes
equal .
at this point we have one pointer from smaller list pointing
1) Find all permutations of a string.
2) Improve it so that the permutations are not repeated, Eg= string is
Answer should be just once not 4! times.
i want suggestion to improve the recursive code in case of 2) case .
--
You received this message because you are subscribed to the
();
stack_temp.pop();
i--;
//if(current-right)
//coutcurrent-dataendl;
current=current-right;
if(current)
i++;
}
}
}
}
--
Cheers,
Nishant Pandey |Specialist Tools
)
//coutcurrent-dataendl;
current=current-right;
if(current)
i++;
}
}
}
}
--
Cheers,
Nishant Pandey |Specialist Tools Development |
npan...@google.comgvib...@google.com |
+91-9911258345
--
You received this message
://groups.google.com/group/algogeeks?hl=en.
--
Cheers,
Nishant Pandey |Specialist Tools Development |
npan...@google.comgvib...@google.com |
+91-9911258345
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email
to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
--
Cheers,
Nishant Pandey |Specialist Tools Development |
npan
I am asking again .. can any one please suggest better method for getting
the median on the longest path of the tree ..
efficient method .
On Tue, Jun 19, 2012 at 5:08 PM, Nishant Pandey
nishant.bits.me...@gmail.com wrote:
for getting diameter we can simply add the max height of left subtree
...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
--
Cheers,
Nishant Pandey |Specialist Tools Development |
npan...@google.comgvib...@google.com |
+91-9911258345
--
You received this message because you are subscribed to the Google
this group at
http://groups.google.com/group/algogeeks?hl=en.
--
Cheers,
Nishant Pandey |Specialist Tools Development |
npan...@google.comgvib...@google.com |
+91-9911258345
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post
://groups.google.com/group/algogeeks?hl=en.
--
Cheers,
Nishant Pandey |Specialist Tools Development |
npan...@google.comgvib...@google.com |
+91-9911258345
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
--
Cheers,
Nishant Pandey
/algogeeks?hl=en.
--
Cheers,
Nishant Pandey |Specialist Tools Development |
npan...@google.comgvib...@google.com |
+91-9911258345
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com
.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
--
Cheers,
Nishant Pandey |Specialist Tools Development |
npan...@google.comgvib...@google.com |
+91-9911258345
--
You received
/algogeeks/-/54GHWSwHHw8J.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
--
Cheers,
Nishant Pandey
://groups.google.com/group/algogeeks?hl=en.
--
Cheers,
Nishant Pandey |Specialist Tools Development |
npan...@google.comgvib...@google.com |
+91-9911258345
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email
to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
--
Cheers,
Nishant Pandey |Specialist Tools Development |
npan...@google.comgvib...@google.com |
+91-9911258345
--
You received this message because you
://groups.google.com/group/algogeeks?hl=en.
--
Cheers,
Nishant Pandey |Specialist Tools Development |
npan...@google.comgvib...@google.com |
+91-9911258345
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks
email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
--
Cheers,
Nishant Pandey |Specialist Tools Development |
npan...@google.comgvib...@google.com |
+91-9911258345
--
You received this message because you
+ i) = *(char *)(data + i);
temp-next = *p;
*p = temp;
}
void(List *p,void (*f)(void*))
{
while (p)
{
(*f)(p-data);
p = p-next;
}
}
void printstr(void *str)
{
printf( \%s\, (char *)str);
}
Regads
Nishant Pandey
On Thu, May 31, 2012 at 1:15 PM, Hassan
...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
--
Cheers,
Nishant Pandey |Specialist Tools Development |
npan...@google.comgvib...@google.com |
+91-9911258345
--
You received this message because you are subscribed to the Google Groups
,
Nishant Pandey |Specialist Tools Development |
npan...@google.comgvib...@google.com |
+91-9911258345
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group
60 matches
Mail list logo