We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Implementation
- Service Lane
- Discussions
Service Lane
Service Lane
+ 0 comments template for c, misses the width array
+ 0 comments /* * Cuddle time * Phuong Chi * Miss you */ import java.math.BigInteger; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Scanner; import java.util.Set; public class Solve_problems { static int solution(int n, ArrayList<Integer> arr, int entry, int exit) { // Find the minimum width in the specified segment int minWidth = Integer.MAX_VALUE; for (int j = entry; j <= exit; j++) minWidth = Math.min(minWidth, arr.get(j)); return minWidth; } public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n = sc.nextInt(); int t = sc.nextInt(); ArrayList<Integer> arr=new ArrayList<>(); for(int i = 0; i <n ; i++) arr.add(sc.nextInt()); for(int i=0;i<t;i++) { int a = sc.nextInt(),b=sc.nextInt(); System.out.println(solution(n,arr, a, b)); } sc.close(); } }
+ 0 comments question is wrong.
+ 0 comments Flow binding have achived a global presence with product availaible at athorized snowboard shop, outdoor retailer and online plate form.
+ 0 comments C++ Solution: Need to add width as parameter input.
vector<int> serviceLane(int n, vector<int> width, vector<vector<int>> cases) { int N = cases.size(); vector<int> results; for(int i = 0; i < N; i++) { int min_width = INT8_MAX; for(int j = cases[i][0]; j <= cases[i][1]; j++) { min_width = min(width[j], min_width); } results.push_back(min_width); } return results; }
Load more conversations
Sort 1223 Discussions, By:
Please Login in order to post a comment