Why use bubble sort. When you have timsort inbuilt😅
@it411489 ай бұрын
illuminati shii
@JustforFun-qj3fg10 ай бұрын
It's doesn't work if have same elements
@sourabhmori812910 ай бұрын
if list = [2,3,4,5,6,6,6] what will be the solution in this senario ?
@Michael-kq3qm11 ай бұрын
array.sort()
@Your_localAndrew2 ай бұрын
And print(array)
@TurtlemanUPG11 ай бұрын
C = '*' for i in range(1, 10): Print(i*C)
@banjoller Жыл бұрын
array = [1,4,6,3,6,4,6,9] n = len(array) for i in range(0, n): for j in range(i+1, n): if(array[i]>array[j]): temp = array[i] array[i] = array[j] array[j] = temp print(array)
@devenderbhatt421 Жыл бұрын
Bad solution o(n2) complexity sorry😢
@nedalalaoui3089 Жыл бұрын
👐
@akashwnl3337 Жыл бұрын
We can use swapcase instead of temp
@akashwnl3337 Жыл бұрын
Line 7 revstr != str is correct condition
@Ruben-ho9jd Жыл бұрын
It can be done in O(n) time complexity using two separate for loops. max = float("-inf'0 for i in range (0, len(array1)): if (array1[i] > max): max = array1[i] max2 = float("-inf") for i in range(0, len(array1)): if (array[i] > max2 and array[i] != max): max2 = array[i] return max2
@Rubyd777 Жыл бұрын
You can do it in single loop in n times
@pajvarma Жыл бұрын
It's not a pyramid brother
@osretrogames64 Жыл бұрын
Linux users opening an application:
@TecRox- Жыл бұрын
The time complexity is O(n2) 🤒
@faaiqrahman669 Жыл бұрын
Create a number question with 5 rows and make all options as unique values also extract first highest and second highest number in next follow up question....plz programm this in python
@PoosuLunda69 Жыл бұрын
Can someone pls explain the working of nested for loop here in this program . Will be glad if someone clarifies me!!. Got stuck in this program. :(
@ChhayaKamble-ft1fd Жыл бұрын
Done = sorted(array1) print(Done[-2])
@ChhayaKamble-ft1fd Жыл бұрын
The code can be improved further. Just use sorted() function in list and get the second last index with -2
@immor8al808 Жыл бұрын
Bro He has used Bubble sort to sort the list
@ramisettyharsha925111 ай бұрын
not lists we need to solve in arrays
@azziazzi98107 ай бұрын
array.sort(reverse=True) for x in range(1,len(a)): if a[x]!=a[x-1]: print(a[x]) break
@ab_web_surfer_ Жыл бұрын
This is bubble sort right
@abhiramjayan6034 Жыл бұрын
Is this realy bubble sort its insertion sort right
@WinterNox Жыл бұрын
I don't know if people will ask you to make a right angle triangle in the terminal on an interview.
@_____JUNPark_____ Жыл бұрын
Bruh. Just use str[::-1]. (string slice, [start:end:step])
@@maxspies8908 you cant use the function sort on interviews
@devenderbhatt421 Жыл бұрын
Mind left the chat whole point of question is to do it eithout sorting inbuilt function 😂😂
@ashutoshchoudhury1755 Жыл бұрын
Which source coder this is
@eddyxide Жыл бұрын
Man, array1.sort()
@BunnyRabbit. Жыл бұрын
build-in functions are not allowed in Exams.
@faisalshafiuddin1018 Жыл бұрын
@@BunnyRabbit. thats what if we know the built in function already whats the point of seeing tutorials then hahahaah
@_____JUNPark_____ Жыл бұрын
@@BunnyRabbit. It's method.
@Michael-kq3qm11 ай бұрын
@@BunnyRabbit. Thats just stupid, exams are stupid then. Its part of the language, and its more efficient, so they are teaching students wrong, whats the point using python if you don't use the built in functions?
@josuemolina61248 ай бұрын
@@Michael-kq3qm You are right, this is kind of stupid, but job interviews are just like this.
@karthikmadhavan4098 Жыл бұрын
L.sort() print(L[-2])
@deborshikashyap6745 Жыл бұрын
You're using OnlineGDB
@rajsekharmuppidi736 Жыл бұрын
I think it's not an array it's list
@herzeg6146 Жыл бұрын
arrays can be list, tuple, str, bytearray and e.tc
@guruyadavraj636 Жыл бұрын
Before square brackets he forgot to mention paranthesis
@monnichoudhory4406 Жыл бұрын
Runtime error
@dotaxanime6689 Жыл бұрын
Can u please include an explanation to your code tnx
@time2enjoy301 Жыл бұрын
useful bro
@time2enjoy301 Жыл бұрын
thanks
@royalmech14 Жыл бұрын
How did it work. Can anyone explain
@bhavaniryali95962 жыл бұрын
With explanation please
@kakajsbdhdh2 жыл бұрын
Thanks a lot
@praveenrockcse21922 жыл бұрын
Array1.sort() Print(-1) #done in two lines
@styleremo28792 жыл бұрын
-2 bro
@sofyanalwi35 Жыл бұрын
@@styleremo2879 Bruh. Starts from 0
@faridayasmeen7432 Жыл бұрын
@@sofyanalwi35 it's -2 you can check it
@SN-oo2fq Жыл бұрын
School marks
@dannyezechukwu1175 Жыл бұрын
Definitely -2. -1 is the last element in the list which would be the max value after the list is sorted.