helpjava11
Replies to this thread:

More by helpjava11
What people are reading
Subscribers
:: Subscribe
Back to: Kurakani General Refresh page to view new replies
 Adults ONLY !
[VIEWED 7701 TIMES]
SAVE! for ease of future access.
Posted on 12-11-14 9:38 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Now I got all of yours attention, solve this problem.

A book has N pages, numbered the usual way, from 1 to N. The total number of digits in the page numbers is 1,095. How many pages does the book have?
 
Posted on 12-11-14 10:17 AM     [Snapshot: 140]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Jhan bihana bihana ke dekhna paaiyela bhanera kholeko ta. Daka le jhukkai halyo ni
 
Posted on 12-11-14 10:28 AM     [Snapshot: 153]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

N(N+1)/2=1095.. Solve for N. that's the answer
 
Posted on 12-11-14 10:41 AM     [Snapshot: 204]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

From 1 to 9 ====> 9 digits
10 to 99 =====> 180 digits
.                           + ----------
Total of 1 digit and 2 digit no.s  = 189 digits
Now rest of the pages are the three numbered pages:
N - 189 = 1095 - 189 = 906
906/3 = 302

So the total pages: 9 + 90 + 302 = 401
Last edited: 11-Dec-14 11:34 AM

 
Posted on 12-11-14 11:19 AM     [Snapshot: 309]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

1 to N = 1 to 129
 
Posted on 12-11-14 1:13 PM     [Snapshot: 523]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Slackdemic got it right. Answer is 401.

Todays score:
Slackdemic +1
Sajhamitra -1
sara_solta11 -1


 
Posted on 12-11-14 1:35 PM     [Snapshot: 553]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Here is my tricky question.
You have range of contiguous numbers in array from 1 to 1 million. Among of them one of the numbers is missing. Find out that missing number. You can use any data structure or use a simple math.
 
Posted on 12-11-14 3:04 PM     [Snapshot: 659]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

अहिलेको जमानामा यसो हल्का गुगल गर्नु पर्छ क्या, गुला खेलाउदै दिमाग चलाउन खोजेर मात्र हुदैन।

http://codepad.org/Hrj8BKZ7

int getMissingNo (int a[], int n)
{
    int i, total;
    total  = (n+1)*(n+2)/2;  
    for ( i = 0; i< n; i++)
       total -= a[i];
    return total;
}
 
/*program to test above function */
int main()
{
    int a[] = {1,2,4,5,6};
    int miss = getMissingNo(a,5);
    printf("%d", miss);
    /*getchar();*/
}
Last edited: 11-Dec-14 03:05 PM

 
Posted on 12-11-14 3:40 PM     [Snapshot: 711]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Do it with a datastructure.
 
Posted on 12-12-14 10:22 AM     [Snapshot: 1337]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

if the numbers are in sequence, this function works fine. if its not in sequence its different story.

main method(){
int[] arrayofMillionNumbers = new int[100000];
for(int i = 1 ; i< arrayofMillionNumbers+1 ; i++){
arrayofMillionNumbers.add(i);
}
findMissing(arrayofMillionNumbers);
}
private int findMissing(int[] num) {
int missingNumber = 0;
for (int i = 0; i < (num.length - 1); i++) {
if ((num[i + 1] - num[i]) > 1) {
missingNumber = num[i] + 1;
break;
}
}
return missingNumber;
}
 
Posted on 12-12-14 10:31 AM     [Snapshot: 1348]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

if the numbers are in sequence, this function works fine. if its not in sequence its different story.


m = missing number
x = 1;
for i = 1 to million
{
if x is not equal to i
{
m = x = missing number;
stop iteration;}
x = x + 1;
}
output m;


 
Posted on 12-12-14 10:42 AM     [Snapshot: 1369]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

those numbers are continuous but distributed randomly. like 1,3,2,5,4.....etc
your solution works only if numbers are continuous but there should be some efficient way to solve if sequential numbers are randomly distributed.
Last edited: 12-Dec-14 10:44 AM

 
Posted on 12-12-14 10:46 AM     [Snapshot: 1378]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 
 
Posted on 12-12-14 11:38 AM     [Snapshot: 1412]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Add all the numbers in the array.
Then find n! ( that is 1,000,000!)
Subtract them, that would be number that is missing.

This is would be complete in O(n) which is better than sorting the number and then using one of above algorithm to find the missing one.

 
Posted on 12-12-14 12:43 PM     [Snapshot: 1460]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Yes that's true but there is another solution too. Hint: You can use an array.
 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 90 days
Recommended Popular Threads Controvertial Threads
What stocks to buy -- Any recommendation
🙏 दलाल स्ट्रिट 🙏
Conservative discussions
What are your first memories of when Nepal Television Began?
When the news is bought for by vaccine corporations
ChatSansar.com Naya Nepal Chat
नव बर्ष २०२२ को मंगलमय शुभकामना / शुस्वास्थ्यको कामना
The Great Himalayan Cable Car
Kuro ali gahiro cha
How to deal with anxiety
Relationship
'Plan C' amnesty push for millions of illegal immigrants in Democrat reconciliation bill
ढुककुर बढाउने घरेलु उपाए ...
Misinformation is followed by Blind Followers as if came from Supreme (God)
भाते मुखियाबा
Diwali is here. Rangoli Ideas. Please let us know which one do you like ?
YouTube question ❔
King Mahendra's Alaska Visit
जेरी हैन जलेबी भन्नुस
What's up with US embassy Nepal Kathmandu?
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters