Skip to content
JaneshSwift.com
JaneshSwift
  • Home
  • Swift
  • SwiftUI
  • DSA
    • Array-Strings
    • BinarySearch
    • String
    • Math
    • Sorting
    • StacksQueues
    • LinkedList
    • Recursion
    • DynamicProgramming
  • Android
  • About us
JaneshSwift.com
JaneshSwift

How to check if the given number is Armstrong ?

Array-Strings

[Question]: Check if given number is Armstrong. for example : 371 =  3 pow 3 + 7 pow 3 + 1 pow 3 = 371 The count of digits to power of each digits & sum is equivalent to self number. (pow id power )

How to check if the given number is Armstrong ? Read More »

How to find GCD of two numbers ?

Array-Strings

[Question]: There is two number find the Greatest common divisor example 3,6 – GCD is 3Better Approach using Euclidean algorithm Here we used recursion which swap the params with second argument as modulo divisor.The space complexity is O(log(min(a,b))) as well, due to the recursive calls being placed on the call stack. Each recursive call consumes

How to find GCD of two numbers ? Read More »

How to print Patterns in swift ?

Array-Strings

Below are the example code for various type of patterns in swift language. Reference Link: Take You Forward

How to print Patterns in swift ? Read More »

How to sort 0s 1s & 2s for an array in swift?

Array-Strings

[Question]: In a given array sort all 0s 1s & 2s .For example: I/P {0, 1, 2, 0, 1, 2} o/p:: {0, 0, 1, 1, 2, 2}Solution:- We can use three pointers low, mid & high. Where low & mid is start index(i.e. 0) & high is arrayLength – 1. In a while loop we

How to sort 0s 1s & 2s for an array in swift? Read More »

How to write a do while loop in swift ?

iOS, Swift

We can use repeat-while which is equivalent to do-while loop in swift. Here the single passthrough will happens first after that condition will be verified

How to write a do while loop in swift ? Read More »

How to add attributed string swift ?

iOS, Swift

If you have two diffrent string and want to have diffrent text style like colours, font then you can use NSAttributedString which can customise. In below example i have joined two string with diffrent fonts, colours into same label.

How to add attributed string swift ? Read More »

Frog jump in swift || How to find min energy required ?

DSA, DynamicProgramming

[Question] Find minimum total energy used by frog to reach from 1st stair to nth stair. He can jump from i+1 or i+2 stair.

Frog jump in swift || How to find min energy required ? Read More »

How to get nth Fibonacci number in swift using dynamic programming ?

DSA

Fibonacci is series of numbers like 0 1 1 2 3 5… Actually its sum of previous two elements. In this article we discuss 3 method to get nth fibonacci number #1 Using Dynamic programming Store computed result into array so whenever next fib(.. called we are using that value. In short we can say

How to get nth Fibonacci number in swift using dynamic programming ? Read More »

How to count number of digits ?

Array-Strings, DSA

The good approach will be to use log10 Time complexity O(1) Space complexity O(1) . The number of digits in an integer = the upper bound of log10(n).Example: log10(12345.0)) = > 4.091491094267951 so we have to use 4+1 Read more about Logarithm here https://janeshswift.com/ios/dsa/math/logarithms-explained/

How to count number of digits ? Read More »

How to log a method’s execution time in Xcode ?

iOS, Swift

We often required to calculate how much time xcode required for execute certain chunk of code. Fortunately there is a workaround which might be used is `CFAbsoluteTimeGetCurrent()`Here i have used Big O(n^2) Time complexity you can change values & test it over xcode.

How to log a method’s execution time in Xcode ? Read More »

← Previous 1 … 11 12 13 … 18 Next →
  • Home
  • Swift
  • SwiftUI
  • DSA
    • Array-Strings
    • BinarySearch
    • String
    • Math
    • Sorting
    • StacksQueues
    • LinkedList
    • Recursion
    • DynamicProgramming
  • Android
  • About us
Search
Search

Copyright © 2025 JaneshSwift | Powered by JaneshSwift

  • Privacy Policy
  • Terms & Conditions
  • About us
  • Contact us
  • Sitemap