list_nums = [3,4,7,7,9,9,9,10]
new_list_nums = []
first_element = -1 #0
last_element = -1 #len(new_list_nums)-1
while list_nums:
min = list_nums[0]
for num in list_nums:
if num < min:
min = num
new_list_nums.append(min)
list_nums.remove(min)
print(new_list_nums)
#how to find index in a list sorted
index_of_list = [i for i in enumerate(new_list_nums)]
target = 8
n = len(new_list_nums)
def findFirstAndLast(new_list_nums, n, target) :
first_element = -1 #0
last_element = -1 #len(new_list_nums)-1
for i in range(0,n) :
if (target != new_list_nums[i]) :
continue
if (first_element == -1) :
first_element = i
last_element = i
if (first_element != -1):
print( first_element ,last_element)
else :
print([-1 , -1])
print(findFirstAndLast(new_list_nums,n,target))
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Discussion on: Devmates.co [Array Search]
For further actions, you may consider blocking this person and/or reporting abuse