-
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
-
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…
-
LRU Cache
Leetcode#146 Problem Statement Logic The secret to breaking down problems and avoiding overly complicated logic lies in systematic thinking and modularization. Here’s a structured approach to develop this mindset: 1. Understand the Problem Deeply 2. Decompose the Problem 3. Make Logic Explicit 4. Think Iteratively 5. Ask: “What Can Go Wrong?” 6. Practice Modularization 7….
-
Design an ATM Machine
Leetcode#2241 Design an ATM Machine When withdrawing, the machine prioritizes using banknotes of larger values. Implement the ATM class: Example 1: Constraints: Golang Code Output Please visit https: https://codeandalgo.com for more such contents.