Given a sorted array, find the smallest positive integer that is not the sum of a subset of the array.

By | June 27, 2023

Java public class SmallestPositiveInteger {    public static int findSmallestPositiveInteger(int[] nums) {        int smallest = 1;        for (int num : nums) {            if (num <= smallest) {                smallest += num;            } else… Read More »

Write a program to compute the in-order traversal of a binary tree using O(1) space.

By | June 25, 2023

Python Java Javascript These implementations use the Morris Traversal algorithm to perform in-order traversal without using any additional space other than O(1). The algorithm establishes temporary links between nodes and their predecessors, allowing efficient traversal and processing of the tree nodes. Note: The code examples assume that the tree nodes have a val, left, and… Read More »

Flutter vs. React Native: Unraveling the Performance Battle

By | June 25, 2023

Introduction: When it comes to developing cross-platform mobile applications, Flutter and React Native have emerged as the two dominant frameworks. As developers seek to create high-performing apps, it’s crucial to understand the performance capabilities of each framework. In this article, we will delve into the performance aspects of Flutter and React Native, examining their strengths… Read More »

Different ways of making rounded corner images in flutter

By | June 25, 2023

Example 1: ClipRRect dartCopy codeClipRRect( borderRadius: BorderRadius.circular(10.0), child: Image.asset(‘assets/images/image.jpg’), ) In this example, the ClipRRect widget is used to clip the child Image with rounded corners. The borderRadius property defines the radius of the corners. Example 2: BoxDecoration dartCopy codeContainer( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), image: DecorationImage( image: AssetImage(‘assets/images/image.jpg’), fit: BoxFit.cover, ), ), ) Here, a… Read More »

Given an absolute pathname that may have . or .. as part of it, return the shortest standardized path

By | June 25, 2023

Given an absolute pathname that may have . or .. as part of it, return the shortest standardized path. For example, given “/usr/bin/../bin/./scripts/../”, return “/usr/bin/”. To obtain the shortest standardized path from an absolute pathname that may contain “.” or “..” as part of it, you can follow these steps: Here’s an example Python code… Read More »

Riverpod in Flutter – Simplest Example Ever

By | June 22, 2023

In this example, we create a simple Flutter application that displays a counter and increments the count when a FloatingActionButton is pressed. The state management is handled by Riverpod. Here’s a breakdown of the code: When you run this code, you will see a simple app with an app bar, a counter in the center… Read More »

Connect 4 is a game where opponents take turns dropping red or black discs into a 7 x 6 vertically suspended grid.

By | June 22, 2023

The game ends either when one player creates a line of four consecutive discs of their color (horizontally, vertically, or diagonally), or when there are no more spots left in the grid. Design and implement Connect 4. To design and implement Connect 4, we can follow these steps: Here’s an example implementation of Connect 4… Read More »

Roman numeral format to decimal.

By | June 22, 2023

Given a number in Roman numeral format, convert it to decimal. The values of Roman numerals are as follows: { ‘M’: 1000, ‘D’: 500, ‘C’: 100, ‘L’: 50, ‘X’: 10, ‘V’: 5, ‘I’: 1 } In addition, note that the Roman numeral system uses subtractive notation for numbers such as IV and XL. For the… Read More »

Problem Solving – IP addresses must follow the format A.B.C.D, where A, B, C, and D are numbers between 0 and 255.

By | June 19, 2023

Given a string of digits, generate all possible valid IP address combinations. IP addresses must follow the format A.B.C.D, where A, B, C, and D are numbers between 0 and 255. Zero-prefixed numbers, such as 01 and 065, are not allowed, except for 0 itself. For example, given “2542540123”, you should return [‘254.25.40.123’, ‘254.254.0.123’]. To… Read More »

Custom Theme using Theme Extensions

By | June 25, 2023

Theme extensions were introduced in Flutter 3. But what are Theme Extensions? As the name says, it helps to extend the inbuilt themes with our own extensions. Let’s jump into an example So when you create a flutter app, your basic root widget will look like this return MaterialApp( title: ‘Flutter Theme Extensions’, theme: ThemeData(… Read More »

Flutter Best Practices — Part 2

By | June 28, 2023

1. Avoid Functional Widgets We usually have a situation where we need to separate out UI code from the widget, But we avoid creating a separate widget and use function which returns Widget. This practice have some benefits, like you don’t need to pass all parameters in your new widget, You have less code and less files.… Read More »

Flutter Best Practices — Part 1

By | June 28, 2023

1. Placeholder Widgets Use SizedBox instead of Container as Placeholder widgets. Take a look at the below use-case return _loaded ? Container() : YourWidget(); The SizedBox is a const constructor and creates a fixed-size box. The width and height parameters can be null to indicate that the size of the box should not be constrained in the corresponding dimension.… Read More »

MVVM in Android – ViewModels, ViewModelScope, Retrofit all with a Simple Example.

By | June 6, 2021

Let’s learn how to implement MVVM in Android. It’s actually really simple. ViewModel is just another class that that implements the main Business Logic. ViewModel is a middle man between your view and your Data class(Repo/any Data Provider). It can be represented simply like this. Here the View just displays the data. ViewModel doesn’t know… Read More »

Theming your App in Flutter using BLoc, Save & Reload

By | December 6, 2020

In this article, we will see how we can use BLoc to Theme your app in Flutter. To understand BLoC with a real world example, you can refer to my previous post on BLoC here. Part 1 Part 1 For this demo also we will need the below plugins If you follow my previous tutorial,… Read More »

BLOC Pattern in Flutter explained with Real Example

By | October 5, 2020

In this article we will learn BLoc pattern in flutter for State Management with a simple real world example. Watch Video Tutorial For this example, we will try to consume a web service. The service we are going to use is https://jsonplaceholder.typicode.com/albums What BLoc does? BLoc helps to separate you presentation and business logic. So… Read More »

How to use YouTube APIs and Play YouTube videos in Flutter.

By | August 27, 2020

In this article we are gonna talk about how to use YouTube API’s and play YouTube videos in Flutter. Watch Video Tutorial Add Dependencies Open pubspec.yaml file in your Flutter project and add below dependencies Now, Let’s create two screens Home Screen Video Player Screen In the HomeScreen we will show the list of videos.… Read More »

Local Notifications in Flutter

By | July 4, 2020

Hello everyone, In this article we will learn how to show local notifications in Flutter. What we are going to learn? Show Simple notifications Show Repeated Notifications Show Scheduled Notifications Show Notifications at a particular time and day of a week Show Notification with an attachment Show Notifications with HTML content Cancel a Notification. Cancel… Read More »

Create an awesome background running Music Player like Amazon Music in Flutter

By | June 24, 2020

We all at sometime have played audio in our apps, correct? But we may not have created a complete music player that will run even if the application is not running in the foreground, yes? Watch Video Tutorial So in this article we will see how we can easily create such a music player. Our… Read More »