Validating Consistency of Directional Rules Between Points Problem

Problem A rule looks like this: A NE B This means this means point A is located northeast of point B. A SW C means that point A is southwest of C. Given a list of rules, check if the sum of the rules validate. Examples Example 1: Input: rules = [ "A N B", "B NE C", "C N A" ] Output: false Explanation: does not validate, since `A` cannot be both north and south of `C`. ...

Valid Sudoku Problem

Problem Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: Each row must contain the digits 1-9 without repetition. Each column must contain the digits 1-9 without repetition. Each of the nine 3 x 3 sub-boxes of the grid must contain the digits 1-9 without repetition. Note: A Sudoku board (partially filled) could be valid but is not necessarily solvable. Only the filled cells need to be validated according to the mentioned rules. The Sudoku board could be partially filled, where empty cells are filled with the character ‘.’. ...

Arrange Given Number To Form The Biggest Number Possible

Problem Arrange Given Numbers To Form The Biggest Number Possible. OR Write a function that takes a number as input and outputs the biggest number with the same set of digits. Examples Example 1: Input: num = 423865 Output: 865432 Similar Problems Next Greater Element 3 - Find smallest number larger than given number using same digits ...

Android Unlock Patterns Problem

Problem 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. All the keys must be distinct. If the line connecting two consecutive keys in the pattern passes through any other keys, the other keys must have previously selected in the pattern. No jumps through non selected key is allowed. The order of keys used matters. ...

Find Deepest Node in a Binary Tree

Problem Given a binary tree, find the deepest node in it. If there are multiple, return the right most node. (Good to check with the interviewer - some may say left most). Examples Example 1: 1 / \ 2 3 / \ / \ 4 5 6 7 ...

Product of Array Except Self

Problem 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]. Examples Example 1: Input: nums = [1,2,3,4] Output: [24,12,8,6] Example 2: Input: nums = [-1,1,0,-3,3] Output: [0,0,9,0,0] Constraints 2 <= nums.length <= 105 -30 <= nums[i] <= 30 The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. Follow up Can you solve the problem in O(1) extra space complexity? (The output array does not count as extra space for space complexity analysis.) ...

Text Justification Problem

Problem Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. OR Given an array of strings words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified. You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces ' ' when necessary so that each line has exactly maxWidth characters. ...

Find first and last Position of Target Element in Sorted Array

Problem Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. If target is not found in the array, return [-1, -1]. You must write an algorithm with O(log n) runtime complexity. Examples Example 1: Input: nums = [5,7,7,8,8,10], target = 8 Output: [3,4] ...

Move Zeroes at the end of array

Problem Given an integer array nums, move all 0’s to the end of it while maintaining the relative order of the non-zero elements. Note that you must do this in-place without making a copy of the array. Examples Example 1: Input: nums = [0,1,0,3,12] Output: [1,3,12,0,0] Example 2: Input: nums = [0] Output: [0] ...

Valid Anagram Problem

Problem Given two strings s and t, return true if t is an anagram of s, and false otherwise. OR WAP to find out if 2 strings are anagrams or not. Anagram Definition Examples Example 1: Input: s = "anagram", t = "nagaram" Output: true Example 2: Input: s = "rat", t = "car" Output: false ...

This site uses cookies to improve your experience on our website. By using and continuing to navigate this website, you accept this. Privacy Policy