Top Coding Interview Questions

Join our facebook group for important interview tips. TipSeason Facebook Group


Number of Islands Solution (Leetcode 200) - Top Google Coding Interview Question

Given an m x n 2d grid map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting...

Cherry Pickup II (Leetcode 1463) Solution

Given a rows x cols matrix grid representing a field of cherries. Each cell in grid represents the number of cherries that you can collect. You have two robots that can collect cherries for...

Coin Change (Leetcode 322) - Coding Interview Question

You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you...

Count Complete Tree Nodes (Leetcode 222) - Top Google Coding Interview Question

Given a complete binary tree, count the number of nodes. Note: Definition of a complete binary tree from Wikipedia: In a complete binary tree every level, except possibly the last,...

Count of subsets of given Sum Solution - Coding Interview Question

Given an array of integers. Count the number of subsets whose sum of elements equals to sum. Example 1: int[] a = {2, 3, 5, 6, 8, 10} sum =...

Count Of Subsets With Given Difference between subsets - Coding Interview Question

Given an array of integers. Count the number of subsets whose difference between pair of subsets is equals to given difference. Example 1: int[] a = {1,1,2,3} difference = 1...

Course Schedule II (Leetcode 210) - Google Coding Question

There are a total of n courses you have to take labelled from 0 to n - 1. Some courses may have prerequisites, for example, if prerequisites[i] = [ai, bi] this means...

Excel Sheet Column Title (Leetcode 168) - Top Coding Question

Given an integer columnNumber, return its corresponding column title as it appears in an Excel sheet. For example: A -> 1 B -> 2 C -> 3 ... Z ->...

Find Duplicate File in System - (Leetcode 609) - Coding Interview Question

Given a list paths of directory info, including the directory path, and all the files with contents in this directory, return all the duplicate files in the file system in...

Forest Detection - (Binarysearch 527) - Coding Interview Question

You are given a list of lists edges representing an undirected graph. Each list contains (u, v) which means there is an undirected edge between nodes u and v. Return...

Generate Parentheses (Leetcode 22) Solution - Top Interview Question

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example 1: Input: n = 3 Output: ["((()))","(()())","(())()","()(())","()()()"] Example 2: Input: n = 1 Output:...

Is Graph Bipartite (Leetcode 785) Solution - Coding Interview Question

There is an undirected graph with n nodes, where each node is numbered between 0 and n - 1. You are given a 2D array graph, where graph[u] is an...

Longest Common Subsequence (Leetcode 1143) - Coding Interview Question

Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0. A subsequence of a string is a new...

Longest Common Substring - Maximum Length of Repeated Subarray (Leetcode 718) - Coding Interview Question

Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays. Example 1: Input: nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7] Output: 3...

Longest Substring Without Repeating Characters (Leetcode 3) Solution - Top Google, Amazon Interview Question

Given a string s, find the length of the longest substring without repeating characters. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length...

Longest Substring with At Most Two Distinct Characters (Leetcode 159) Solution - Top Google Interview Question

Given a string s, return the length of the longest substring that contains at most two distinct characters. Example 1: Input: s = "eceba" Output: 3 Explanation: The substring is...

Longest Univalue Path - (Leetcode 687) - Coding Interview Question

Given the root of a binary tree, return the length of the longest path, where each node in the path has the same value. This path may or may not...

Meeting Rooms II (Leetcode 253) - Top Google Coding Question

Given an array of meeting time intervals intervals where intervals[i] = [starti, endi], return the minimum number of conference rooms required. Example 1: Input: intervals = [[0,30],[5,10],[15,20]] Output: 2 Example...

Minimum Subset Sum Difference - Coding Interview Question

Given a set of integers, the task is to divide it into two sets S1 and S2 such that the absolute difference between their sums is minimum. If there is...

Network Delay Time - (Leetcode 743) - Coding Interview Question

You are given a network of n nodes, labeled from 1 to n. You are also given times, a list of travel times as directed edges times[i] = (ui, vi,...

Palindrome Permutation II (Leetcode 267) Solution - Coding Interview Question

Given a string s, return all the palindromic permutations (without duplicates) of it. You may return the answer in any order. If s has no palindromic permutation, return an empty...

Partition Equal Subset Sum (Leetcode 416) Solution - Coding Interview Question

Given a non-empty array nums containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal....

Search Insert Position (Leetcode 35) Solution - Top Interview Question

Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it...

Shuffle an Array - (Leetcode 384) - Coding Interview Question

Given an integer array nums, design an algorithm to randomly shuffle the array. All permutations of the array should be equally likely as a result of the shuffling. Implement the...

Subset Sum with target - Coding Interview Question

Given a set of non-negative integers, and a value sum, determine if there is a subset of the given set with sum equal to given target sum. Example: Input: set[]...

Target Sum (Leetcode 494) - Coding Interview Question

You are given an integer array nums and an integer target. You want to build an expression out of nums by adding one of the symbols '+' and '-' before...

Unique Binary Search Trees (Leetcode 96) Solution - Coding Interview Question

Given an integer n, return the number of structurally unique BST's (binary search trees) which has exactly n nodes of unique values from 1 to n.   Example 1: Input:...

Word Ladder (Leetcode 127) Solution - Google Interview Question

A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that: Every...

Word Search (Leetcode 79) - Top Coding Interview Question

Given an m x n grid of characters board and a string word, return true if word exists in the grid. The word can be constructed from letters of sequentially...