Skip to main content


IOS Simulator Crash report

Recent posts

Subsequence check

A subsequence of a string is a new string that is formed from the original string by removing zero or more characters without disturbing the relative positions of the remaining characters. Ex: Original String = ABC Subsequences = "", A, B, C, AB, AC, BC, ABC Characteristics of a Subsequence: 1. Length of subsequence is always less than or equal to the original string. 2. Characters should always appear in the same order as in the original string. 3. The total number of subsequences of a string with length n will be  2 n .  Since for every character we have 2 choices, either to keep it or remove it. func checkIs(subsequence: String , from input: String )-> Bool { guard subsequence. count <= input. count else { return false } var subsequenceIndex = subsequence. startIndex var inputIndex = subsequence. startIndex while inputIndex < input. endIndex && subsequenceIndex < subseque

Palindrome check

A Palindrome is a word, phrase, or sequence that reads the same backward as forward. Ex: RaceCar, madam, mom, level We have two methods to check for a palindrome. 1. Reverse String Comparision: If we reverse a string and compare it with the given string, then if both the strings are equal, we can say the given string is a palindrome. func reversedString(input: String )-> String { var reversed = "" for char in input{ reversed = "\(char)" + reversed } return reversed } func isPalindrome( _ input : String )-> Bool { let reversed = reversedString (input: input) return reversed == input } Time Complexity: θ(n) Space Complexity: θ(n) 2. Character Comparision: We'll start comparing the first character with the last character, if both are equal we'll increment the left index & decrement the right index until we cross the middle character. If we successfully pass the middle character then the given s

Stack Problem - Balancing of Symbols

Stack Problem - Balancing of Symbols Problem: Given an expression string exp , write a program to examine whether the pairs and the orders of “{“,”}”,”(“,”)”,”[“,”]” are correct in exp. Example : Input : exp = “[()]{}{[()()]()}” Output : Balanced Input : exp = “[(])” Output : Not Balanced Algorithm: Create a stack. while ( end of input is not reached ) { If the character read is not a symbol to be balanced, ignore it. If the character is an opening delimiter like ( , {  or [ , PUSH it into the stack. If it is a closing symbol like ) , } , ] , then if the stack is empty report an error, otherwise POP the stack. If the symbol POP-ed is not the corresponding delimiter, report an error. At the end of the input, if the stack is not empty report an error. Implementation : func balancingOfSymbols(string: String )-> Bool { guard string. count > 0 else { return false } let symbols:[ Character : Character ] = [ "{" : "}&qu


What is a Stack ? A Stack ADT is an ordered list in which insertion and deletion are done at the top end of the list. A stack follows LIFO(Last In First Out) Principle i.e, the last element inserted is the first one to be deleted. Why do we need Stack? Well, in many algorithms you want to add objects to a temporary list at some point and then pull them off this list again at a later time. Often the order in which you add and remove these objects matters. Applications of Stack Balancing of symbols Infix-to-Postfix conversion Evaluation of postfix expression Implementing function calls(Recursive) Forward and Backward feature in a browser. Redo & Undo sequence in a text editor. Matching tags in HTML & XML. Used in other algorithms like Tree traversal, Tower of Hanoi, Stock span, N Queens, etc. Stack Operations Main stack operations Push : Inserts data onto stack Pop : Removes and returns the last inserted element from the stack. Auxiliary stack operation

IOS Q&A -The Basics#01

IOS Interview Questions and Answers The Basics#01 1. What are the Key Features of the Swift programming language? Modern : Swift is a result of the latest research on programming languages, combined with decades of experience building Apple platforms. Also, Swift is continuously evolving. Safe : Swift is a type-safe language which means, If we pass a String to a variable of type Int by mistake, then Swift throws a compile-time error. Also, it’s a static programming language i.e. any variable or a constant should be declared or inferred to a specific type at the compile time. Fast : Swift was built to be fast using the incredibly high-performance LLVM compiler technology. There are claims that Swift is 2.6x faster than Objective-C and 8.4x faster than Python. Expressive : Swift is called Syntactic sugar because it makes the language “Sweeter” for developer use. Swift offers a simplified syntax and grammar that is easy to read and write. Open source : In 2015 , Swi

Confused OS Concepts

Difference between MultiProcessor and Multicore Processor? A  multiprocessor   system  contains more than one CPU, allowing them to work in parallel. A  multicore   CPU  has multiple execution cores on one CPU so that multiple cores can work in parallel on separate operations at chip level. Difference between MultiProgramming, MultiTasking, MultiProcessing,      MultiThreading? MultiProgramming: To minimize the CPU Idle time, Multiprogramming was introduced in older days for single core processor. One or more programs are loaded into main memory which are ready to execute still, only one program is able to get the CPU for execution while all others are waiting for their turn. When currently running process is performing an I/O task, then OS may interrupt that process and give the control to another program( process context switching ) loaded in main memory for execution and a running process keeps executing until either it voluntarily releases the CPU or when it blocks for an I