Cracking the Coding Interview

General tips:

Always validate the entry first. Check for invalid, empty, negative or different entries. Never assume you have valid parameters. Alternatively, make it clear to the interviewer if you can accept valid input (generally yes), which can save you time writing code that validates the input.

Are there requirements or cracking the coding interview limitations of complexity of time or space?

Check for additional errors face to face.

In languages ​​that do not have coercivity of an automatic nature, check that the combination of similar values: int, str and list.

After finishing your code, use some sample inputs to test your solution.

Is the algorithm expected to run repeatedly, perhaps on a web server?

If so, the input is likely pre-processed to improve efficiency on all API calls.

Use a combination of functional and essential programming parameters:

• Write pure functions as often as possible.

• Use pure functions, as they are easier to reason and can help reduce errors in your implementation.

• Avoid modifying the parameters entered in your function, especially if it is passed by reference, if you are not sure what you are doing.

• Strike a balance between precision and efficiency. Use the right amount of functional and essential code when appropriate. Functional programming is often expensive in terms of spatial complexity due to non-mutation and repeated assignment of new objects. On the other hand, the code is essentially faster because you work on existing things.

• Avoid relying on global variables. Global variables introduce a situation.

• Make sure you don't accidentally override global variables, especially if you have to depend on them.

Data structures are your weapons. The key to victory is choosing the right weapon for the right battle. Consider the merits of each data structure and the time complexity of its various operations.

Data structures can be augmented to achieve time effective complexity across multiple operations. For example, HashMap can be used in conjunction with a double-linked list to overcome the time complexity of O (1) to find and store an LRU operation.

HashMaps is probably the most used data structure for algorithm queries. If you get stuck with one question, your last option will be to do a calculation through the possible data structures (fortunately there are not enough) and think if you can do all of them. applied to the problem. This worked for me sometimes.

If you are taking shortcuts in your code, say it out loud to your interviewer and explain what you would do outside of an interview setting (no time restrictions). For example, explain that you would write regular expressions to parse the wire instead of using a division, which does not cover all cases.

Sequence

Notes

Strings and strings are considered sequences (a string is a sequence of characters). There are suggestions for dealing with arrays and strings, which will be covered here.

Are there duplicate values ​​in the sequence? Would they affect the answer?

Check the sequence out of bounds.

Be aware of split or concurrent layers in your code. The cleavage and integration sequences typically require O (n) time. Use leading and trailing indices to limit a tributary or substring when possible.

Sometimes you cross the sequence from the right instead of the left.

Master the sliding window technique associated with many substring or subarray problems.

When given two rows to process, generally one index must be crossed per layer. For example, we use the same approach to merge two ordered matrices.

Corner cases

• Empty sequence

• Sequence with 1 o 2 elements

• Sequence with repeating elements