top of page

Mathematical

 

 

How to approach:

 

 

Many of these problems read cracking the coding interview 6th edition pdf like brain warmers at first, but can be logically fixed.

road. Just remember to trust the rules of math to develop an approach, and then

carefully translate that idea into code.

 

Example: if you are given two numbers m and n, write a method to return the first number r, that is

divisible by both (for example, the least common plural).

I must enter r, and all strollers must be in r. What if m and n have common strollers?

For example, if m is divisible by 3 A 5 and n is divisible by 3 A 7, what does this mean for r?

It means that r must be divisible by 3 A 7.

 

The rule: for each prime p such that p A a \ m (that is, m is divisible by p A a) and p A b \ n, r

 

The algorithm:

 

Define q as 1.

 

for all prime numbers p less than m and n:

 

lig q = q * p A uas (a, b)

back that

 

 

NOTE: An alternative solution is to recognize that gcd (a, b) * lcm (a, b) = ab.

The gcd (a, b) could then be calculated using the Euclidean algorithm. Of course

If you do not know this fact yet, this rule is unlikely to happen to you.

during an interview.

 

 

Things to keep in mind:

 

1. Be careful of the difference in precision between floats and doubles.

 

2. Do not assume that the value (such as the slope of the line) is a value unless instructed to do so

so.

 

Bayes' rule and probability

 

1. If A and B are independent, then P (A and B) = P (A) * P (B).

 

2. Other (usually), P (A and B) = P (A given B) * P (B)

 

3. If A and B are mutually exclusive (for example, if one occurs, the other does not),

 

 

4. Other (usually), P (A or B) = P (A) + P (B) - P (A and B).

Proof

 

 

Test problems - not just for testers!

 

 

While it is clear that testers are being asked for more test problems, developers are often asked

test problems too. Why? Because a good developer knows how to test code!

 

Types of test problems:

 

 

Test problems generally fall into one of three categories:

 

1. Explain how you would test this realistic object (pen, paperclip, etc.).

 

2. Explain how you would test this computer software (for example, web browser).

 

We will talk about type n. 1, as it is usually the scariest. Remember that there are three types

they require you not to make assumptions that the input or the user will be pleasant. Expect abuse

and plan it.

 

How to test a real world target

 

 

We imagine you have been asked to prove the paperwork. The first thing to understand is: what

it was expected to be used and by whom the users were expected. Ask your interviewer: the answer

It may not be your opinion! " or not

could "by artists, bend new forms". These two use cases will be very different

answers. Once you understand the intended use, consider:

For example, save 2 sheets

together and up to 30 sheets. If it fails, does it fail gracefully? (Look down)

 

»What does it mean to fail? Answer: "Elegant failure" means that the clip stops

without binding the paper. If it hits easily, it doesn't (probably) miss gracefully.

 

»Ask your interviewer: what are the chances of using it outside the secret?

 

use case ed? Should we make sure it has the least possible use for the other scenarios?

 

»What are the" stress "conditions  that can be used on your paperwork? Answer: hot and cold weather

weather, frequent reuse, etc.

bottom of page