You are given row x col grid representing a map where grid[i][j] = 1 represents land and grid[i][j] = 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells). The island doesn’t have “lakes”, meaning the water inside isn’t connected to the water around the island. One […]

Read More# Category: Coding Problems Page 1 of 3

Given a list of cars traveling from point start to end with speed in the format [start, end, speed]. You need to return the list of smallest intervals (segments) and the average speed of vehicles in each of those intervals. Used for road color coding as per traffic prediction used in google maps or lately uber. The problem involves processing a list of cars […]

Read MoreGiven an array of integers nums, calculate the pivot index of this array. The pivot index is the index where the sum of all the numbers strictly to the left of the index is equal to the sum of all the numbers strictly to the index’s right. If the index is on the left edge […]

Read MoreThe “Group Anagrams” problem is a common coding challenge that is often given to software engineers during technical interviews. Essentially, the problem involves grouping a list of words into sets of anagrams – that is, words that are made up of the same letters but in a different order. For example, the words “listen” and […]

Read MorestrStr() is a function that takes two strings as input, haystack and needle, and returns the index of the first occurrence of needle in haystack, or -1 if needle is not present in haystack. For example, if haystack = “hello world” and needle = “world”, then the function should return 6, because “world” first appears […]

Read MoreA palindrome is a word, phrase, or sequence of characters that reads the same backward as forward. For example, “racecar” is a palindrome because it is spelled the same way forwards and backwards. A valid palindrome is a palindrome that also meets certain conditions. One common condition is that spaces and punctuation marks are ignored […]

Read MoreThe Reverse Integer problem is a programming challenge that asks you to reverse the digits of a given integer. For example, if you’re given the number 123, you should return the number 321. Now, it’s important to note that there are a few rules to keep in mind while solving this problem. For one, you […]

Read More“String to Integer (atoi)” is a coding problem that requires you to convert a given string to its corresponding integer value. Here’s a more detailed explanation of the problem: Problem Statement: Implement the atoi function that converts a string to an integer. The function first discards as many whitespace characters as necessary until the first […]

Read MoreThe Three Sum problem is a well-known problem in computer science that involves finding all unique triplets in an array of integers that add up to a target sum. For example, given the array [1, 2, 3, 4, 5, 6, 7] and a target sum of 10, the solution would be [[1, 2, 7], [1, […]

Read MoreLongest Palindromic Substring refers to finding the longest contiguous substring in a given string that is a palindrome, which is a sequence of characters that reads the same backward as forward. For example, in the string “babad”, the longest palindromic substring is “bab”, which is a palindrome because it reads the same backward as forward. […]

Read More