-
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
-
Find the Maximum Subarray Sum (Kadane’s Algorithm)
Find the Maximum Subarray Sum LeetCode#54 Given an array of integers, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example Input: [-2,1,-3,4,-1,2,1,-5,4]Output: 6Explanation: The subarray [4,-1,2,1] has the largest sum = 6. Approach Use Kadane’s algorithm, which runs in O(n) time. Golang Code Sample runs Why does the simple check…
-
Array Google Interview Questions
Array Google Interview Questions Google interview questions often focus on algorithmic problem-solving using arrays or slices in Go. Here are a few common types of array-related questions that could be asked: 1. Find the Maximum Subarray Sum (Kadane’s Algorithm) LeetCode#54 Given an array of integers, find the contiguous subarray (containing at least one number) which…
-
Golang UTF 8 Encoding
Golang UTF 8 Encoding Does golang used utf-8 encoding ? Yes, Go (Golang) uses UTF-8 encoding for its strings. Here are some details about how Go handles UTF-8: Key Points Example Code-1 Here’s a simple example showing how Go handles UTF-8 encoding: Output This example shows how UTF-8 encoded bytes are printed, how Unicode runes…
-
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:…
-
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 :…
-
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…