|
@@ -0,0 +1,99 @@
|
|
|
+
|
|
|
+##Quiz 1
|
|
|
+There is a table World
|
|
|
+
|
|
|
+ +-----------------+------------+------------+--------------+---------------+
|
|
|
+ | name | continent | area | population | gdp |
|
|
|
+ +-----------------+------------+------------+--------------+---------------+
|
|
|
+ | Afghanistan | Asia | 652230 | 25500100 | 20343000 |
|
|
|
+ | Albania | Europe | 28748 | 2831741 | 12960000 |
|
|
|
+ | Algeria | Africa | 2381741 | 37100000 | 188681000 |
|
|
|
+ | Andorra | Europe | 468 | 78115 | 3712000 |
|
|
|
+ | Angola | Africa | 1246700 | 20609294 | 100990000 |
|
|
|
+ +-----------------+------------+------------+--------------+---------------+
|
|
|
+A country is big if it has an area of bigger than 3 million square km or a population of more than 25 million. _(595. Big Countries)_
|
|
|
+
|
|
|
+Write a SQL solution to output big countries' name, population and area.
|
|
|
+For example, according to the above table, we should output:
|
|
|
+
|
|
|
+ +--------------+-------------+--------------+
|
|
|
+ | name | population | area |
|
|
|
+ +--------------+-------------+--------------+
|
|
|
+ | Afghanistan | 25500100 | 652230 |
|
|
|
+ | Algeria | 37100000 | 2381741 |
|
|
|
+ +--------------+-------------+--------------+
|
|
|
+
|
|
|
+##Quiz 2
|
|
|
+Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything. _(183. Customers Who Never Order)_
|
|
|
+
|
|
|
+Table: Customers.
|
|
|
+
|
|
|
+ +----+-------+
|
|
|
+ | Id | Name |
|
|
|
+ +----+-------+
|
|
|
+ | 1 | Joe |
|
|
|
+ | 2 | Henry |
|
|
|
+ | 3 | Sam |
|
|
|
+ | 4 | Max |
|
|
|
+ +----+-------+
|
|
|
+Table: Orders.
|
|
|
+
|
|
|
+ +----+------------+
|
|
|
+ | Id | CustomerId |
|
|
|
+ +----+------------+
|
|
|
+ | 1 | 3 |
|
|
|
+ | 2 | 1 |
|
|
|
+ +----+------------+
|
|
|
+Using the above tables as example, return the following:
|
|
|
+
|
|
|
+ +-----------+
|
|
|
+ | Customers |
|
|
|
+ +-----------+
|
|
|
+ | Henry |
|
|
|
+ | Max |
|
|
|
+ +-----------+
|
|
|
+
|
|
|
+##Quiz 3
|
|
|
+
|
|
|
+You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels.
|
|
|
+
|
|
|
+The letters in J are guaranteed distinct, and all characters in J and S are letters. Letters are case sensitive, so "a" is considered a different type of stone from "A". _(771. Jewels and Stones)_
|
|
|
+
|
|
|
+### Test Case 1:
|
|
|
+ Input: J = "aA", S = "aAAbbbb"
|
|
|
+ Output: 3
|
|
|
+### Test Case 2:
|
|
|
+ Input: J = "z", S = "ZZ"
|
|
|
+ Output: 0
|
|
|
+### Note:
|
|
|
+* S and J will consist of letters and have length at most 50.
|
|
|
+* The characters in J are distinct.
|
|
|
+
|
|
|
+### Example Code (Ruby):
|
|
|
+ # @param {String} j
|
|
|
+ # @param {String} s
|
|
|
+ # @return {Integer}
|
|
|
+ def num_jewels_in_stones(j, s)
|
|
|
+ end
|
|
|
+
|
|
|
+##Quiz 4
|
|
|
+
|
|
|
+Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the original place.
|
|
|
+
|
|
|
+The move sequence is represented by a string. And each move is represent by a character. The valid robot moves are R (Right), L (Left), U (Up) and D (down). The output should be true or false representing whether the robot makes a circle. _(657. Judge Route Circle)_
|
|
|
+
|
|
|
+### Test Case 1:
|
|
|
+ Input: "UD"
|
|
|
+ Output: true
|
|
|
+
|
|
|
+### Test Case 2:
|
|
|
+ Input: "LL"
|
|
|
+ Output: false
|
|
|
+
|
|
|
+### Example Code (Ruby):
|
|
|
+ # @param {String} moves
|
|
|
+ # @return {Boolean}
|
|
|
+ def judge_circle(moves)
|
|
|
+ end
|
|
|
+
|
|
|
+
|