Brain Mentors – Brain Mentors Skip to content

Single Number | Arrays | Data Structures and Algorithms

Single Number is a problem statement that is based on arrays from Data Structures and Algorithms. In this problem, we can find the single number that occurs an odd number of times in the given array. The first approach to solve this problem is: Brute Force Algorithm As you can see we have an array with size 5. To find the single number that occurring the odd number of times in this given array. So, we can traverse from left to right side of the array, one by one select each element and compare it with all the remaining elements of the array. If the selected element is equal to any remaining elements of the array, so for this we keep one variable that is count variable which is used to increment it’s value by 1 each time and If the count variable’s value is odd. It means, it is

What is Recursion? | Concepts of Recursion

The process in which a function calls itself is called recursion. Recursion is a method where the solution of a problem depends upon the solutions that are small instances of the same problem.  The diagram shows how recursion works:  Why we need recursion? Any problem can be solved by a recursive method as well as by the iterative method. But whenever we have a problem that is complex to do just by iterative/looping method. Then we are going to divide the problem into a smaller instance of the same problem that means we solve it by the recursive method. Recursion vs Iteration Recursion Iteration Function calls itself. A set of instructions repeatedly executed. For functions For loops Infinite recursion can lead to system crash/stack overflow. Whereas, infinite iteration consumes CPU cycles. The time complexity of recursion can be found by finding the value of the nth recursive call in terms

Leaders In An Array – Data Structures & Algorithms

Leaders in an array is an easy problem of arrays from Data Structures and Algorithms. Leaders in the array mean that element is greater than all its right side elements of the array. So there are two approaches to find the leaders in an array: Brute Force Algorithm  Scan Array from Right 1. Brute Force Algorithm As you can see, we have an array of size 5. In this approach, we can traverse the array from left to right and each element picks one by one and check with all its right side elements of the array, which is used to checking that it is greater or not than its right side elements of the array. So those are greater than their right side elements of the array, then they become the leaders of this given array. The rightmost element is always a leader because there is no element to

Flutter vs React Native – What to Choose?

As mobile hardware is progressing, the demand for mobile apps has started increasing. Software developers were looking for a platform that could make mobile apps fast. Today we are going to talk about React-Native and Flutter. Flutter Flutter is an open source UI (SDK) created by Google. The first version of Flutter was known as codename “Sky”. Flutter framework written in C, C++, and Dart Language. Flutter used to develop mobile app, desktop app and web app. flutter initial release was Alpha(v0.0.6)/May 2017 and now currently stable version of Flutter is (v1.17.0)/May 6 2020. Flutter uses single codebase for Android and iOS platforms. Features of Flutter Flutter is for developers that want a faster way to build beautiful apps, or a way to reach more users with a single investment. Flutter is also for designers that want their original design visions delivered consistently, with high fidelity, to all users. In fact, CodePen now supports Flutter. Flutter

Sign Up and Start Learning