spik
BAN USER
void make_unique(vector<int> & first , vector<int> & second , vector<int> &third)
{
sort(first.begin(),first.end());
sort(second.begin(), second.end());
third.clear();
int f_pos = 0 , s_pos = 0 ; // index on first array and second array
while(f_pos < first.size() && s_pos <second.size())
{
// 2 elements to compare
if(first[f_pos] < second[s_pos])
{
third.push_back(first[f_pos]);
// i want to skip all element in first array which are the same as first[f_pos]
skip_dup(first,f_pos);
}
else if( second[s_pos] < first[f_pos])
{
third.push_back(second[s_pos]);
// // i want to skip all element in second array which are the same as second[f_pos]
skip_dup(second,s_pos);
}
else
{
// 2 elements quals so push any of them and skip dup in both
third.push_back(first[f_pos]);
skip_dup(first,f_pos);
skip_dup(second,s_pos);
}
}
while(f_pos <first.size())
{
third.push_back(first[f_pos]);
skip_dup(first,f_pos);
}
while(s_pos <second.size())
{
third.push_back(second[s_pos]);
skip_dup(second,s_pos);
}
}
Time O(NlogN) , Space O(1)
- spik August 26, 2013void rearrange(vector <int> &nums)
{
vector<int> temp;
int start_pos = 0;
for(int i=0;i<nums.size();++i)
{
if(nums[i] <0 )
nums[start_pos++] = nums[i];
else
temp.push_back(nums[i]);
}
for(int i=0;i<temp.size();++i)
nums[start_pos++] = temp[i];
}
It's O(N) time and (N) memory , i can't find solution with less memory.
Repaaronfreunda, Human resources coordinator at Prestiga-Biz
Aaron , My work is to facilitate daily HR functions like track of employees records and supporting the interview process. I ...
Repolliejshea, Android test engineer at ABC TECH SUPPORT
Hello I am an application engineer. I love my work very much. Nowadays I am doing some new experiments. Like ...
RepRobin Strain, Consultant
I am from New york. I am 26 year old. I work in a Central Hardware as a Worker compensation ...
Replillyalaird, Associate at Achieve Internet
I am Lilly from Eau Claire USA, I am working as a manager in a Best products company. My interest ...
RepTaylahMacge, Consultant at Accenture
Assigned to manage the requirements of foreign clients specifically those from the Chinese, Arabic, and French-speaking markets.I am passionate ...
RepDedicated administrative assistant with years of experience managing large and small offices. I have worked with numerous branches,including payroll ...
Repclarasbarr, Korean Air Change Flight at Adap.tv
I am ClaraBarr from California USA. Writes and records various different genres for television, film and other artists.Wrote several ...
Repanitajmiller3, Android test engineer at ADP
Je suis passionnée par le monde du marketing de marque. Je souhaite explorer Comment faire revenir l etre aimé avec ...
Repverarfurman, Problem Setter at Cerberus Capital
I am Vera from Bullard USA, I am working as a Violin repairer in a Handyman company. My interest in ...
RepJe suis Hudson Will des États-Unis. Je travaille comme technicien dans une entreprise Éco Vannes. J'analyse et vérifie tous ...
Reprajanadeep17, Android Engineer at 247quickbookshelp
I am a Special education teacher who adapts general education lessons and teaches various subjects to students with mild to ...
Repkenneroce, Cheap Escort Service in Lajpat Nagar 8447779280 Call Girls at Persistent Systems
Hi, I am Kenne working as a LAN manager. One day, I read how to break up a couple from ...
Repluisbshifflett, Aghori Mahakal Tantrik at ABC TECH SUPPORT
I am working as a partner in the Project Planner.I additionally assists people groups with holding appearance rights or ...
Repdennahood, Top mobile application Development Company in India at Arista Networks
Je suis Denna, une rédactrice professionnelle avec une expérience complète et de solides atouts en rédaction et en rédaction Web ...
Repkevinlmoses, Animator at Accenture
I am Experienced Building Manager who is an expert in public and industrial safety with a preventative mindset against fire ...
Repleighpjoyce, job tessio at CapitalIQ
Welcome to my world.I am a safety-conscious HVAC Engineer with experience with mechanical engineering Brampton HVAC design for commercial ...
Repmartinskrull, Analyst at A9
Hi everyone, I am from new york,USA. I currently work in the Affiliate Marketing industry. I love all things ...
Repcarmelalewis9, Area Sales Manager at AMD
I am fond of reading stories then reading articles which are all about a story of a beautiful nature and ...
RepPriscillaRYoung, Aghori Mahakal Tantrik at Absolute Softech Ltd
Hi, I am Priscilla from California. I am working as a Business management consultant in Quality Merchant Services company. I ...
Rephollymclark8, Apple Phone Number available 24/7 for our Customers at Accenture
I am clinical laboratory technologist in Stratapro company. I have Excellent clinical laboratory skills, with commended performance conducting/analyzing laboratory ...
Repterricjohnson8547, Animator at 247quickbookshelp
Hello, I am a dancer. I have completed my studies from New York. And today I am a dance teacher ...
RepGrimesOtto, Java Developer at Coupondesh
I am Grimes Agriculture inspector. I examine agriculture commodities and related operations . I like listening to music, painting, and reading ...
RepRhondaLillie, Android test engineer at AppNexus
I work as an General and operations manager at the Official All Star Café. presenting love stories, ghost stories. Currently ...
Repjoshuacmurphy36, Animator at ABC TECH SUPPORT
Hey,I am an agricultural engineer. And I love this job. We Agricultural Engineers do engineering design and planning in ...
Repannavhedge4, AT&T Customer service email at ABC TECH SUPPORT
Hi everyone, I am from Worcester,USA. I currently work in the Argus Tapes & Records as Scientific illustrator . I love ...
RepDonnaArvin, Analyst at Apple
Hii am from the United States. I work as a computer control programmer at Dynatronics Accessories. I am a social ...
Repmarkemorgan007, Applications Developer at Big Fish
I am Mark From Fresno city in USA.I working as a tour guide and also help for make a ...
Repvictorcraigw, Animator at Chicago Mercantile Exchange
Hi, I am Victor working as a Speech Writer in the USA. Spoke at an academic conference about mantra for ...
RepAvikaEthan, Data Engineer at Adjetter Media Network Pvt Ltd.
Avika Ethan has five years of experience collecting physical and biological data in California streams and rivers. In the field ...
RepHenryMelvin, Korean Air Change Flight at AMD
Hello, everybody! My name is Henry,I am a picture-drawer.Art drawing & painting classes for adults, kids, teens.We have ...
How can you check if the word you added in the heap after remove the min is not already exist in the heap. for example if you have only 2 words {ab,6} , {ac,3} so min heap head will be {ac,3} if you countered ab you will increase ab with 1 to be{ab,7} comparing it with {ac,3} which is > so remove head {ac} and insert {ab} so heap now contains repeated strings
- spik August 30, 2013