-
8 Patterns Review For Successful Coding Interview
8 Patterns Review For Successful Coding Interview This is nothing but quick 5 min revision before going to interview. Visit https: https://codeandalgo.com for more such contents
-
CAP Theorem
Introduction CAP Theorem In database theory, the CAP theorem, also named Brewer’s theorem after computer scientist Eric Brewer, states that any distributed data store can provide only two of the following three guarantees. Consistency Availability Partition Tolerance What to do when network partition failure occurs ? When a network partition failure happens, it must be decided to do one of the following. Option A…
-
Min Stack
Leetcode#155 Min Stack Problem Statement Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the MinStack class: You must implement a solution with O(1) time complexity for each function. Example 1: Constraints: Logic / Trick Two Stack Since we want to achieve time complexity of O(1) for all operations, we can…
-
Longest Palindromic Substring
Leetcode#5 Longest Palindromic Substring Problem statement Given a string s, return the longest palindromic substring in s. Example 1: Input: s = “babad” Output: “bab” Explanation: “aba” is also a valid answer. Example 2: Input: s = “cbbd” Output: “bb” Constraints: Golang solution 1 Time Complexity: O(n2) Space complexity : O(n) Space Complexity Analysis Overall Space Complexity: where O(n) comes…
-
Group Anagrams
Leetcode#49 Group Anagrams Problem Statement Given an array of strings strs, group the anagrams together. You can return the answer in any order. Example 1: Input: strs = [“eat”,”tea”,”tan”,”ate”,”nat”,”bat”] Output: [[“bat”],[“nat”,”tan”],[“ate”,”eat”,”tea”]] Explanation: Example 2: Input: strs = [“”] Output: [[“”]] Example 3: Input: strs = [“a”] Output: [[“a”]] Constraints: Simple Approach Output Optimised solution Output Please visit https: https://codeandalgo.com for more such contents.
-
Multiply Strings
Leetcode#43 Problem Statement Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Note: You must not use any built-in BigInteger library or convert the inputs to integer directly. Constraints: Logic To solve this problem optimally, you can use an approach inspired by manual multiplication, employing a digit-by-digit multiplication method. Here’s…
-
Valid Anagram
Leetcode#242 Problem Statement Given two strings s and t, return true if t is an anagram of s, and false otherwise. Example 1 Input: s = “anagram”, t = “nagaram” Output: true Example 2 Input: s = “rat”, t = “car” Output: false Constraints: Follow up: What if the inputs contain Unicode characters? How would you adapt your solution to such a case? Golang solution Optimised code Output Please visit https: https://codeandalgo.com for…