an HCL GUVI product

11. Rearrange Characters in a String

Required Input:

s = "aaabb"

Expected Output:

ababa

Code In Python

def rearrange_string(s): # Write your logic here pass # Prefilled input s = "aaabb" print(rearrange_string(s))

Run Code?

Click Run Button to view compiled output

12. Maximum Number of Meetings in a Room

Required Input:

meetings = [(1, 3), (2, 5), (3, 6), (8, 9), (5, 7)]

Expected Output:

3

Code In Python

def max_meetings(meetings): # Write your logic here pass # Prefilled input meetings = [(1, 3), (2, 5), (3, 6), (8, 9), (5, 7)] print(max_meetings(meetings))

Run Code?

Click Run Button to view compiled output

13. Jump Game (Minimum Number of Jumps)

Required Input:

arr = [2, 3, 1, 1, 4]

Expected Output:

2

Code In Python

def min_jumps(arr): # Write your logic here pass # Prefilled input arr = [2, 3, 1, 1, 4] print(min_jumps(arr))

Run Code?

Click Run Button to view compiled output

14. Partition Labels

Required Input:

s = "ababcbacadefegdehijhklij"

Expected Output:

[9, 7, 8]

Code In Python

def partition_labels(s): # Write your logic here pass # Prefilled input s = "ababcbacadefegdehijhklij" print(partition_labels(s))

Run Code?

Click Run Button to view compiled output

15. Task Scheduling with Cooling Period

Required Input:

tasks = ["A", "A", "A", "B", "B", "B"]
cooldown = 2

Expected Output:

8

Code In Python

def least_interval(tasks, cooldown): # Write your logic here pass # Prefilled input tasks = ["A", "A", "A", "B", "B", "B"] cooldown = 2 print(least_interval(tasks, cooldown))

Run Code?

Click Run Button to view compiled output

16. Maximize Sum of Consecutive Differences in a Circular Array

Required Input:

arr = [4, 2, 1, 8]

Expected Output:

12

Code In Python

def max_sum_consecutive_diff(arr): # Write your logic here pass # Prefilled input arr = [4, 2, 1, 8] print(max_sum_consecutive_diff(arr))

Run Code?

Click Run Button to view compiled output

17. Maximize Sum by Picking Non-Adjacent Elements

Required Input:

arr = [3, 2, 7, 10]

Expected Output:

13

Code In Python

def max_sum_non_adjacent(arr): # Write your logic here pass # Prefilled input arr = [3, 2, 7, 10] print(max_sum_non_adjacent(arr))

Run Code?

Click Run Button to view compiled output

18. Largest Number From Given Digits

Required Input:

nums = [3, 30, 34, 5, 9]

Expected Output:

9534330

Code In Python

from functools import cmp_to_key def largest_number(nums): # Write your logic here pass # Prefilled input nums = [3, 30, 34, 5, 9] print(largest_number(nums))

Run Code?

Click Run Button to view compiled output

19. Minimum Number of Taps to Water a Garden

Required Input:

n = 5
ranges = [3, 4, 1, 1, 0, 0]

Expected Output:

1

Code In Python

def min_taps(n, ranges): # Write your logic here pass # Prefilled input n = 5 ranges = [3, 4, 1, 1, 0, 0] print(min_taps(n, ranges))

Run Code?

Click Run Button to view compiled output

20. Minimum Number of Arrows to Burst Balloons

Required Input:

balloons = [[10, 16], [2, 8], [1, 6], [7, 12]]

Expected Output:

2

Code In Python

def min_arrows_to_burst_balloons(balloons): # Write your logic here pass # Prefilled input balloons = [[10, 16], [2, 8], [1, 6], [7, 12]] print(min_arrows_to_burst_balloons(balloons))

Run Code?

Click Run Button to view compiled output

2 of 3