Big "OH" Before we proceed we must know what the below graph means If you are wondering what it means let me be very straight forward to you. "You have to write your algorithm with time and space complexity near or below the purple line" When someone asks you to calculate Big-O, you do the below things and you are golden : 1. Worst Case Scenario Always consider the worst case scenario. As yourself this, question a million times."What if the input is huge, like a million or a trillion ?" If you have to check no of times a string occurs in an array, you would go for a for loop which will loop through the elements and keep increment a counter, which has a complexity of O(N) where N is the number of inputs. Always think, what will happen when N reaches a million or a trillion. How will your code perform. 2. Remove Constants - I have added the Big-O complexity to the code. Final complexity is 2*O(1) + 2*O(N) If we consider th...
I wonder Why ? #1 W e have "string" and "String" in C# when both does the same thing ? Answer : Answer is fairly simple. string is an alias of String. Hows that ?. To achieve type safety, Microsoft has designed the Managed languages such that they can communicate with each other. For the entire framework we have base types such as System.String and thus their code specific alias such as string in C# and String in VB. When we compile the program in C# it actually refers to System.String(Kinda how alias is suppose to work right) There are plenty of other alias too object : System. Object string : System. String bool : System. Boolean byte : System. Byte ...