-
Notifications
You must be signed in to change notification settings - Fork 0
/
Strings.py
53 lines (43 loc) · 2.37 KB
/
Strings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
COPYRIGHT = '© Copyright: Ofir Tanami 2021'
# q1:
sort_colors = "Sort Colors"
inst_sort_colors = """ Given an array nums with n objects colored red, blue, or green,
sort them in-place so that objects of the same color are adjacent, with the colors in the order red, green, and blue.
Time Complexity: O(n), Space Complexity: O(1)."""
# q2:
num_islands = "Number of Islands"
inst_num_islands = """Given an n x n 2D binary grid which represents a map of 'Brown's (land) and 'Blue's (water),
return the number of islands."""
# q3:
max_profit = "Max Profit"
inst_max_profit = """You are given an array prices where prices[i] is the price of a given stock on the ith day.
You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock.
Time Complexity: O(n), Space Complexity: O(1)."""
# q4:
rotated_array = "Rotated Sorted Array"
inst_rotated_array = """Given the array nums after the rotation and an integer target,
return the index of target if it is in nums, or -1 if it is not in nums
Time Complexity: O(log(n)), Space Complexity: O(1)."""
# q5:
nearest_exit = "Nearest Exit"
inst_nearest_exit = """You are given an m x n matrix maze.
Return the number of steps in the shortest path from the entrance to the nearest exit, or 0 if no such path exists."""
# q6:
rotate_list = "Rotate List"
inst_rotate_list = """Given the head of a linked list, rotate the list to the right by k places."""
# q7:
add_two_huge_numbers = "Add Two Huge Numbers"
inst_add_two = """You're given 2 huge integers represented by linked lists.
Each linked list element is a number from 1 to 9 that represents a number with exactly 1 digits.
Your task is to add up these huge integers and return the result in the same format."""
# q8
rotate_image = "Rotate Image"
inst_rotate_image = """You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise).
You have to rotate the image in-place (space complexity O(1))"""
# q9:
calculate_pi = "Calculate π"
inst_calculate_pi = "Given a function that produces a number in the range [0,1], calculate π."
# q10:
game_of_life = "Game of Life"
inst_game_of_life = """According to Wikipedia's article: "The Game of Life, also known simply as Life,
is a cellular automaton devised by the British mathematician John Horton Conway in 1970."""""