Problem:
Using our monsters table with the following schema:
monsters table schema
Write two Python functions to find the minimum number in a list. The first function should compare each number to every other number on the list. O(n²). The second function should be linear O(n).
Solution(O(n²)):
def findMin(alist)…
181. Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.
Employee
+----+-------+--------+-----------+| Id | Name | Salary |…
Your company has an internal policy to determine your customers’ credit limit, but this procedure has been questioned recently by the board as being too conservative.
Generate the following two result sets:
Plus One
Given a non-empty array of digits representing a non-negative integer, increment one to the integer.
The digits are stored such that the most significant digit is at the head of the list, and each element in the array contains a single…
If we want to add a single element to an existing set, we can use the .add() operation.It adds the element to the set and returns ‘None'.
None
Example
>>> s = set('HackerRank')>>> s.add('H')>>> print sset(['a', 'c', 'e', 'H', 'k'…
>>> s = set('HackerRank')>>> s.add('H')>>> print sset(['a', 'c', 'e', 'H', 'k'
262. Trips and Users
The Trips table holds all taxi trips. Each trip has a unique Id, while Client_Id and Driver_Id are both foreign keys to the Users_Id at the Users table. Status is an ENUM type of (‘completed’, ‘cancelled_by_driver’, ‘cancelled_by_client’).
Trips
Users