- 2
Write a program to print all the LEADERS in the array. An element is leader if it is greater than all the elements to its right
Write a program to print all the LEADERS in the array. An element is leader if it is greater than all the elements to its right side. And the rightmost element is always a leader. For example int the array {16, 19, 4, 3, 8, 3}, leaders are 19, 8 and 3? how to solved in c lenguage
2 Antworten
+ 2
I'm not going to spoil the process but, *nested for-loops*
+ 2
You can look at any code that finds the maximum value in an array. You just need to change two things: yours needs to run backwards and whenever you find a new "leader", print it.