Category Archives: ANDROID

3 Simple ways to use Debouncer in Flutter

By | August 26, 2024

Watch Video Tutorial Using Simple Timer Create a simple debouncer class Implementation: Using ValueNotifier Implementation: Using “Simple Debouncer” package First Add easy_debouncer package in your dependencies https://pub.dev/packages/easy_debounce Source Code https://github.com/MrVipinVijayan/flutter_tutorials/tree/feat/debounce

Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. Find the minimum element in O(log N) time. You may assume the array does not contain duplicates.

By | August 22, 2024

To find the minimum element in a rotated sorted array in O(log⁡N)O(\log N)O(logN) time, you can use a modified binary search approach. The key observation is that even though the array is rotated, one part of the array will still be in sorted order. By comparing elements in the middle of the array with the… Read More »

Given a 2D board of characters and a word, find if the word exists in the grid.

By | August 5, 2024

The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once. For example, given the following board: exists(board, “ABCCED”) returns true, exists(board, “SEE”) returns true, exists(board, “ABCB”) returns false. Python def exist(board, word):    if not board:        return False   … Read More »

What are optionals in swift?

By | March 14, 2024

In Swift, optionals are a powerful feature that allows variables or constants to have a value or be nil, indicating the absence of a value. Optionals are represented using the Optional type, which is an enumeration with two cases: Some(Wrapped) to represent a value, and nil to represent the absence of a value. Here are… Read More »

Implement a stack API using only a heap. A stack implements the following methods:

By | January 31, 2024

Recall that a heap has the following operations: To implement a stack using only a heap, you can use a max heap and maintain a counter to ensure that the order of elements is preserved. Here’s an example implementation in Python, Java, and JavaScript using the heapq module (Python), PriorityQueue (Java), and BinaryHeap (JavaScript): Python:… Read More »

Handling exception in Ruby

By | January 30, 2024

In Ruby, exception handling is done using the begin, rescue, else, and ensure blocks. Here’s a basic structure of a begin-rescue block: Let’s break down the components: Example with a specific exception: In this example: As with any language, it’s good practice to catch only the exceptions you expect and handle them appropriately. Avoid catching… Read More »

How to do exception handling in python?

By | January 29, 2024

Exception handling in Python is done using the try, except, else, and finally blocks. Here’s a basic structure of a try-except block: Let’s break down the components: Example with a specific exception: In this example: You can customize exception handling based on the specific requirements of your code. It’s generally a good practice to catch… Read More »

What are python name spaces?

By | January 27, 2024

In Python, a namespace is a container that holds a set of names (identifiers) and their corresponding objects. It serves as a mapping between names and objects, allowing you to organize and manage the scope of variables, functions, classes, and other identifiers in your code. Namespaces help avoid naming conflicts and provide a way to… Read More »

Given a string of parentheses, find the balanced string that can be produced from it using the minimum number of insertions and deletions

By | January 25, 2024

Given a string of parentheses, find the balanced string that can be produced from it using the minimum number of insertions and deletions. If there are multiple solutions, return any of them. For example, given “(()”, you could return “(())”. Given “))()(“, you could return “()()()()”. To find the balanced string with the minimum number… Read More »

What is inout parameter in swift?

By | January 24, 2024

In Swift, inout is a keyword used to indicate that a parameter is passed by reference and can be modified inside a function, affecting the original value outside the function. This allows a function to modify the value of the parameter and have those changes reflected in the calling scope. Here’s an example to illustrate… Read More »

Common SQL commands with example

By | January 20, 2024

Certainly! SQL (Structured Query Language) is used to interact with relational databases. Here are some common SQL commands with examples: Example: Example: Example: Example: Example: Example: Example: Example: These are just a few examples of common SQL commands. SQL is a powerful language with many features, and its usage can vary depending on the specific… Read More »

Concurrency in Python

By | January 18, 2024

In Python, there are several ways to implement concurrency, allowing you to execute multiple tasks concurrently to improve the performance of your code. Here are some commonly used methods: Threading: Multiprocessing: Asyncio (asynchronous I/O): ThreadPoolExecutor and ProcessPoolExecutor: Choose the concurrency approach that best fits your specific use case, considering factors such as the nature of… Read More »

How to use BlockOperation in swift?

By | January 17, 2024

In Swift, BlockOperation is a subclass of Operation that allows you to encapsulate the code you want to execute concurrently. You can use it to create operations that consist of one or more blocks of code. Here’s an example of how to use BlockOperation: In this example: The OperationQueue takes care of managing the concurrent… Read More »

Write a program to merge two binary trees. Each node in the new tree should hold a value equal to the sum of the values of the corresponding nodes of the input trees. If only one input tree has a node in a given position, the corresponding node in the new tree should match that input node.

By | January 16, 2024

Asked by SalesForce JavaScript: Java: Python: These programs define a TreeNode class and a function (mergeTrees in JavaScript, mergeTrees method in Java, and merge_trees function in Python) to merge two binary trees following the specified rules. You can adapt these examples based on your specific requirements.

How to do navigation and data pass in swiftUI?

By | January 14, 2024

In SwiftUI, navigation is typically handled using the NavigationView and related components. Here’s a basic guide on how to perform navigation in SwiftUI: Basic Navigation with NavigationLink: 2. Creating NavigationLinks: 3. Creating the Destination View: 4. Putting it All Together: Passing Data with NavigationLink: 2. Receiving Data in Destination View:In the destination view, define a… Read More »

What are the difference between UIKit and SwiftUI in iOS?

By | January 14, 2024

UIKit and SwiftUI are both UI frameworks used in iOS development, but they differ significantly in terms of design, architecture, and development approach. Here are some key differences between UIKit and SwiftUI: 1. Declarative vs Imperative 2. UI Layout 3. Code re-usability 4. Live preview 5. UI Representation 6. State management 7. Adoption and Legacy… Read More »

How data is passed from one view to another in SwiftUI?

By | January 13, 2024

In SwiftUI, you can pass data from one view to another using the @State, @Binding, @ObservedObject, or @EnvironmentObject property wrappers. The appropriate choice depends on the nature of the data and the relationship between the views. Below are brief explanations and examples for each approach: 1. @State : Use @State to store simple values within… Read More »