0% found this document useful (0 votes)
7 views1 page

IEEE - 1.ipynb - Colab

Uploaded by

nimmanibhanu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

IEEE - 1.ipynb - Colab

Uploaded by

nimmanibhanu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

10/15/24, 1:49 PM IEEE_1.

ipynb - Colab

def first_non_repeating_char(s):
char_count = {}
for char in s:
if char in char_count:
char_count[char] += 1
else:
char_count[char] = 1
for char in s:
if char_count[char] == 1:
return char
return None
input_string = input("Enter a string: ")
result = first_non_repeating_char(input_string)
if result:
print(result)
else:
print("No non-repeating")

Enter a string: rishik


The first non-repeating character is: r

def merge_intervals(intervals):
if not intervals:
return []
intervals.sort(key=lambda x: x[0])
merged = [intervals[0]]
for current in intervals[1:]:
last_merged = merged[-1]
if current[0] <= last_merged[1]:
last_merged[1] = max(last_merged[1], current[1])
else:
merged.append(current)
return merged
intervals = [[1, 3], [2, 6], [8, 10], [15, 18]]
result = merge_intervals(intervals)
print(result)

[[1, 6], [8, 10], [15, 18]]

https://colab.research.google.com/drive/1bZiPDHy1WvT3XPHxZjbZpR_wnFltlPRD#scrollTo=YfncnZX2QVr2&printMode=true 1/1

You might also like