Skip to main content

96 docs tagged with "Uber"

View All Tags

01 Matrix

Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell.

Add Two Numbers

You are given two non-empty linked lists representing two non-negative integers...

Asteroid Collision

We are given an array asteroids of integers representing asteroids in a row.

Basic Calculator

Given a string s representing a valid expression, implement a basic calculator to evaluate it, and return the result of the evaluation.

Basic Calculator II

Given a string s which represents an expression, evaluate this expression and return its value.

Best Time To Buy And Sell Stock

You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock.

Binary Search

Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums...

Binary Tree Right Side View

Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.

Bus Routes

Return the least number of buses you must take to travel from source to target. Return -1 if it is not possible.

Climbing Stairs

You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

Coin Change

You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.

Container With Most Water

You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the...

Contains Duplicate

Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.

Course Schedule

For example, the pair [0, 1], indicates that to take course 0 you have to first take course 1. Return true if you can finish all courses. Otherwise, return false.

Course Schedule II

Return the ordering of courses you should take to finish all courses. If there are many valid answers, return any of them. If it is impossible to finish all courses, return an empty array.

Daily Temperatures

Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature.

Decode Ways

Given a string s containing only digits, return the number of ways to decode it.

Find All Anagrams in a String

Given two strings s and p, return an array of all the start indices of p's anagrams in s. You may return the answer in any order.

Find K Closest Elements

Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array.

Find Peak Element

A peak element is an element that is strictly greater than its neighbors.

First Bad Version

Implement a function to find the first bad version. You should minimize the number of calls to the API.

Flood Fill

An image is represented by an m x n integer grid image where image[i][j] represents the pixel value of the image.

Generate Parentheses

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

Group Anagrams

Given an array of strings strs, group the anagrams together. You can return the answer in any order.

Implement Queue using Stacks

Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue...

Interval List Intersections

You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [starti, endi] and secondList[j] = [startj, endj]. Each list of intervals is pairwise disjoint and in sorted order.

Kth Smallest Element in a BST

Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree.

Letter Combinations of a Phone Number

Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order.

Longest Valid Parentheses

Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring.

LRU Cache

Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.

Maximal Square

Given an m x n binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.

Maximum Subarray

Given an integer array nums, find the subarray which has the largest sum and return its sum.

Median of Two Sorted Arrays

Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.

Merge k Sorted Lists

You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.

Min Stack

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.

Minimum Height Trees

Among all possible rooted trees, those with minimum height (i.e. min(h)) are called minimum height trees (MHTs).

Minimum Window Substring

Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicates) is included in the window.

Move Zeroes

Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.

N-Queens

The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.

Number of Islands

Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands.

Partition Equal Subset Sum

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.

Partition to K Equal Sum Subsets

Given an integer array nums and an integer k, return true if it is possible to divide this array into k non-empty subsets whose sums are all equal.

Permutations

Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.

Pow(x, n)

Implement pow(x, n), which calculates x raised to the power n.

Product of Array Except Self

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].

Random Pick with Weight

You need to implement the function pickIndex(), which randomly picks an index in the range [0, w.length - 1] (inclusive) and returns it.

Reorganize String

Given a string s, rearrange the characters of s so that any two adjacent characters are not the same.

Reverse Integer

Given a signed 32-bit integer x, return x with its digits reversed.

Reverse Linked List

Given the head of a singly linked list, reverse the list, and return the reversed list.

Rotate Array

Given an integer array nums, rotate the array to the right by k steps, where k is non-negative.

Rotate Image

You have to rotate the image in-place, which means you have to modify the input 2D matrix directly.

Search in Rotated Sorted Array

Given the array nums after the possible rotation and an integer target, return the index of target if it is in nums, or -1 if it is not in nums.

Single Number

Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.

Sliding Window Maximum

You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window.

Sliding Window Median

The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle values.

Spiral Matrix

Given an m x n matrix, return all elements of the matrix in spiral order.

Squares of a Sorted Array

Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.

String to Integer (atoi)

Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer (similar to C/C++'s atoi function).

Subarray Sum Equals K

Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k.

Sudoku Solver

Write a program to solve a Sudoku puzzle by filling the empty cells.

Symmetric Tree

Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).

Target Sum

You want to build an expression out of nums by adding one of the symbols '+' and '-' before each integer in nums and then concatenate all the integers.

Task Scheduler

Given a characters array tasks, representing the tasks a CPU needs to do, where each letter represents a different task.

Top K Frequent Elements

Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.

Trapping Rain Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.

Two Sum

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

Valid Anagram

Given two strings s and t, return true if t is an anagram of s, and false otherwise.

Valid Palindrome

A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers.

Valid Parentheses

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

Word Ladder

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

Word Search

Given an m x n grid of characters board and a string word, return true if word exists in the grid.

Word Search II

Given an m x n board of characters and a list of strings words, return all words on the board.