Category: Interview Questions

Interview Questions

Interview Questions

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 […]

prakashsinghabody@gmail.com 
Interview Questions

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. […]

prakashsinghabody@gmail.com 
Interview Questions

Design Authentication Manager

Leetcode#1797 Problem Statement There is an authentication system that works with authentication tokens. For each session, the user will receive a new authentication token that will expire timeToLive seconds after the currentTime. If the token is renewed, the expiry time will be extended to expire timeToLive seconds after the (potentially different) currentTime. Implement the AuthenticationManager class: Note that if a token expires at time t, and […]

prakashsinghabody@gmail.com 
Interview Questions

Design Browser History

Leetcode#1472 Problem Statement You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: Example Constraints: Logic Golang Code Output Optimised Solution Please visit https: https://codeandalgo.com for more such contents.

prakashsinghabody@gmail.com 
Interview Questions

Design Memory Allocator

Leetcode#2502 Problem Statement You are given an integer n representing the size of a 0-indexed memory array. All memory units are initially free. You have a memory allocator with the following functionalities: Note that: Implement the Allocator class: Example 1: Input [“Allocator”, “allocate”, “allocate”, “allocate”, “freeMemory”, “allocate”, “allocate”, “allocate”, “freeMemory”, “allocate”, “freeMemory”] [[10], [1, 1], [1, 2], [1, 3], [2], [3, 4], […]

prakashsinghabody@gmail.com 
Interview Questions

Design Twitter

Leetcode#355 Problem Statement Design a simplified version of Twitter where users can post tweets, follow/unfollow another user, and is able to see the 10 most recent tweets in the user’s news feed. Implement the Twitter class: Example 1: Input [“Twitter”, “postTweet”, “getNewsFeed”, “follow”, “postTweet”, “getNewsFeed”, “unfollow”, “getNewsFeed”] [[], [1, 5], [1], [1, 2], [2, 6], [1], [1, 2], [1]] […]

prakashsinghabody@gmail.com 
Interview Questions

Rest API Golang

Rest API Golang API URL Hello World ! How to run Verify Marshalling Data structure to Json Representation Basic code Response Wrong Content Type We observe context type as text, but is should be json. Correct JSON Content Type Updated Code Corrected Response With Updated json tags XML encoding Output Client Side Request Header Output […]

prakashsinghabody@gmail.com 
Interview Questions

Golang Performance Benchmarking

Golang Performance Benchmarking Command Example Fibonacci number Benchmarking Results Explanation 1. Environment Information 2. Package Information 3. Benchmark Results For each benchmark function, you get the following details: a. BenchmarkFibo-8 This is the benchmark for your fibo function: b. BenchmarkFiboOptimized-8 This is the benchmark for your fiboOptimized function: 4. Thread Parallelism The -8 suffix (e.g., […]

prakashsinghabody@gmail.com