prashaenator
BAN USER
- 0of 0 votes
AnswersGiven an array { -2 3 5 0 -3 7 -1}. Sort the array in such a way that array should contain -ve numbers first and then zero and then all +ve numbers. (Note: order of +ve number and order of -ve numbers should be same after sorting). For ex: the o/p of above array is {-2 -3 -1 0 3 5 7}
- prashaenator in India for BING| Report Duplicate | Flag | PURGE
Microsoft Developer Program Engineer Algorithm
We need to store 4 things
1. color
2. presence
3. type of the coin
4. location
Locations range is (0,0) = 0x00 to (7,7) = 0x77 which need 6bits. That means 32 * 6bits = 24bytes (for storing the locations)
1 bit for color => 32 bits = 4 bytes
1 bit for presence => 32 bits = 4 bytes
3 bits for type of coin (000 - pawn, 001 - bishop, 010 - knight , 011 -rook, 100- queen, 101 - king) => 3*32 = 12 bytes
Total = 44 bytes
@ Srinivas: Yes, I do agree. max sum is -2, min sum is -10. But, does this algo give right answer ?
- prashaenator August 17, 2012@ karthikaditya
Your code doesn't seem to work if the array contains all -ve numbers
Ex : {-4 , -4 , -2}
Max Sum is -10... But, your algo give 0 as max sum
@arya
How does it work if the array contains all the negative numbers
for ex : { -4, -5, -2}
Max sum should be -11
Repjennykyiler, Area Sales Manager at AMD
Jenny , an Assistant Secretary with a track record of employer satisfaction in performing various administrative tasks, and completing visual presentations ...
RepMistySangra, Developer Program Engineer at Alliance Global Servies
I am Misty , working as a Database Administrator with 4+ years of experience installing, maintaining, and upgrading various servers and ...
RepDaisyDiaz, abc at ADP
I am enthusiastic professional writer with years of experience in writing articles for magazines and newspaper, very dependable and has ...
RepJeniferWatts, SEO at Accolite software
I’m Jenifer , working as a press reporter in the USA. I collect, write, or distribute news or other current ...
RepSophiaLopez, Analyst at AMD
I am a skilled freelance graphic designer with over a decade of experience in the field. I am dedicated to ...
RepManilaRoche, Animator at Abs india pvt. ltd.
Manila , an extensive executive assistant with experience of 4 years in the field of administrative functions, managing the office of ...
RepEllaScotz, abc at A9
I am a creative designer with innovative ideas and a unique approach to visuals. I am also a skilled painter ...
Repheldagale, Backend Developer at ASU
Helda , an outgoing Library Assistant capable of working independently in a busy library environment. Great team player adept at performing ...
RepJenniaLopez, Associate at Absolute Softech Ltd
Jennia , a hard-working Packer with a strong determination to finish all assignments in a timely manner. Replaces , operates and maintains ...
Repneilsjohn4563, Android Engineer at ABC TECH SUPPORT
Hello, I am a multimedia artist. I have 4 years experience in this.A multimedia Artist is someone who is ...
Repcheryljnewsome, Android Engineer at ABC TECH SUPPORT
Hello, my name is Chery and I am a Graphic designer. We are Graphic Designers create visual concepts to communicate ...
RepZoeKim, AT&T Customer service email at A9
Holds a job in the social work sector and directly deals primarily with women and children who are fleeing domestic ...
RepStellaMoore, Analyst at ADP
I am professional and dependable with more than 4 years of experience working at a bakery. I mix ingredients together ...
This problem can be solved using prime numbers
- prashaenator August 18, 2012Let's say A is an array which contains first 10 prime numbers
A = { 2,3,5,7,11,13,17,19,23,29}
unsigned long int multnum =1, multsearchnum =1 ;
foreach digit of number
{
multnum *= A[digit];
}
foreach digit of (searchNumber)
{
multsearchnum *= A[digit];
}
if { multnum % multsearchnum == 0} {
print ( "all digits of search string are present in the number");
}
I didn't find any failing case till now. Please let me know if you find any failing case.