Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Java by registered user venki ( 9 years ago )
// you can also use imports, for example:
import java.util.*;
import java.util.stream.Collectors;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");

class Solution {
    public int solution(int[] A) {
        // write your code in Java SE 8
        int count = 0;
  List<Integer> nums = Arrays.stream(A).boxed().collect(Collectors.toList());
  for(int S=0;S<A>i).toArray());
   int nextleader = getLeaderValue(nums.subList((S+1),A.length).stream().mapToInt(i->i).toArray());
   if (prevleader == nextleader) count++;
  }

  return count;
    }
    
    public  int getLeaderIndex(int[] A) {
  HashMap<Integer> nums = new HashMap<>();
  for (int num:A) {
   if (nums.get(num) == null) nums.put(num, 1);
   else nums.put(num,(nums.get(num)+1));
  }
  for(int i=0;i<A> nums = new HashMap<>();
  for (int num:A) {
   if (nums.get(num) == null) nums.put(num, 1);
   else nums.put(num,(nums.get(num)+1));
  }
  for(int i=0;i<A.

 

Revise this Paste

Children: 89599
Your Name: Code Language: