repo stringclasses 1k
values | file_url stringlengths 96 373 | file_path stringlengths 11 294 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 6
values | commit_sha stringclasses 1k
values | retrieved_at stringdate 2026-01-04 14:45:56 2026-01-04 18:30:23 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/ValidParentheses.java | company/facebook/ValidParentheses.java | // Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
// The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not.
public class ValidParentheses {
public boolean isValid(String s) {
if(s.le... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/RemoveDuplicatesFromSortedArray.java | company/facebook/RemoveDuplicatesFromSortedArray.java | // Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.
// Do not allocate extra space for another array, you must do this in place with constant memory.
// For example,
// Given input array nums = [1,1,2],
// Your function should return length = 2, ... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/WallsAndGates.java | company/facebook/WallsAndGates.java | // You are given a m x n 2D grid initialized with these three possible values.
// -1 - A wall or an obstacle.
// 0 - A gate.
// INF - Infinity means an empty room. We use the value 231 - 1 = 2147483647 to represent INF as you may assume that the distance to a gate is less than 2147483647.
// Fill each empty room with ... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/RomanToInteger.java | company/facebook/RomanToInteger.java | // Given a roman numeral, convert it to an integer.
// Input is guaranteed to be within the range from 1 to 3999
public class RomanToInteger {
public int romanToInt(String s) {
HashMap<Character, Integer> map = new HashMap<Character, Integer>();
map.put('I', 1);
map.put('V', 5);
... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/BinarySearchTreeIterator.java | company/facebook/BinarySearchTreeIterator.java | // Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.
// Calling next() will return the next smallest number in the BST.
// Note: next() and hasNext() should run in average O(1) time and uses O(h) memory, where h is the height of the tree.
/**
* Def... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/SortColors.java | company/facebook/SortColors.java | // Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.
// Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively.
// Note:
// You are not suppose to use th... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/FirstBadVersion.java | company/facebook/FirstBadVersion.java | // You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.
// Suppose you have n versions [1, 2, ..., n] ... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/ProductOfArrayExceptSelf.java | company/facebook/ProductOfArrayExceptSelf.java | // Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].
// Solve it without division and in O(n).
// For example, given [1,2,3,4], return [24,12,8,6].
// Follow up:
// Could you solve it with constant space comp... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/MinimumWindowSubstring.java | company/facebook/MinimumWindowSubstring.java | // Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).
// For example,
// S = "ADOBECODEBANC"
// T = "ABC"
// Minimum window is "BANC".
// Note:
// If there is no such window in S that covers all characters in T, return the empty string "".
// ... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/BinaryTreePaths.java | company/facebook/BinaryTreePaths.java | // Given a binary tree, return all root-to-leaf paths.
// For example, given the following binary tree:
// 1
// / \
// 2 3
// \
// 5
// All root-to-leaf paths are:
// ["1->2->5", "1->3"]
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* Tr... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/GroupAnagrams.java | company/facebook/GroupAnagrams.java | // Given an array of strings, group anagrams together.
// For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"],
// Return:
// [
// ["ate", "eat","tea"],
// ["nat","tan"],
// ["bat"]
// ]
// Note: All inputs will be in lower-case.
public class GroupAnagrams {
public List<List<String>> groupAnagra... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/Subsets.java | company/facebook/Subsets.java | // Given a set of distinct integers, nums, return all possible subsets.
// Note: The solution set must not contain duplicate subsets.
// For example,
// If nums = [1,2,3], a solution is:
// [
// [3],
// [1],
// [2],
// [1,2,3],
// [1,3],
// [2,3],
// [1,2],
// []
// ]
public class Subsets {
publ... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/MeetingRooms.java | company/facebook/MeetingRooms.java | // Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all meetings.
// For example,
// Given [[0, 30],[5, 10],[15, 20]],
// return false.
/**
* Definition for an interval.
* public class Interval {
* int start;
* i... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/RemoveInvalidParentheses.java | company/facebook/RemoveInvalidParentheses.java | // Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.
// Note: The input string may contain letters other than the parentheses ( and ).
// Examples:
// "()())()" -> ["()()()", "(())()"]
// "(a)())()" -> ["(a)()()", "(a())()"]
// ")(" -> [""]
public ... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/WordBreak.java | company/facebook/WordBreak.java | // Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. You may assume the dictionary does not contain duplicate words.
// For example, given
// s = "leetcode",
// dict = ["leet", "cod... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/SubsetsII.java | company/facebook/SubsetsII.java | // Given a collection of integers that might contain duplicates, nums, return all possible subsets.
// Note: The solution set must not contain duplicate subsets.
// For example,
// If nums = [1,2,2], a solution is:
// [
// [2],
// [1],
// [1,2,2],
// [2,2],
// [1,2],
// []
// ]
public class SubsetsI... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/InsertInterval.java | company/facebook/InsertInterval.java | // Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).
// You may assume that the intervals were initially sorted according to their start times.
// Example 1:
// Given intervals [1,3],[6,9], insert and merge [2,5] in as [1,5],[6,9].
// Example 2:
// Given [1,2],[... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/PaintHouseII.java | company/facebook/PaintHouseII.java | // There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.
// The cost of painting each house with a certain color is represented by a n... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/FlattenNestedListIterator.java | company/facebook/FlattenNestedListIterator.java | // Given a nested list of integers, implement an iterator to flatten it.
// Each element is either an integer, or a list -- whose elements may also be integers or other lists.
// Example 1:
// Given the list [[1,1],2,[1,1]],
// By calling next repeatedly until hasNext returns false, the order of elements returned by... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/SparseMatrixMultiplication.java | company/facebook/SparseMatrixMultiplication.java | // Given two sparse matrices A and B, return the result of AB.
// You may assume that A's column number is equal to B's row number.
// Example:
// A = [
// [ 1, 0, 0],
// [-1, 0, 3]
// ]
// B = [
// [ 7, 0, 0 ],
// [ 0, 0, 0 ],
// [ 0, 0, 1 ]
// ]
// | 1 0 0 | | 7 0 0 | | 7 0 0 |
// AB = | -1... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/PalindromeLinkedList.java | company/facebook/PalindromeLinkedList.java | /**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
public class PalindromeLinkedList {
public boolean isPalindrome(ListNode head) {
if(head == null || head.next == null) {
return true;
}
... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/ExclusiveTimeOfFunctions.java | company/facebook/ExclusiveTimeOfFunctions.java | //Given the running logs of n functions that are executed in a nonpreemptive single threaded CPU, find the exclusive time of these functions.
//Each function has a unique id, start from 0 to n-1. A function may be called recursively or by another function.
//A log is a string has this format : function_id:start_or_en... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/SquareRootX.java | company/facebook/SquareRootX.java | // Implement int sqrt(int x).
// Compute and return the square root of x.
public class SquareRootX {
public int mySqrt(int x) {
if(x == 0) {
return 0;
}
int left = 1;
int right = x;
while(left <= right) {
int mid = left + (right - l... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/CombinationSumIV.java | company/facebook/CombinationSumIV.java | // Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.
// Example:
// nums = [1, 2, 3]
// target = 4
// The possible combination ways are:
// (1, 1, 1, 1)
// (1, 1, 2)
// (1, 2, 1)
// (1, 3)
// (2, 1, 1)
// (2, 2)
// (... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/LongestConsecutiveSequence.java | company/facebook/LongestConsecutiveSequence.java | // Given an unsorted array of integers, find the length of the longest consecutive elements sequence.
// For example,
// Given [100, 4, 200, 1, 3, 2],
// The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4.
// Your algorithm should run in O(n) complexity.
class LongestConsecutiveSequence ... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/LowestCommonAncestorOfABinaryTree.java | company/facebook/LowestCommonAncestorOfABinaryTree.java | // Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
// According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes v and w as the lowest node in T that has both v and w as descendants (where we allow a node to be a descendant of it... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/PowerOfXToTheN.java | company/facebook/PowerOfXToTheN.java | // Implement pow(x, n).
public class PowerOfXToTheN {
public double myPow(double x, int n) {
if(n == 0) {
return 1;
}
if(Double.isInfinite(x)) {
return 0;
}
if(n < 0) {
n = -n;
x = 1 / x;
}
... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/AddBinary.java | company/facebook/AddBinary.java | // Given two binary strings, return their sum (also a binary string).
// For example,
// a = "11"
// b = "1"
// Return "100"
public class AddBinary {
public String addBinary(String a, String b) {
StringBuilder result = new StringBuilder();
int carry = 0;
int i = a.length(... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/SumOfLeftLeaves.java | company/facebook/SumOfLeftLeaves.java | // Find the sum of all left leaves in a given binary tree.
// Example:
// 3
// / \
// 9 20
// / \
// 15 7
// There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* Tre... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/BinaryTreeLevelOrderTraversal.java | company/facebook/BinaryTreeLevelOrderTraversal.java | // Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).
// For example:
// Given binary tree [3,9,20,null,null,15,7],
// 3
// / \
// 9 20
// / \
// 15 7
// return its level order traversal as:
// [
// [3],
// [9,20],
// [15,7]
/... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/WordSearch.java | company/facebook/WordSearch.java | // Given a 2D board and a word, find if the word exists in the grid.
// The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once.
// For example,
// Given board =
// [
// ['A'... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/SearchInRotatedSortedArray.java | company/facebook/SearchInRotatedSortedArray.java | // Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
// (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
// You are given a target value to search. If found in the array return its index, otherwise return -1.
// You may assume no duplicate exists in the array.
public cl... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/ValidateBinarySearchTree.java | company/facebook/ValidateBinarySearchTree.java | // Given a binary tree, determine if it is a valid binary search tree (BST).
// Assume a BST is defined as follows:
// The left subtree of a node contains only nodes with keys less than the node's key.
// The right subtree of a node contains only nodes with keys greater than the node's key.
// Both the left and right... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/facebook/ValidPalindrome.java | company/facebook/ValidPalindrome.java | public class ValidPalindrome {
public boolean isPalindrome(String s) {
int left = 0;
int right = s.length() - 1;
while(left < right) {
while(!Character.isLetterOrDigit(s.charAt(left)) && left < right) {
left++;
}
while(!Character.... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/airbnb/MergeKSortedLists.java | company/airbnb/MergeKSortedLists.java | // Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
public class MergeKSortedLists {
public ListNode mergeKLists(... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/airbnb/TwoSum.java | company/airbnb/TwoSum.java | // Given an array of integers, return indices of the two numbers such that they add up to a specific target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// Example:
// Given nums = [2, 7, 11, 15], target = 9,
// Because nums[0] + nums[1] = 2 + 7 = 9,... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/airbnb/AddTwoNumbers.java | company/airbnb/AddTwoNumbers.java | // You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
// You may assume the two numbers do not contain any leading zero, except the number 0 itself.
... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/airbnb/ContainsDuplicatesII.java | company/airbnb/ContainsDuplicatesII.java | //Given an array of integers and an integer k, find out whether there are two distinct indices i and
//j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at most k.
class ContainsDuplicatesII {
public boolean containsNearbyDuplicate(int[] nums, int k) {
HashMap<Integ... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/airbnb/RegularExpressionMatching.java | company/airbnb/RegularExpressionMatching.java | // Implement regular expression matching with support for '.' and '*'.
// '.' Matches any single character.
// '*' Matches zero or more of the preceding element.
// The matching should cover the entire input string (not partial).
// The function prototype should be:
// bool isMatch(const char *s, const char *p)
// ... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/airbnb/ValidParentheses.java | company/airbnb/ValidParentheses.java | // Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
// The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not.
public class ValidParentheses {
public boolean isValid(String s) {
if(s.le... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/airbnb/ConvertSortedArrayToBinarySearchTree.java | company/airbnb/ConvertSortedArrayToBinarySearchTree.java | // Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public TreeNode... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/airbnb/HouseRobber.java | company/airbnb/HouseRobber.java | // You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/airbnb/ContainsDuplicate.java | company/airbnb/ContainsDuplicate.java | //Given an array of integers, find if the array contains any duplicates. Your function should return
//true if any value appears at least twice in the array, and it should return false if every element is distinct.
class ContainsDuplicate {
public boolean containsDuplicate(int[] nums) {
HashMap<Integer, I... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/bloomberg/LinkedListCycle.java | company/bloomberg/LinkedListCycle.java | //Given a linked list, determine if it has a cycle in it.
//Follow up:
//Can you solve it without using extra space?
/**
* Definition for singly-linked list.
* class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
* val = x;
* next = null;
* }
* }
*/
public class Sol... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/bloomberg/FirstUniqueCharacterInAString.java | company/bloomberg/FirstUniqueCharacterInAString.java | //Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.
//
//Examples:
//
//s = "leetcode"
//return 0.
//
//s = "loveleetcode",
//return 2.
//Note: You may assume the string contain only lowercase letters.
class FirstUniqueCharacterInAString {
public in... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/bloomberg/ReverseWordsInAString.java | company/bloomberg/ReverseWordsInAString.java | //Given an input string, reverse the string word by word.
//For example,
//Given s = "the sky is blue",
//return "blue is sky the".
public class ReverseWordsInAString {
public String reverseWords(String s) {
String[] words = s.trim().split("\\s+");
String result = "";
for(int i = words.leng... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/bloomberg/UniquePaths.java | company/bloomberg/UniquePaths.java | //A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
//
//The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).
//
//How many possible unique paths are ther... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/bloomberg/MinStack.java | company/bloomberg/MinStack.java | //Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
//push(x) -- Push element x onto stack.
//pop() -- Removes the element on top of the stack.
//top() -- Get the top element.
//getMin() -- Retrieve the minimum element in the stack.
/**
* Your MinStack object will be in... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/bloomberg/LongestPalindromicSubstring.java | company/bloomberg/LongestPalindromicSubstring.java | //Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
//Example:
//Input: "babad"
//Output: "bab"
//Note: "aba" is also a valid answer.
//Example:
//Input: "cbbd"
//Output: "bb"
class LongestPalindromicSubstring {
public String longestPalindrome(St... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/ReverseLinkedList.java | company/uber/ReverseLinkedList.java | // Reverse a singly linked list.
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
public class ReverseLinkedList {
public ListNode reverseList(ListNode head) {
if(head == null) {
return head;
... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/DecodeWays.java | company/uber/DecodeWays.java | // A message containing letters from A-Z is being encoded to numbers using the following mapping:
// 'A' -> 1
// 'B' -> 2
// ...
// 'Z' -> 26
// Given an encoded message containing digits, determine the total number of ways to decode it.
// For example,
// Given encoded message "12", it could be decoded as "AB" (1 2... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/MergeKSortedLists.java | company/uber/MergeKSortedLists.java | // Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
public class MergeKSortedLists {
public ListNode mergeKLists(... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/EncodeAndDecodeTinyURL.java | company/uber/EncodeAndDecodeTinyURL.java | //TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl
//and it returns a short URL such as http://tinyurl.com/4e9iAk.
//
//Design the encode and decode methods for the TinyURL service. There is no restriction on how your
//encode/decode algorithm should work.... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/OneEditDistance.java | company/uber/OneEditDistance.java | // Given two strings S and T, determine if they are both one edit distance apart.
public class OneEditDistance {
public boolean isOneEditDistance(String s, String t) {
//iterate through the length of the smaller string
for(int i = 0; i < Math.min(s.length(), t.length()); i++) {
//if the... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/ImplementTrie.java | company/uber/ImplementTrie.java | // Implement a trie with insert, search, and startsWith methods.
// Note:
// You may assume that all inputs are consist of lowercase letters a-z.
// Your Trie object will be instantiated and called as such:
// Trie trie = new Trie();
// trie.insert("somestring");
// trie.search("key");
class TrieNode {
HashMap<C... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/TwoSum.java | company/uber/TwoSum.java | // Given an array of integers, return indices of the two numbers such that they add up to a specific target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// Example:
// Given nums = [2, 7, 11, 15], target = 9,
// Because nums[0] + nums[1] = 2 + 7 = 9,... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/CloneGraph.java | company/uber/CloneGraph.java | // Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.
// OJ's undirected graph serialization:
// Nodes are labeled uniquely.
// We use # as a separator for each node, and , as a separator for node label and each neighbor of the node.
// As an example, consider the serializ... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/GroupShiftedStrings.java | company/uber/GroupShiftedStrings.java | // Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequence:
// "abc" -> "bcd" -> ... -> "xyz"
// Given a list of strings which contains only lowercase alphabets, group all strings that belong to the same shifting sequence.... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/GenerateParentheses.java | company/uber/GenerateParentheses.java | class GenerateParentheses {
public List<String> generateParenthesis(int n) {
List<String> result = new ArrayList<String>();
generateParenthesisRecursive(result, "", 0, 0, n);
return result;
}
public void generateParenthesisRecursive(List<String> result, String current, ... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/LetterCombinationsOfAPhoneNumber.java | company/uber/LetterCombinationsOfAPhoneNumber.java | // Given a digit string, return all possible letter combinations that the number could represent.
// A mapping of digit to letters (just like on the telephone buttons) is given below.
// 2 - abc
// 3 - def
// 4 - ghi
// 5 - jkl
// 6 - mno
// 7 - pqrs
// 8 - tuv
// 9 - wxyz
// Input:Digit string "23"
// Output: ["ad"... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/PalindromePermutation.java | company/uber/PalindromePermutation.java | public class PalindromePermutation {
public boolean canPermutePalindrome(String s) {
char[] characters = new char[256];
for(int i = 0; i < s.length(); i++) {
characters[s.charAt(i)]++;
}
int oddCount = 0;
for(int i = 0; i < characters.le... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/MaximumDepthOfABinaryTree.java | company/uber/MaximumDepthOfABinaryTree.java | // Given a binary tree, find its maximum depth.
// The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x)... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/MinStack.java | company/uber/MinStack.java | //Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
//push(x) -- Push element x onto stack.
//pop() -- Removes the element on top of the stack.
//top() -- Get the top element.
//getMin() -- Retrieve the minimum element in the stack.
/**
* Your MinStack object will be in... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/RegularExpressionMatching.java | company/uber/RegularExpressionMatching.java | // Implement regular expression matching with support for '.' and '*'.
// '.' Matches any single character.
// '*' Matches zero or more of the preceding element.
// The matching should cover the entire input string (not partial).
// The function prototype should be:
// bool isMatch(const char *s, const char *p)
// ... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/SpiralMatrix.java | company/uber/SpiralMatrix.java | //Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
//
//Example 1:
//
//Input:
//[
//[ 1, 2, 3 ],
//[ 4, 5, 6 ],
//[ 7, 8, 9 ]
//]
//Output: [1,2,3,6,9,8,7,4,5]
//Example 2:
//
//Input:
//[
//[1, 2, 3, 4],
//[5, 6, 7, 8],
//[9,10,11,12]
//]
//Output: [1,2... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/InsertDeleteGetRandomO1.java | company/uber/InsertDeleteGetRandomO1.java | //Design a data structure that supports all following operations in average O(1) time.
//insert(val): Inserts an item val to the set if not already present.
//remove(val): Removes an item val from the set if present.
//getRandom: Returns a random element from current set of elements. Each element must have the same pr... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/RomanToInteger.java | company/uber/RomanToInteger.java | // Given a roman numeral, convert it to an integer.
// Input is guaranteed to be within the range from 1 to 3999
public class RomanToInteger {
public int romanToInt(String s) {
HashMap<Character, Integer> map = new HashMap<Character, Integer>();
map.put('I', 1);
map.put('V', 5);
... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/MinimumWindowSubstring.java | company/uber/MinimumWindowSubstring.java | // Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).
// For example,
// S = "ADOBECODEBANC"
// T = "ABC"
// Minimum window is "BANC".
// Note:
// If there is no such window in S that covers all characters in T, return the empty string "".
// ... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/ValidSudoku.java | company/uber/ValidSudoku.java | //Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. (http://sudoku.com.au/TheRules.aspx)
//The Sudoku board could be partially filled, where empty cells are filled with the character '.'.
//A partially filled sudoku which is valid.
//Note:
//A valid Sudoku board (partially filled) is not necess... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/GroupAnagrams.java | company/uber/GroupAnagrams.java | // Given an array of strings, group anagrams together.
// For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"],
// Return:
// [
// ["ate", "eat","tea"],
// ["nat","tan"],
// ["bat"]
// ]
// Note: All inputs will be in lower-case.
public class GroupAnagrams {
public List<List<String>> groupAnagra... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/Subsets.java | company/uber/Subsets.java | // Given a set of distinct integers, nums, return all possible subsets.
// Note: The solution set must not contain duplicate subsets.
// For example,
// If nums = [1,2,3], a solution is:
// [
// [3],
// [1],
// [2],
// [1,2,3],
// [1,3],
// [2,3],
// [1,2],
// []
// ]
public class Subsets {
publ... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/WordBreak.java | company/uber/WordBreak.java | // Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. You may assume the dictionary does not contain duplicate words.
// For example, given
// s = "leetcode",
// dict = ["leet", "cod... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/BestTimeToBuyOrSellStock.java | company/uber/BestTimeToBuyOrSellStock.java | // Say you have an array for which the ith element is the price of a given stock on day i.
// If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.
// Example 1:
// Input: [7, 1, 5, 3, 6, 4]
// Output: 5
// max. d... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/ExclusiveTimeOfFunctions.java | company/uber/ExclusiveTimeOfFunctions.java | //Given the running logs of n functions that are executed in a nonpreemptive single threaded CPU, find the exclusive time of these functions.
//Each function has a unique id, start from 0 to n-1. A function may be called recursively or by another function.
//A log is a string has this format : function_id:start_or_en... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/SearchInRotatedSortedArray.java | company/uber/SearchInRotatedSortedArray.java | // Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
// (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
// You are given a target value to search. If found in the array return its index, otherwise return -1.
// You may assume no duplicate exists in the array.
public cl... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/uber/ValidPalindrome.java | company/uber/ValidPalindrome.java | public class ValidPalindrome {
public boolean isPalindrome(String s) {
int left = 0;
int right = s.length() - 1;
while(left < right) {
while(!Character.isLetterOrDigit(s.charAt(left)) && left < right) {
left++;
}
while(!Character.... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/BinaryTreeVerticalOrderTraversal.java | company/google/BinaryTreeVerticalOrderTraversal.java | // Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column).
// If two nodes are in the same row and column, the order should be from left to right.
// Examples:
// Given binary tree [3,9,20,null,null,15,7],
// 3
// /\
// / \
// 9 20
// /\... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/PacificAtlanticWaterFlow.java | company/google/PacificAtlanticWaterFlow.java | // Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top edges of the matrix and the "Atlantic ocean" touches the right and bottom edges.
// Water can only flow in four directions (up, down, left, or right) from a cell to a... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/IslandPerimeter.java | company/google/IslandPerimeter.java | // You are given a map in form of a two-dimensional integer grid where 1 represents land and 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 hav... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/ClosestBinarySearchTreeValue.java | company/google/ClosestBinarySearchTreeValue.java | // Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target.
// Note:
// Given target value is a floating point.
// You are guaranteed to have only one unique value in the BST that is closest to the target.
/**
* Definition for a binary tree node.
* public c... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/ExpressionAddOperators.java | company/google/ExpressionAddOperators.java | // Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the digits so they evaluate to the target value.
// Examples:
// "123", 6 -> ["1+2+3", "1*2*3"]
// "232", 8 -> ["2*3+2", "2+3*2"]
// "105", 5 -> ["1*0+5","10-5"]
// "00"... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/WordSquares.java | company/google/WordSquares.java | // Given a set of words (without duplicates), find all word squares you can build from them.
// A sequence of words forms a valid word square if the kth row and column read the exact same string, where 0 ≤ k < max(numRows, numColumns).
// For example, the word sequence ["ball","area","lead","lady"] forms a word squar... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/NumberOfIslands.java | company/google/NumberOfIslands.java | // Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.
// Example 1:
// 11110
// 11010
// 11000
// 00000
// Answe... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/EncodeAndDecodeTinyURL.java | company/google/EncodeAndDecodeTinyURL.java | //TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl
//and it returns a short URL such as http://tinyurl.com/4e9iAk.
//
//Design the encode and decode methods for the TinyURL service. There is no restriction on how your
//encode/decode algorithm should work.... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/ImplementTrie.java | company/google/ImplementTrie.java | // Implement a trie with insert, search, and startsWith methods.
// Note:
// You may assume that all inputs are consist of lowercase letters a-z.
// Your Trie object will be instantiated and called as such:
// Trie trie = new Trie();
// trie.insert("somestring");
// trie.search("key");
class TrieNode {
HashMap<C... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/PaintFence.java | company/google/PaintFence.java | // There is a fence with n posts, each post can be painted with one of the k colors.
// You have to paint all the posts such that no more than two adjacent fence posts have the same color.
// Return the total number of ways you can paint the fence.
// Note:
// n and k are non-negative integers.
public class PaintFe... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/PlusOne.java | company/google/PlusOne.java | //Given a non-empty array of digits representing a non-negative integer, plus one to the integer.
//
//The digits are stored such that the most significant digit is at the head of the list, and each element in the array contain a single digit.
//
//You may assume the integer does not contain any leading zero, except th... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/FirstUniqueCharacterInAString.java | company/google/FirstUniqueCharacterInAString.java | //Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.
//
//Examples:
//
//s = "leetcode"
//return 0.
//
//s = "loveleetcode",
//return 2.
//Note: You may assume the string contain only lowercase letters.
class FirstUniqueCharacterInAString {
public in... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/LoggerRateLimiter.java | company/google/LoggerRateLimiter.java | // Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it is not printed in the last 10 seconds.
// Given a message and a timestamp (in seconds granularity), return true if the message should be printed in the given timestamp, otherwise return... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/CloneGraph.java | company/google/CloneGraph.java | // Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.
// OJ's undirected graph serialization:
// Nodes are labeled uniquely.
// We use # as a separator for each node, and , as a separator for node label and each neighbor of the node.
// As an example, consider the serializ... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/PlusOneLinkedList.java | company/google/PlusOneLinkedList.java | // Given a non-negative integer represented as non-empty a singly linked list of digits, plus one to the integer.
// You may assume the integer do not contain any leading zero, except the number 0 itself.
// The digits are stored such that the most significant digit is at the head of the list.
// Example:
// Input:
... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/MergeIntervals.java | company/google/MergeIntervals.java | // Given a collection of intervals, merge all overlapping intervals.
// For example,
// Given [1,3],[2,6],[8,10],[15,18],
// return [1,6],[8,10],[15,18].
/**
* Definition for an interval.
* public class Interval {
* int start;
* int end;
* Interval() { start = 0; end = 0; }
* Interval(int s, int... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/GroupShiftedStrings.java | company/google/GroupShiftedStrings.java | // Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequence:
// "abc" -> "bcd" -> ... -> "xyz"
// Given a list of strings which contains only lowercase alphabets, group all strings that belong to the same shifting sequence.... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/GenerateParentheses.java | company/google/GenerateParentheses.java | //Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
//
//For example, given n = 3, a solution set is:
//
//[
//"((()))",
//"(()())",
//"(())()",
//"()(())",
//"()()()"
//]
class GenerateParentheses {
public List<String> generateParenthesis(int n) {
... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/LetterCombinationsOfAPhoneNumber.java | company/google/LetterCombinationsOfAPhoneNumber.java | // Given a digit string, return all possible letter combinations that the number could represent.
// A mapping of digit to letters (just like on the telephone buttons) is given below.
// 2 - abc
// 3 - def
// 4 - ghi
// 5 - jkl
// 6 - mno
// 7 - pqrs
// 8 - tuv
// 9 - wxyz
// Input:Digit string "23"
// Output: ["ad"... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/DailyTemperatures.java | company/google/DailyTemperatures.java | //Given a list of daily temperatures, produce a list that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead.
//
//For example, given the list temperatures = [73, 74, 75, 71, 69, 72, 76, 73], your out... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/AndroidUnlockPatterns.java | company/google/AndroidUnlockPatterns.java | // Given an Android 3x3 key lock screen and two integers m and n, where 1 ≤ m ≤ n ≤ 9, count the total number of unlock patterns of the Android lock screen, which consist of minimum of m keys and maximum n keys.
// Rules for a valid pattern:
// Each pattern must connect at least m keys and at most n keys.
// A... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/ShortestDistanceFromAllBuildings.java | company/google/ShortestDistanceFromAllBuildings.java | // You want to build a house on an empty land which reaches all buildings in the shortest amount of distance. You can only move up, down, left and right. You are given a 2D grid of values 0, 1 or 2, where:
// Each 0 marks an empty land which you can pass by freely.
// Each 1 marks a building which you cannot pass thro... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/3SumSmaller.java | company/google/3SumSmaller.java | // Given an array of n integers nums and a target, find the number of index triplets i, j, k with 0 <= i < j < k < n that satisfy the condition nums[i] + nums[j] + nums[k] < target.
// For example, given nums = [-2, 0, 1, 3], and target = 2.
// Return 2. Because there are two triplets which sums are less than 2:
// ... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
kdn251/interviews | https://github.com/kdn251/interviews/blob/03fdcb2703ce72dc0606748733d0c13f09d41d21/company/google/UniqueWordAbbreviation.java | company/google/UniqueWordAbbreviation.java | // An abbreviation of a word follows the form <first letter><number><last letter>. Below are some examples of word abbreviations:
// a) it --> it (no abbreviation)
// 1
// b) d|o|g --> d1g
// 1 1 1
// 1---5----0----5--8
// c) i|nternationalizatio|... | java | MIT | 03fdcb2703ce72dc0606748733d0c13f09d41d21 | 2026-01-04T14:45:56.686758Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.