Problem 3

34 comments on “Problem 3”


  • Ravisurya

    n=int(input())
    list1=[int(input()) for x in range(n)]
    print(list1)
    key=int(input())
    count=0
    for i in range(n):
    if(key==list1[i]):
    count+=1
    print(count)


  • Somya_sharma

    public class Main {
    public static void main(String args[]) {
    int[] arr={1, 1, 2, 2, 2, 2, 3};
    int x=2;
    int count=0;
    for(int i=0;i<arr.length;i++)
    {
    if(x==arr[i])
    {
    count++;
    }
    }
    System.out.print(count);
    }
    }


  • Sabeeq

    def counter0occurences(arr,n,x):
    res = 0
    for i in range(n):
    if x = arr[i]:
    res += 1
    arr = [1,1,1,2,3,3]
    n = len(arr)
    x = 1
    print counter0occurences(arr,n,x)


  • Mangalam

    array=[]
    n=int(input(‘length of the array’))
    for i in range(0,n):
    item=int(input())
    array.append(item)
    x=int(input(‘enter the number whose frequency is to be found’))
    count=0
    for i in range(0,n):
    if array[i]==x:
    count=count+1
    print(count)


  • Mandeep

    #include
    using namespace std;

    int main() {
    int i ,a[50],n,count=0,x;
    cout<>n;
    cout<<"Element of array : \n";
    for(i=0;i>a[i];
    }
    cout<>x;
    for(i=0;i<n;i++)
    {

    if(x==a[i])
    {
    count++;
    }
    }
    cout<<"\n Count : "<<count;

    return 0;
    }


  • Anshul

    list=[1, 1, 2, 2, 2, 2, 3]
    n = len(list)

    count = 0
    p = int(input(“Enter number to be searched: \n”))
    for i in range(n):
    if p == list[i]:
    count += 1

    print(“The count is”,count)


  • dee.pansh18johri

    #include
    using namespace std;

    int main() {

    int n;
    cin>>n;
    map s;
    for(int i=0;i>e;
    s[e]++;
    }
    int x;
    cin>>x;
    cout<<s[x];

    return 0;
    }
    DEEPANSH JOHRI


  • Adarsh

    #include
    using namespace std;

    int main()
    {

    int n;
    cin>>n;
    vectorv(n);
    for(int i=0;i>v[i];
    }
    int t;
    cin>>t;
    int l=lower_bound(v.begin(),v.end(),t)-v.begin();
    int u=upper_bound(v.begin(),v.end(),t)-v.begin();
    cout<<(l-u==0?-1:(u-l))<<"\n";
    return 0;
    }


  • HEMAPRAKASH

    #include

    void repeat(int a[],int n,int x)
    {
    int k=0,i;
    for(i=0;i<n;i++)
    {
    if(a[i]==x)
    k++;
    }
    printf("%d",k);
    }

    int main()
    {
    int i,a[100],n,x;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
    scanf("%d",&a[i]);
    }
    scanf("%d",&x);
    repeat(a,n,x);
    }