Category: Interview Questions

Interview Questions

Interview Questions

Product of Array Except Self

LeetCode#238 Problem Statement Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. You must write an algorithm that runs in O(n) time and without using the division operation. Example 1: Input: nums = [1,2,3,4] Output: [24,12,8,6] Example 2: Input: […]

prakashsinghabody@gmail.com 
Interview Questions

GOLANG SLICE

Golang Slice Example Given our buffer array variable from the previous section, we could create a slice that describes elements 100 through 150 (to be precise, 100 through 149, inclusive) by slicing the array: Slice Assignments Empty slice Copy of Slice Passing slices to functions Changing underlying array values Modifying Slice itself Pointers to slices: Method receivers Version-1 : […]

prakashsinghabody@gmail.com 
Interview Questions

Reverse words in string

Problem Statment Leetcode #151 Given an input string s, reverse the order of the words. A word is defined as a sequence of non-space characters. The words in s will be separated by at least one space. Return a string of the words in reverse order concatenated by a single space. Note that s may contain leading or trailing spaces or multiple spaces between two words. The […]

prakashsinghabody@gmail.com 
Interview Questions

Golang Channel

Golang Channel Send & Receive Golang Channel Buffered Channels Use Cases Advantages Example Unbuffered Channel Use Cases Advantages Example When to Use Each Real-World Scenarios Conclusion Both unbuffered and buffered channels have their place in real-world Go programming. The choice depends on whether you need tight synchronization or more flexibility and decoupling in your concurrent […]

prakashsinghabody@gmail.com 
Interview Questions

Strings

Slice vs Array In Go, the syntax for arrays and slices differs, and the presence or absence of a number within the square brackets ([]) distinguishes them: Array Slice To summarize: Slices in Go are more commonly used due to their flexibility, while arrays are used when you need a fixed-size collection. Golang Strings Copy […]

prakashsinghabody@gmail.com 
Interview Questions

Reverse Vowels of a String

Problem Statement LeetCode#345 Given a string s, reverse only all the vowels in the string and return it. The vowels are ‘a’, ‘e’, ‘i’, ‘o’, and ‘u’, and they can appear in both lower and upper cases, more than once. Example 1: Input: s = “hello” Output: “holle” Example 2: Input: s = “leetcode” Output: “leotcede” Constraints: Golang Code Reverse Vowels […]

prakashsinghabody@gmail.com