General tips
Always validate input first. Check for inputs that are invalid, empty, negative, or different. Never assume you are given the valid parameters. Alternatively, clarify with the interviewer whether you can assume valid input (usually yes), which can save you time from writing code that does input validation.
Are there any time and space complexities requirements or constraints?
Check for off-by-one errors.
In languages where there are no automatic type coercion, check that concatenation of values are of the same type: int,str, and list.
After you finish your code, use a few example inputs to test your solution.
Is the algorithm supposed to run multiple times, perhaps on a web server? If yes, the input can likely be pre-processed to improve the efficiency in each API call.
Use a mix of functional and imperative programming paradigms:
🔹 Write pure functions as often as possible.
🔹 Use pure functions because they are easier to reason with and can help reduce bugs in your implementation.
🔹 Avoid mutating the parameters passed into your function, especially if they are passed by reference, unless you are sure of what you are doing.
🔹 Achieve a balance between accuracy and efficiency. Use the right amount of functional and imperative code where appropriate. Functional programming is usually expensive in terms of space complexity because of non-mutation and the repeated allocation of new objects. On the other hand, imperative code is faster because you operate on existing objects.
🔹 Avoid relying on mutating global variables. Global variables introduce state.
🔹 Make sure that you do not accidentally mutate global variables, especially if you have to rely on them.
Always validate input first. Check for inputs that are invalid, empty, negative, or different. Never assume you are given the valid parameters. Alternatively, clarify with the interviewer whether you can assume valid input (usually yes), which can save you time from writing code that does input validation.
Are there any time and space complexities requirements or constraints?
Check for off-by-one errors.
In languages where there are no automatic type coercion, check that concatenation of values are of the same type: int,str, and list.
After you finish your code, use a few example inputs to test your solution.
Is the algorithm supposed to run multiple times, perhaps on a web server? If yes, the input can likely be pre-processed to improve the efficiency in each API call.
Use a mix of functional and imperative programming paradigms:
🔹 Write pure functions as often as possible.
🔹 Use pure functions because they are easier to reason with and can help reduce bugs in your implementation.
🔹 Avoid mutating the parameters passed into your function, especially if they are passed by reference, unless you are sure of what you are doing.
🔹 Achieve a balance between accuracy and efficiency. Use the right amount of functional and imperative code where appropriate. Functional programming is usually expensive in terms of space complexity because of non-mutation and the repeated allocation of new objects. On the other hand, imperative code is faster because you operate on existing objects.
🔹 Avoid relying on mutating global variables. Global variables introduce state.
🔹 Make sure that you do not accidentally mutate global variables, especially if you have to rely on them.
What is the use of Destructor in Java?
What is a Destructor?
A destructor is a special method that gets called automatically as soon as the life-cycle of an object is finished. A destructor is called to de-allocate and free memory. The following tasks get executed when a destructor is called.
- Releasing the release locks
- Closing all the database connections or files
- Releasing all the network resources
- Other Housekeeping tasks
- Recovering the heap space allocated during the lifetime of an object
Destructors in Java also known as finalizers are non-deterministic. The allocation and release of memory are implicitly handled by the garbage collector in Java.
Finalizers in Java have to be implicitly invoked since their invocation is not guaranteed, unlike C# finalizers which get invoked during the .NET run-time.
Let’s take a look at key properties of a destructor:
- Overloading or inheritance is not allowed
- No specification of access modifiers or parameters
- Automatic invocation and no explicit call from the user
- Used in classes but not in structures
- The order of the class varies from the most derived class to the least derived class
- Also called when the object instance is no longer eligible for access
- Used for releasing un-managed resources instead of managed resources held by the object
Garbage Collector
A garbage collector is a program that runs on the Java virtual machine to recover the memory by deleting the objects which are no longer in use or have finished their life-cycle. An object is said to be eligible for garbage collection if and only if the object is unreachable.
What is a Destructor?
A destructor is a special method that gets called automatically as soon as the life-cycle of an object is finished. A destructor is called to de-allocate and free memory. The following tasks get executed when a destructor is called.
- Releasing the release locks
- Closing all the database connections or files
- Releasing all the network resources
- Other Housekeeping tasks
- Recovering the heap space allocated during the lifetime of an object
Destructors in Java also known as finalizers are non-deterministic. The allocation and release of memory are implicitly handled by the garbage collector in Java.
Finalizers in Java have to be implicitly invoked since their invocation is not guaranteed, unlike C# finalizers which get invoked during the .NET run-time.
Let’s take a look at key properties of a destructor:
- Overloading or inheritance is not allowed
- No specification of access modifiers or parameters
- Automatic invocation and no explicit call from the user
- Used in classes but not in structures
- The order of the class varies from the most derived class to the least derived class
- Also called when the object instance is no longer eligible for access
- Used for releasing un-managed resources instead of managed resources held by the object
Garbage Collector
A garbage collector is a program that runs on the Java virtual machine to recover the memory by deleting the objects which are no longer in use or have finished their life-cycle. An object is said to be eligible for garbage collection if and only if the object is unreachable.
👍1
Human-Computer Interaction in Game.pdf
8.1 MB
Human-Computer Interaction in Game Development with Python
Joseph Thachil George, 2022
Joseph Thachil George, 2022
Important Sorting Algorithms-
Bubble Sort: Bubble Sort is the most basic sorting algorithm, and it works by repeatedly swapping adjacent elements if they are out of order.
Merge Sort: Merge sort is a sorting technique that uses the divide and conquer strategy.
Quicksort: Quicksort is a popular sorting algorithm that performs n log n comparisons on average when sorting an array of n elements. It is a more efficient and faster sorting algorithm.
Heap Sort: Heap sort works by visualizing the array elements as a special type of complete binary tree known as a heap.
Bubble Sort: Bubble Sort is the most basic sorting algorithm, and it works by repeatedly swapping adjacent elements if they are out of order.
Merge Sort: Merge sort is a sorting technique that uses the divide and conquer strategy.
Quicksort: Quicksort is a popular sorting algorithm that performs n log n comparisons on average when sorting an array of n elements. It is a more efficient and faster sorting algorithm.
Heap Sort: Heap sort works by visualizing the array elements as a special type of complete binary tree known as a heap.
Important Searching Algorithms-
Binary Search: Binary search employs the divide and conquer strategy, in which a sorted list is divided into two halves and the item is compared to the list’s middle element. If a match is found, the middle element’s location is returned.
Breadth-First Search(BFS): Breadth-first search is a graph traversal algorithm that begins at the root node and explores all neighboring nodes.
Depth-First Search(DFS): The depth-first search (DFS) algorithm begins with the first node of the graph and proceeds to go deeper and deeper until we find the goal node or node with no children.
Binary Search: Binary search employs the divide and conquer strategy, in which a sorted list is divided into two halves and the item is compared to the list’s middle element. If a match is found, the middle element’s location is returned.
Breadth-First Search(BFS): Breadth-first search is a graph traversal algorithm that begins at the root node and explores all neighboring nodes.
Depth-First Search(DFS): The depth-first search (DFS) algorithm begins with the first node of the graph and proceeds to go deeper and deeper until we find the goal node or node with no children.
👍1
Dynamic Programming (DP) is an algorithmic technique for solving an optimization problem by breaking it down into simpler sub-problems and taking advantage of the fact that the optimal solution to the overall problem is dependent on the optimal solution to its sub-problems.
✅Grokking the Coding Interview Patterns
Sliding Window
Two Pointers
Fast & Slow Pointers
Merge Intervals
Cyclic Sort
In-place Reversal of a LinkedList
Tree Breadth-First Search
Tree Depth First Search
Two Heaps
Subsets
Modified Binary Search
Bitwise XOR
Top ‘K’ Elements
K-way Merge
0/1 Knapsack
Unbounded Knapsack
Fibonacci Numbers
Palindromic Subsequence
Longest Common Substring
Topological Sort
Trie Traversal
Number of Island
Trial & Error
Union Find
Unique Paths
Sliding Window
Two Pointers
Fast & Slow Pointers
Merge Intervals
Cyclic Sort
In-place Reversal of a LinkedList
Tree Breadth-First Search
Tree Depth First Search
Two Heaps
Subsets
Modified Binary Search
Bitwise XOR
Top ‘K’ Elements
K-way Merge
0/1 Knapsack
Unbounded Knapsack
Fibonacci Numbers
Palindromic Subsequence
Longest Common Substring
Topological Sort
Trie Traversal
Number of Island
Trial & Error
Union Find
Unique Paths
👍3
Recursion is a problem-solving technique in which the solution is dependent on solutions to smaller instances of the same problem. Computing factorials is a classic example of recursive programming.
Every recursive program follows the same basic sequence of steps:
Set up the algorithm. Recursive programs frequently require a seed value, to begin with. This is accomplished by either using a parameter passed to the function or by providing a non-recursive gateway function that sets up the seed values for the recursive calculation.
Check to see if the current value(s) being processed correspond to the base case. If so, process the value and return it.
Rephrase the solution in terms of a smaller or simpler sub-problem or sub-problems.
Apply the algorithm to the sub-problem.
In order to formulate an answer, combine the results.
Return the results.
Every recursive program follows the same basic sequence of steps:
Set up the algorithm. Recursive programs frequently require a seed value, to begin with. This is accomplished by either using a parameter passed to the function or by providing a non-recursive gateway function that sets up the seed values for the recursive calculation.
Check to see if the current value(s) being processed correspond to the base case. If so, process the value and return it.
Rephrase the solution in terms of a smaller or simpler sub-problem or sub-problems.
Apply the algorithm to the sub-problem.
In order to formulate an answer, combine the results.
Return the results.
Hashing is a technique or process that uses a hash function to map keys and values into a hash table. It is done to allow for quicker access to elements. The efficiency of mapping is determined by the hash function’s efficiency.
JavaScript from Frontend to Backend.pdf
7.7 MB
JavaScript from Frontend to Backend
Eric Sarrion, 2022
Eric Sarrion, 2022
The Ultimate Guide to Machine Learning Job Interviews .pdf
2.9 MB
'The Ultimate Guide to Machine Learning Job Interviews '
benjamin-baka-python-data-structures-and-algorithms-2017.pdf
11.5 MB
Python Data Structures and Algorithms
Benjamin Baka, 2017
Benjamin Baka, 2017
❤1👍1