chukka.swathi
BAN USER
could you please provide the link for coding interview book..
- chukka.swathi June 01, 2011This will fail if you have exactly n elements.
What you have to do is find the nth element from the end then copy the (n+1)th element data into nth node and delete the (n+1)th node.. pretty easy..
b[0]=0 otherwise it will fail if the i/p is "4,-6,-8,10"
- chukka.swathi December 20, 2010#include <stdio.h>
int main()
{
int a[]={1,2,2,3,3,3,4,5,6,6,9};
int counter, lastIndex;
int length = sizeof(a)/sizeof(int);
// Set 0 for duplicates
for(counter=1,lastIndex=0;counter < length;counter++)
{
if(a[counter] == a[lastIndex])
{
a[counter] = 0;
continue;
}
lastIndex=counter;
}
// Print the whole array
for(counter=0,lastIndex=0;counter<length;counter++)
printf("%d ", a[counter]);
printf("\n");
// Move the 0(s) to end of the list.
for(counter=1,lastIndex=0;counter<length;counter++)
{
printf("lastIndex=%d counter=%d\n",lastIndex,counter);
if(a[counter] == 0)
{
//Set the lastIndex for the firsttime.
if(lastIndex == 0) lastIndex = counter;
continue;
}
if(lastIndex == 0) continue;
a[lastIndex]=a[counter];
a[counter]=0;
//For the first time lastIndex will be set above..
lastIndex = lastIndex+1;
}
for(counter=0,lastIndex=0;counter<length;counter++)
printf("%d ", a[counter]);
getchar();
return 0;
}
small mistake.. you need to add 1.
return Math.max(FindDepth(root->left,level),FindDepth(root->right, level))+1
The best and easy solution is here..
Take two pointers (p1, p2). Initially both points to head
do p1=p1->next, p2=p2->next->next till "p1==p2".
Now p1 and p2 points to a single node. Keep p2 at that meeting point and take p1 to start from head.
till p1->next==p2->next do p1=p1->next, p2=p2->next.
fix the p2->next == NULL.
In case of a circular linked list both p1 and p2 will meet at head point so traverse the linked list till p1->next == p2 and the make p1->next==NULL
Pls take care of having all the NULL n error prone scenarios while coding.
MR.Siva.sai.2020, stop saying good solution for each post..
Look at the ways where it fails.
This algo will fail if the input itself is in sorted order..
chk i/p - 1,2,3,4,5,6,7,8
It fails if the i/p is in reverse order
i/p - 8,7,6,5,4,3,2,1
this is not working..
i/p - 1,2,3,4,5
rotate by 4
o/p - 5,3,4,1,2
but the o/p should be 5,1,2,3,4
this is not working..
i/p - 1, 2, 3, 4, 5
try to rotate by 1 then o/p is 1,1,3,4,5 but it should be 2,3,4,5,1
RepDarshWilliams, abc at 8x8
Exceptionally dedicated and professional Academic Advisor with a superb record of student support and satisfaction. Read about dua to put ...
Repbettylfoster, University dean at Littler's
Hi , I am Betty from the USA , working as Dien in Littler's University for the last three years. Previously ...
RepJanetCKeel, Accountant at ABC TECH SUPPORT
Hey i am Janet i am from Us and i leave here from last 4 years .My job is truck ...
RepKeithyMayes, Area Sales Manager at ASAPInfosystemsPvtLtd
Keithy , an administrative manager , Designs and access to technology to facilitate new infrastructure for students. and I have a hobby ...
RepDavidRNichols, Analyst at AMD
Skilled communicator and listener with a knack for remedying conflict, and keen organizational skills which allow for effective delivery of ...
Reptanyaarriol911, Applications Developer at ABC TECH SUPPORT
I am working as a Data entry Manager and I love my job. Also I love to read new Articles ...
RepBruceSwigert, Android Engineer at Altera
I am Bruce,I have worked with various branches, including finance and HR, which permits me to encourage a productive ...
RepAdaShipman, abc at 247quickbookshelp
During operation, determine all necessary adjustments to the printing press to maintain safety, quality and productivity standards and make such ...
RepHannahWilson, Android Engineer at A9
Hi, I’m Hannah from the USA and I am working as an account manager. I work for a hardware ...
Repkalerkant98, abc at ADP
I am DennisRue, seeking an entry level position where my strong work ethics and ability to learn quickly will contribute ...
Replovercast172, Analyst at ADP
I am working as Human Resources Associates, and my duties are for obtaining, recording, and interpreting human resources information within ...
Replillianrperkins66, Android test engineer at ABC TECH SUPPORT
I'm Lillian Perkins, and I'm a studio camera operator. A studio camera operator Main work includes operating cranes ...
Reppennyruddie, Cloud Support Associate at Accenture
Training Coordinator focuses on transaction quality, efficiency, and facility management. develops effective training for the programme “ mantra for attract girl ...
Repyalendatopi, Dev Lead at Alliance Global Servies
I am Yalenda , a video editor with 3+ years of experience, skilled in Premiere Pro. Seeking position with Weingarten's ...
Repmerrillagreerm, Android Engineer at Abs india pvt. ltd.
I am patient, compassionate, and caring when treating and counseling patients in practice, making them feel like they’re in ...
RepHelenBMartin, Android Engineer at ABC TECH SUPPORT
I am an avid reader and a leader and participant in a community book club. My reading Kamakhya Mandir Tantrik ...
RepAayshaRosie, HTML Freshers at Abs india pvt. ltd.
Aaysha , a book editor with 4 years of experience with increasing readership and developing skilled writers. At the Daily Record ...
RepHey, I am Ruth and I am working as an interviewer.I take too many Interviews For my Company and ...
Repneshujaha, Member Technical Staff at BMO Harris Bank
I am Neshu, a Camera Operator with a creative eye for detail and dedication to quality work. I am always ...
Rephallieriddic, HR Executive Trainee at Barclays Capital
I am Hallie, Dedicated and experienced administrative secretary who excels at prioritizing , completing multiple tasks simultaneously and following through to ...
Repcarlotamdaniel, abc at ADP
RepMillaSoth, Intern at ADP
I am Milla , a dedicated Emergency Response Technician regarded for performing advanced medical procedures with a high degree of accuracy ...
Repmorganswitzer8475, Android test engineer at ABC TECH SUPPORT
Hey, I'm Morgan switzer and i am a sociologist. I also like to read some interesting books like get ...
RepRuthOrvis, AT&T Customer service email at 8x8
Hey I am Ruth Working as a branch manager in a bank.I have worked here for the last 4 ...
Reparlenekraft8, How to book a seat on Southwest airlines flight at Absolute Softech Ltd
I am a coding specialist from MD,USA.I’m indifferent to most items on the planet.Participated in creating ...
RepMariaBJiles, Accountant at A9
I am working as a team leader in a development software company. I am creative in learning how to crochet ...
Repsuzikaily, Digital marketing freshers at ADP
Hi , I am Suzi , working as a dancer in the Rudo club . I have been working here since 2013 and ...
Rephugaliuli, Nurse at 8x8
Registered nurse with experience in delivering quality care to patients. Professional with more than 3 years in emergency room care ...
Repandrealmoore45, Analyst at 247quickbookshelp
My name is Andrea and I Live in california. I like to read articles from some interesting topics.And today ...
RepMelissaJoy, Associate at Bocada
Hi, I am Melissa, a purchasing agent from Texas. Kind of a good Samaritan, terrible athlete, but extremely blessed in ...
Repaishadavind7, Analyst at ASU
Being a Route driver I need to go here and there for the reason for delivering things here. I met ...
RepNancyDWilliams, abc at ABC TECH SUPPORT
I am NancyDWilliams. I work as a Personnel Administrator at Campbellsville university. I was born in India and currently, I ...
Repremiflo4, Dyeing at Fabric Dyeing Service
Mid-level hair stylist with five years of experience working with men’s and women’s hair as well as children ...
RepMiaMiller, abc at A9
Experienced software engineer with a passion for developing innovative programs that expedite the efficiency and effectiveness of organizational success. Well-versed ...
Repkiyanshak, Associate at Adobe
I am a skilled software developer and have 5 years experience as a data coder operator. I have certain skills ...
Reppihupiter, university professor at Precious Moments
Expert English literature and language university professor with more than 5 years of experience teaching at the college level. Outside ...
RepPrankHwa, Animator at Accolite software
I am a Reporter and responsible for delivering updates and analysis on current events with the main goal to keep ...
Repjeniakant, Android test engineer at AMD
Hey I am working as a actor in Film industry from last 10 years.I start My last carrier after ...
Repjoanarce252, abc at ABC TECH SUPPORT
Hello, I am Joan. I live in Jackson, USA. I am passionate about my work and I am working as ...
Repaaronyocoma, U.S. marshal at Pacific Stereo
Working as U.S. marshal at Pacific Stereo numerous years . I encountered heaps of things . With this I likewise like ...
Reppaytonmorrison48, Data Scientist at ADP
I am working as a date entry keyar . I have many years of experience . The data entry manager is primarily ...
RepMaryCParker, Dev Lead at ADP
My name is Mary and I am from usa.I am a representative sales advertising agent of (Specific Appraisals)company ...
Repmyershllims, abc at ASAPInfosystemsPvtLtd
Hiii, I am Myers and I am from Elizabeth. I am working as a Product designer designing most things I ...
Repbungayasorya, Accountant at BrowserStack
An archeologist is an expert on history who gains expertise through experience with historical documents and artifacts. The archaeological record ...
RepAakeshCruz, Accountant at Tinder
Exceptional knowledge of mathematical concepts, accounting and finance topics, tax code, and banking principles.Worked with clients and CFOs to ...
could you please provide the link for coding interview book..
- chukka.swathi June 01, 2011