
Table of contents
Writing in progress: If you have any suggestions for improving the content or notice any inaccuracies, please email me at [email protected]. Thanks!
Overview
Having a talent for finding solutions to problems may accelerate our performance and put us ahead of our contemporaries or colleagues. In general, the solutions to certain problems may be accomplished in the blink of an eye, while others might take much more time, even days. As a result, it is essential to approach the programming problems in the appropriate manner in order to save time and effort. Let’s not attempt to solve the problem by using a brute-force approach.
Let’s try different ways to solve each problem, from brute force to finding the most efficient solution.
Problems and solutions
You can find all the code examples here.
Problem 1: Find pair that sums up to “k”
Given an array of integers nums
and an integer k
, create a boolean function that checks if there are two elements in nums
such that we get k
when we add them together.
Problem 2: Find first repeating character in a given string
Given a string str
, create a function that returns the first repeating character. If such character doesn’t exist, return the null character '\0'
.
Problem 3: Remove duplicates from an integer array
Given an array of integers nums
, create a function that returns an array containing the values of nums
without duplicates; the order doesn’t matter.
Conclusion
In my opinion, solutions that are straightforward and simple are preferable to those that use the newest buzzword technology. Let’s not get too excited about new products before discovering if they are flexible, useful, and have any adverse effects.
Comments