How to reverse String in swift?
[Question]: Reverse a string with O(1) extra memory. The input string is given as an array of characters like [“C”, “A”, “R”] So here we have used one for loop which iterates half of array & swapping last with first
Data structure & algorithm using swift language.
[Question]: Reverse a string with O(1) extra memory. The input string is given as an array of characters like [“C”, “A”, “R”] So here we have used one for loop which iterates half of array & swapping last with first
[Link] In Pascal’s triangle, each element is the sum of the two numbers directly above it.
Question: – if on given matrix any element is zero set entire row & column to zero [Link] Approach #2 Here we find the rows & cols which is zero & then iterate over matrix & make that rows and cols as zero
A function which calls itself in the body & solve the problem is called recursion. we will take some example to understand #1 Print numbers from 1 to N Because Print is before recursion function it will print 1 to n #2 Print numbers from N to 1 #3 Sum of first N numbers #4 …