Noisy Palindrome - Facebook Top Interview Questions
You are given a string s containing lowercase and uppercase alphabet characters as well as digits from "0" to "9". Return whether s is a palindrome if we only consider the lowercase alphabet characters. Constraints 0 ≤ n ≤ 100,000 where n is the length of s Example 1 Input s = "a92bcbXa" Output True Explanation If we only consider the lowercase characters, then s is "abcba" which is a palindrome. Example 2 Input s = "abZ" Output False
View Solution →Strictly Alternating List - Facebook Top Interview Questions
You are given a list of integers nums. Return whether the list alternates from first strictly increasing to strictly decreasing and then strictly increasing etc. If a list is only strictly increasing, return true. Constraints 2 ≤ n ≤ 100,000 where n is the length of nums Example 1 Input nums = [1, 2, 5, 7, 4, 1, 6, 8, 3, 2] Output True Explanation This list strictly increases, strictly decreases, strictly increases, then strictly decreases. Example 2
View Solution →Task Run - Facebook Top Interview Questions
You are given a list of integers tasks where each different integer represents a different task type, and a non-negative integer k. Each task takes one unit of time to complete and each task must be done in order, but you must have k units of time between doing two tasks of the same type. At any time, you can be doing a task or waiting. Return the amount of time it takes to complete all the tasks. Constraints n ≤ 100,000 where n is the length of tasks Example 1 Input ta
View Solution →Unobstructed Buildings - Facebook Top Interview Questions
You are given a list of integers heights representing building heights. A building heights[i] can see the ocean if every building on its right has shorter height. Return the building indices where you can see the ocean, in ascending order. Constraints 0 ≤ n ≤ 100,000 where n is the length of heights Example 1 Input heights = [1, 5, 5, 2, 3] Output [2, 4] Explanation We can see the ocean in building heights[2] and heights[4]. Example 2 Input heights
View Solution →Binary Matrix Leftmost One - Facebook Top Interview Questions
You are given a two-dimensional list of integers matrix which contains 1s and 0s. Given that each row is sorted in ascending order with 0s coming before 1s, return the leftmost column index with the value of 1. If there's no row with a 1, return -1. Can you solve it faster than \mathcal{O}(nm)O(nm). Constraints n, m ≤ 250 where n and m are the number of rows and columns in matrix Example 1 Input matrix = [ [0, 0, 0, 0], [0, 0, 1, 1], [0, 0, 0, 1
View Solution →