This 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..
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;
// Print the whole array
printf("%d ", a[counter]);
// Move the 0(s) to end of the list.
if(a[counter] == 0)
//Set the lastIndex for the firsttime.
if(lastIndex == 0) lastIndex = counter;
if(lastIndex == 0) continue;
//For the first time lastIndex will be set above..
lastIndex = lastIndex+1;
printf("%d ", a[counter]);
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
DarshWilliams, abc at 8x8
Exceptionally dedicated and professional Academic Advisor with a superb record of student support and satisfaction. Read about dua to put ...
bettylfoster, 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 ...
JanetCKeel, 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 ...
KeithyMayes, 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 ...
DavidRNichols, Analyst at AMD
Skilled communicator and listener with a knack for remedying conflict, and keen organizational skills which allow for effective delivery of ...
tanyaarriol911, 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 ...
BruceSwigert, Android Engineer at Altera
I am Bruce,I have worked with various branches, including finance and HR, which permits me to encourage a productive ...
AdaShipman, abc at 247quickbookshelp
During operation, determine all necessary adjustments to the printing press to maintain safety, quality and productivity standards and make such ...
HannahWilson, Android Engineer at A9
Hi, I’m Hannah from the USA and I am working as an account manager. I work for a hardware ...
kalerkant98, abc at ADP
I am DennisRue, seeking an entry level position where my strong work ethics and ability to learn quickly will contribute ...
lovercast172, Analyst at ADP
I am working as Human Resources Associates, and my duties are for obtaining, recording, and interpreting human resources information within ...
lillianrperkins66, 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 ...
pennyruddie, 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 ...
yalendatopi, 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 ...
merrillagreerm, 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 ...
HelenBMartin, 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 ...
AayshaRosie, 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 ...
Hey, I am Ruth and I am working as an interviewer.I take too many Interviews For my Company and ...
neshujaha, 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 ...
hallieriddic, 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 ...
carlotamdaniel, abc at ADP
MillaSoth, Intern at ADP
I am Milla , a dedicated Emergency Response Technician regarded for performing advanced medical procedures with a high degree of accuracy ...
morganswitzer8475, 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 ...
RuthOrvis, 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 ...
arlenekraft8, 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 ...
MariaBJiles, Accountant at A9
I am working as a team leader in a development software company. I am creative in learning how to crochet ...
suzikaily, 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 ...
hugaliuli, Nurse at 8x8
Registered nurse with experience in delivering quality care to patients. Professional with more than 3 years in emergency room care ...
andrealmoore45, Analyst at 247quickbookshelp
My name is Andrea and I Live in california. I like to read articles from some interesting topics.And today ...
MelissaJoy, Associate at Bocada
Hi, I am Melissa, a purchasing agent from Texas. Kind of a good Samaritan, terrible athlete, but extremely blessed in ...
aishadavind7, Analyst at ASU
Being a Route driver I need to go here and there for the reason for delivering things here. I met ...
NancyDWilliams, 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 ...
remiflo4, 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 ...
MiaMiller, abc at A9
Experienced software engineer with a passion for developing innovative programs that expedite the efficiency and effectiveness of organizational success. Well-versed ...
kiyanshak, Associate at Adobe
I am a skilled software developer and have 5 years experience as a data coder operator. I have certain skills ...
pihupiter, 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 ...
PrankHwa, Animator at Accolite software
I am a Reporter and responsible for delivering updates and analysis on current events with the main goal to keep ...
jeniakant, 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 ...
joanarce252, 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 ...
aaronyocoma, 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 ...
paytonmorrison48, Data Scientist at ADP
I am working as a date entry keyar . I have many years of experience . The data entry manager is primarily ...
MaryCParker, Dev Lead at ADP
My name is Mary and I am from usa.I am a representative sales advertising agent of (Specific Appraisals)company ...
myershllims, abc at ASAPInfosystemsPvtLtd
Hiii, I am Myers and I am from Elizabeth. I am working as a Product designer designing most things I ...
bungayasorya, Accountant at BrowserStack
An archeologist is an expert on history who gains expertise through experience with historical documents and artifacts. The archaeological record ...
AakeshCruz, 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