FINAL Assignment

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Python Final Assignment

1.Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed
parentheses.

Code:

Output:

2. 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, which means you have to modify the input
2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.
Code:

Output

3.Minimum Path Sum


Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right,
which minimizes the sum of all numbers along its path. Note: You can only move either down
or right at any point in time.
Code:

Output:
4. Count Primes
Given an integer n, return the number of prime numbers that are strictly less than n.

Code:

Output:

THANK YOU

You might also like