Blogs Hub

by AskGif | Oct 17, 2020 | Category :coding

Swap Salary - Sql - Easy - LeetCode

Swap Salary - Sql - Easy - LeetCode

Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update statement and no intermediate temp table. Note that you must write a single update statement, DO NOT write any sele

read more...

by AskGif | Oct 17, 2020 | Category :coding

Not Boring Movies - Sql - Easy - LeetCode

Not Boring Movies - Sql - Easy - LeetCode

X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies&rsquo; ratings and descriptions.<br />Please write a SQL query to output movies with an odd numbered ID and a description that is not 'boring'. Order the result by rat

read more...

by AskGif | Oct 17, 2020 | Category :coding

Classes More Than 5 Students - Sql - Easy - LeetCode

Classes More Than 5 Students - Sql - Easy - LeetCode

There is a table courses with columns: student and class Please list out all classes which have more than or equal to 5 students. For example, the table: +---------+------------+<br />| student | class &nbsp; &nbsp; &nbsp;|<br />+---------+------------+<br />| A &nbsp; &nbsp;

read more...

by AskGif | Oct 17, 2020 | Category :coding

Big Countries - Sql - Easy - LeetCode

Big Countries - Sql - Easy - LeetCode

There is a table World +-----------------+------------+------------+--------------+---------------+<br />| name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| continent &nbsp;| area &nbsp; &nbsp; &nbsp; | population &nbsp; | gdp &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />+-----------------+----

read more...

by AskGif | Oct 17, 2020 | Category :coding

Relative Ranks - Array - Easy - LeetCode

Relative Ranks - Array - Easy - LeetCode

Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: "Gold Medal", "Silver Medal" and "Bronze Medal". Example 1:<br />Input: [5, 4, 3, 2, 1]<br />Output: ["Gold Medal", "Silver Medal", "Bronze Medal", "4", "5"]<

read more...

by AskGif | Oct 17, 2020 | Category :coding

Construct the Rectangle - Maths - Easy - LeetCode

Construct the Rectangle - Maths - Easy - LeetCode

A web developer needs to know how to design a web page's size. So, given a specific rectangular web page&rsquo;s area, your job by now is to design a rectangular web page, whose length L and width W satisfy the following requirements: The area of the rectangular web page you designed must

read more...

by AskGif | Oct 17, 2020 | Category :coding

License Key Formatting - String - Easy - LeetCode

License Key Formatting - String - Easy - LeetCode

You are given a license key represented as a string S which consists of only alphanumeric character and dashes. The string is separated into N+1 groups by N dashes. Given a number K, we would want to reformat the strings such that each group contains exactly K characters, except for the fi

read more...

by AskGif | Oct 16, 2020 | Category :coding

Fizz Buzz - List - Easy - LeetCode

Fizz Buzz - List - Easy - LeetCode

Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three, it should output &ldquo;Fizz&rdquo; instead of the number and for the multiples of five output &ldquo;Buzz&rdquo;. For numbers which are multiples of both three and five output &ldquo

read more...

by AskGif | Oct 16, 2020 | Category :coding

Rising Temperature - SQL - Easy - LeetCode

Rising Temperature - SQL - Easy - LeetCode

Table: Weather +---------------+---------+<br />| Column Name &nbsp; | Type &nbsp; &nbsp;|<br />+---------------+---------+<br />| id &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| int &nbsp; &nbsp; |<br />| recordDate &nbsp; &nbsp;| date &nbsp; &nbsp;|<br />| temperature &nbsp; | int &nbsp; &

read more...

by AskGif | Oct 16, 2020 | Category :coding

Delete Duplicate Emails - SQL - Easy - LeetCode

Delete Duplicate Emails - SQL - Easy - LeetCode

Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id. +----+------------------+<br />| Id | Email &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />+----+------------------+<br />| 1 &nbsp;| john@example.com |<br

read more...

by AskGif | Oct 16, 2020 | Category :coding

Tenth Line - Bash - Easy - LeetCode

Tenth Line - Bash - Easy - LeetCode

Given a text file file.txt, print just the 10th line of the file. Example: Assume that file.txt has the following content: Line 1<br />Line 2<br />Line 3<br />Line 4<br />Line 5<br />Line 6<br />Line 7<br />Line 8<br />Line 9<br />Line 10<br />Your script should output the te

read more...

by AskGif | Oct 16, 2020 | Category :coding

Valid Phone Numbers - Bash - Easy - LeetCode

Valid Phone Numbers - Bash - Easy - LeetCode

Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bash script to print all valid phone numbers. You may assume that a valid phone number must appear in one of the following two formats: (xxx) xxx-xxxx or xxx-xxx-xxxx. (x means a digit)

read more...