Given an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. Example 1: Input: nums = [1,2,3] Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] Example 2: Input: nums = [0] Output: [[],[0]]
Given an undirected graph, Write an algorithm to determine whether its tree or not.An undirected graph is a tree if it has properties mentioned below. There is no cycle present in the graph. The graph is connected. (All the vertices in the graph are connected) Example: Recommended articles to read before continue reading Detect Cycle in an Undirected Graph using DFS. Check if Given Directed Graph is disconnected
Given two versions of a software, write an algorithm to find out which version is the latest. Example: Version A: 1.1.0 Version B: 1.1.1 Given version B latest than version A Version A: 1.2.1 Version B: 1.2.1 Given versions are the same Version A: 2.2.0 Version B: 2.2 Given versions are the same Version A: 2.2.0.0.1 Version B: 2.2.0 Given version A latest than version B Version A: 2.2.0.0.1 Version B: 2.2.1 Given version B latest than version A
Given a string, write a function that returns a random character from the string. Example: Given string = algorithms @ tutorial horizon Random character: s Random character: r Random character: h Random character: @ Random character: i
In school a student gets rewarded if he has an attendance record without being absent for more than once or being late for 3 times continuously. Given a student’s attendance record represented by a string. The record only contains the following three characters: ‘A’ : Absent. ‘L’ : Late. ‘O’ : On-Time. Check whether the student qualifies for the reward. Example: Record: "OLLAOOOLLO" Output: False Explanation: The student does not qualify for a reward because "LLA" means he was late 3 times in a row. Record: "OLLOAOLLO" Output: True
Given an array of strings, write a program to count all the similar words. Similar words: Two words are similar if Has spaces in-between or at the end. Ex: “Apple” and ” A pp le” are similar. Has upper or lower cases. Ex: “APPle” and “apple” are similar. Has special characters. Ex: “app%^L&e” and “@@apple” are similar. Example:; input = ["Apple", "Bat", "apple", "A%^%ppLE", "BA T", " C A T", "cAt "] Output: apple -- 3 bat -- 2 cat -- 2
Given a sorted array of integers, Write an algorithm to make all array elements distinct or unique by doing minimum increments. Example: Given Input: [2, 2, 3, 5, 6, 6] Unique Array: [2, 3, 4, 5, 6, 7], Minimum Increments: 3 Explanation: Increment 2 to 3, 3 to 4 and 6 to 7. Given Input: [1, 1, 1, 1] Unique Array: [1, 2, 3, 4], Minimum Increments: 3
Given a binary array (contains only 0’s and 1’s), find out the number of maximum consecutive ones. Example: Input: [0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1] Max consecutive ones: 4 Input: [0, 1, 1, 0, 1, 1], Max consecutive ones: 2 Input: [0, 0, 0, 0] Max consecutive ones: 0