Powerful Integers in Python

Arnab Chakraborty
Updated on 06-Jul-2020 09:17:24

247 Views

Suppose we have two positive integers x and y, we can say an integer is powerful if it is equal to x^i + y^j for some integers i >= 0 and j >= 0. We have to find a list of all-powerful integers that have value less than or equal to bound.So, if the input is like x = 2 and y = 3 and the bound is 10, then the output will be [2, 3, 4, 5, 7, 9, 10], as 2 = 2^0 + 3^0 3 = 2^1 + 3^0 4 = 2^0 + 3^1 5 = 2^1 ... Read More

Largest Time for Given Digits in C++

Arnab Chakraborty
Updated on 06-Jul-2020 09:15:09

199 Views

Suppose we have an array of 4 digits, we have to find the largest 24-hour time that can be made. We know that the smallest 24-hour time is 00:00, and the largest time is 23:59. Starting from 00:00, a time is larger if more time has elapsed since midnight. We have to return the answer as a string of length 5. If there is no valid time to be returned, then return an empty string.So, if the input is like [1, 2, 3, 4], then the output will be "23:41"To solve this, we will follow these steps −Define a function ... Read More

Delete Columns to Make Sorted in Python

Arnab Chakraborty
Updated on 06-Jul-2020 09:13:15

257 Views

Suppose we have an array of N lowercase letter strings, the array name is A, all strings are of same length. Now, we can choose any set of deletion indices, and for each string, we delete all the characters in those indices.As an example, if we have an array A like ["abcdef", "uvwxyz"] and deletion indices are {0, 2, 3}, then the final array after deletions will be ["bef", "vyz"], and the remaining columns of A are ["b", "v"], ["e", "y"], and ["f", "z"].Suppose we chose a set of deletion indices D like after deletions, each remaining column in A ... Read More

DI String Match in Python

Arnab Chakraborty
Updated on 06-Jul-2020 09:12:21

280 Views

Suppose we have a string S that only contains "I" (to denote increase) or "D" (to denote decrease), let N = size of S. We have to return any permutation A of [0, 1, ..., N] such that for all i in range 0, ..., N-1 −If S[i] is "I", then A[i] < A[i+1]Otherwise when S[i] is "D", then A[i] > A[i+1]So, if the input is like "IDID", then the output will be [0, 4, 1, 3, 2]To solve this, we will follow these steps −A := a list from 0 to N where N is the size of S.res ... Read More

Valid Mountain Array in Python

Arnab Chakraborty
Updated on 06-Jul-2020 09:10:41

947 Views

Suppose we have an array A of integers; we have to check whether it is a valid mountain array or not. We know that A is a mountain array if and only if it satisfies the following situations − size of A >= 3There exists some index i in A such that −A[0] < A[1] < ... A[i-1] < A[i]A[i] > A[i+1] > ... > A[A.length - 1]So, if the input is like [0, 3, 2, 1], then the output will be True.To solve this, we will follow these steps −if size of A < 3, thenreturn Falsei := 1while ... Read More

Reorder Data in Log Files Using Python

Arnab Chakraborty
Updated on 06-Jul-2020 09:10:04

429 Views

Suppose we have an array of logs. In that array each entry is a space delimited string of words. The first word in each log is an alphanumeric identifier. Then, there are different types of strings like below −Each word after the id will consist only of lowercase letters;Each word after the id will consist only of digits.We will call these two types of logs as letter-logs and digit-logs respectively. And ti is guaranteed that each log has at least one word after its id.We have to reorder the logs so that all of the letter-logs stays before any digit-log. ... Read More

Find HCF of Two Given Bytes in 8085 Microprocessor

Arnab Chakraborty
Updated on 06-Jul-2020 09:00:37

729 Views

Here we will see how to find the HCF or GCD of two given bytes using 8085. The numbers are 8-bit numbers, nor larger than that.Problem Statement−            Write an 8085 Assembly language program to find the HCF or GCD of two numbers stored at memory location 8000H and 8001H.Discussion−            Here we will use the Euclidean algorithm to find HCF. This algorithm is very simple. We have to follow these steps−If first number and second number are same, thena) go to step 3.Else if first number < second number, the    ... Read More

Count Rows from Two Tables in a Single MySQL Query

AmitDiwan
Updated on 06-Jul-2020 08:56:03

417 Views

Let us first create a table −mysql> create table DemoTable1 (    Name varchar(40) ); Query OK, 0 rows affected (0.81 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values('Chris'); Query OK, 1 row affected (0.48 sec) mysql> insert into DemoTable1 values('Robert'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1 values('Mike'); Query OK, 1 row affected (0.10 sec)Display all records from the table using select statement −mysql> select *from DemoTable1;This will produce the following output −+--------+ | Name   | +--------+ | Chris  | | Robert | | Mike   | +--------+ ... Read More

Define Colors Using the HSLA Model with CSS

karthikeya Boyini
Updated on 06-Jul-2020 08:23:59

263 Views

To define colors using the Hue-Saturation-Lightness model (HSL) with Opacity, use the hsla() CSS method.ExampleYou can try to run the following code to implement the hsla() function in CSSLive Demo                    h1 {             background-color:hsl(0,100%,50%);          }          h2 {             background-color:hsl(192,89%,48%);          }          p {             background-color:hsla(290,100%,50%,0.3);          }                     Red Background       Blue Background       This is demo text!    

Align Flex Items in the Middle of the Container in CSS

Arjun Thakur
Updated on 06-Jul-2020 08:23:19

171 Views

Use the align-items property with value center to align flex items in the middle.ExampleYou can try to run the following code to implement the center valueLive Demo                    .mycontainer {             display: flex;             background-color: orange;             align-items: center;             height: 150px;             width: 600px;          }          .mycontainer > div {             background-color: white;             text-align: center;             line-height: 40px;             font-size: 25px;             width: 100px;             margin: 5px;          }                     Quiz                Q1          Q2          Q3          Q4          

Advertisements