General kotlin code syntax
#1 Function #2 Named Arguments #3 Function with default argument #4 Triple-quoted strings
General kotlin code syntax Read More »
#1 Function #2 Named Arguments #3 Function with default argument #4 Triple-quoted strings
General kotlin code syntax Read More »
In this article It has explanation how to use async/await with two network callsWe can use an array of Task instances to manage multiple concurrent tasks in Swift. This approach is useful for running multiple network requests in parallel and handling their results collectively. Here’s how you can incorporate an array of Task instances into
Async Await with SwiftUI Read More »
[Question] Count all prime numbers from given nExample Input: n = 10Output: 4Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.Solution: using Sieve of Eratosthenes AlgoThe Sieve of Eratosthenes is an ancient and efficient algorithm for finding all prime numbers up to a specified integer \( n \). It
Count all prime numbers Read More »
In this article I will explain about how log values is being calculated Remember Log 2 8 = 3 which means 2 3 = 8 Example : Log 10 1000 = 4 which means 10 4 = 10,000
Logarithms Explained Read More »
NSUserDefaults, which is now called UserDefaults in Swift, is a mechanism for storing small pieces of data persistently across app launches. It’s typically used for storing user preferences, settings, and other simple data. The reason why UserDefaults can only store class instances and not other types directly is due to its design. UserDefaults is primarily
How to save struct into UserDefaults ? Read More »
SOLID represents 5 five design principles intended to make object-oriented designs more understandable, flexible, and maintainable. Let’s discuss one by one 1. Single Responsibility Principle Every class should have only one responsibilityExample: In below example class UserProfileManager is single responsibility class which has getUserProfile function 2.Open/Closed Principle Software entities such as classes, modules, and functions should be open for
SOLID principles in swift Read More »
[Question]: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.Example: – n = 2. — [“(())”, “()()”] Approach: We can solve using backtracking / recursion
How to generate parentheses Read More »
[Question]: Given a positive integer number N. The task is to generate all the binary strings of N bits. These binary strings should be in ascending order.Example: – Input: 2Output:0 00 11 01 1
How to Generate all the binary strings of N bits? Read More »
[Question]: Given an integer array nums and an integer k, remove all occurrences of k in nums in-place. The order of the elements may be changed. Then return the count after removal Approach: We can declare a variable which holds index initial it’s 0 now move elements which are not matched with k
How to Remove all occurrence of certain number ? Read More »
[Question] Write a program to reverse a stack using recursion.Input: elements present in stack from top to bottom 1 2 3 4 Output: 4 3 2 1
How to Reverse a Stack using Recursion ? Read More »