0% found this document useful (0 votes)
14 views

Interview

The document discusses two problems related to finding pairs of numbers in an array that sum to a target number. The first problem returns the indices of the pairs, while the second returns the minimum cost to reach the top of a staircase given costs for each step.

Uploaded by

jcdf.89
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Interview

The document discusses two problems related to finding pairs of numbers in an array that sum to a target number. The first problem returns the indices of the pairs, while the second returns the minimum cost to reach the top of a staircase given costs for each step.

Uploaded by

jcdf.89
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

Two Sum

Given an array of integers nums and an integer target, return indices of the two numbers such that
they add up to target.

You may assume that each input would have exactly one solution, and you may not use the same
element twice.

You can return the answer in any order.

Example 1:

Input: nums = [2,7,11,15], target = 9

Output: [0,1]

Output: Because nums[0] + nums[1] == 9, we return [0, 1].

Example 2:

Input: nums = [3,2,4], target = 6

Output: [1,2]

Example 3:

Input: nums = [3,3], target = 6

Output: [0,1]

Constraints:

● 2 <= nums.length <= 104


● -109 <= nums[i] <= 109
● -109 <= target <= 109

● Only one valid answer exists.


2. Min Cost Climbing Stairs

You are given an integer array cost where cost[i] is the cost of ith step on a staircase. Once
you pay the cost, you can either climb one or two steps.

You can either start from the step with index 0, or the step with index 1.

Return the minimum cost to reach the top of the floor.

Example 1:

Input: cost = [10,15,20]

Output: 15

Explanation: You will start at index 1.

- Pay 15 and climb two steps to reach the top.

The total cost is 15.

Example 2:
Input: cost = [1,100,1,1,1,100,1,1,100,1]

Output: 6

Explanation: You will start at index 0.

- Pay 1 and climb two steps to reach index 2.

- Pay 1 and climb two steps to reach index 4.

- Pay 1 and climb two steps to reach index 6.

- Pay 1 and climb one step to reach index 7.

- Pay 1 and climb two steps to reach index 9.

- Pay 1 and climb one step to reach the top.

The total cost is 6.

Constraints:

● 2 <= cost.length <= 1000


● 0 <= cost[i] <= 999
SQL

Escribe sobre problemas de performance de BD que has tenido y que has corregido. ¿Qué
herramientas has usado?

Teniendo las siguientes tablas

reservation
reservationId int
dtCreated datetime
amount decimal(18,2)
currency varchar(3)
userIdCreatedBy int

user
userId int
name varchar(200)

Escribe las siguientes consultas:

● Trae todas las reservaciones que fueron creadas el día actual

● Elimina todas las reservaciones que fueron creadas antes de una fecha específica

● Trae las reservaciones de los usuarios que el nombre contenga “berto”

● Actualiza el nombre del usuario con id 10 a “Juan Perez”

● Regresa el monto total de reservaciones del día en cada moneda

● Regresa el nombre de todos los usuarios que tengan al menos una reservación el 12 de
enero del 2010

Usando las consultas anteriores, ¿qué índices agregarías a las tablas y por qué?

You might also like