Questions tagged [find-occurrences]

435 questions
-2
votes
1 answer

Search occurrence in an array of string

I have an array of string like this : array{"CTT29","CTT37","CTT41","CTT","CTT43"} And I want to find the occurence in all strings, in this example it should give me "CTT" Thanks a lot for your answers ! :) Edit : sorry I've forgot the "s" ( I'm…
-2
votes
2 answers

Python: building a CCDF out of a list

I have the following list, where the 1st element is a generic value and the second is the number of occurrences of that value: mylist=[(2, 45), (3, 21), (4, 12), (5, 7), (6, 2), (7, 2), (8, 3), (9, 2), (10, 1), (11, 1), (15, 1), (17, 2), (18,…
FaCoffee
  • 7,609
  • 28
  • 99
  • 174
-2
votes
1 answer

Not finding occurrences as intended

I have the following program, the programs purpose is to display how many times each value in the list vector occurred. if the tuple 2:3 occurs 3 times in the vector, then the program displays this to the user. Expected output 0:8 occurred 1 time…
Mitch89
  • 59
  • 7
-2
votes
1 answer

Number of occurrences in array

Logic please.. With just using for or while loop... Example: int a[ ] = {2,3,2,3,4,4,5,1,3}; Output : 2 occurred 2 time 3 occurred 3 time 4 occurred 2 time 5 occurred 1 time 1 occurred 1 time
-2
votes
2 answers

How to display the word and its number of occurences in a string in C

Basically, I want to display the words and their number of occurrences in a string. It can be both case sensitive and vice-versa. For e.g if the input string is "Hello World How are you Hello how", the output should…
Pawan Kumar
  • 594
  • 4
  • 18
-2
votes
1 answer

How to perform the needed search process for array elements?

Please Help me revise or improve the program because it has a logical error. Write a program that will search for the number of an item in the array num[20]={23,45,1,23,5,78,6,13,1,4,78,18,3,5,26,4,5,10,3,45}. If the search item is in the array,…
user3808774
  • 57
  • 1
  • 5
-2
votes
1 answer

How to count how many entry's of each type are in array?

I need to count how many times caracter 1, 2 ,3 ,4, 5 is existing in this array e.g. for this i should get answer 1 - two times 2 - two times 3 - one time 4 - three times array(2) { [0]=> string(1) "3" …
JohnA
  • 1,875
  • 8
  • 28
  • 34
-3
votes
8 answers

Number of occurarece of each char in a string

Possible Duplicate: Count occurrences of each unique character How can I get the number of occurrence of each char in a string? for example: "stackoverflow": s:1 t:1 a:1 c:1 k:1 o:2 v:1 e:1 r:1 f:1 l:1 o:1 w:1
Othman
  • 332
  • 5
  • 19
-3
votes
1 answer

C: Search vor endindex of first occurence

how can i write following programm: • a function which searches a string in a second string and returns the endindex of the first occurence • a function which includes all occurences of the first string in the second string, which will be replaced…
Sedem
  • 47
  • 1
  • 9
-3
votes
2 answers

Trying to count number of occurrences in an array

So I'm trying to count the number of integer occurrences in this program. The code still doesn't work, but am I on the right track? public static void main(String[] args) { Scanner scan = new Scanner(System.in); int…
studentS
  • 41
  • 1
  • 1
  • 5
-3
votes
4 answers

Java - Number of occurrences of a digit in a number without loop

Given a non-negative int n, how do i return the count of the occurrences of a digit e.g 7, so for example 717 yields 2? (no loops). Here is my code but it doesn't work well. public int count7(int n) { int count = 0; if(n==7){ count++; return…
sully11
  • 37
  • 1
  • 9
-4
votes
1 answer

Find all the occurences of an array that contain a substring in java

Input: [the, and, land, wander, dreams] Substring: "and" Output: 3 I need to find all the occurrences of an array that contain a certain substring but all I found was the word itself. For example, I want it to count the "and" in the word "land" and…
zoe
  • 1
-4
votes
1 answer

How to find occurrence of each set of cartesian product in python?

I want to find occurrence of each set of Cartesian product like A = [1,2] B = [2,1] then A * B = [(1,2),(1,1),(2,2),(2,1)] then I want to find occurrence of each set like (1,2) occurs 2 times [(1,2), (2,1)] (1,1) occurs 1 time (1,1) and so on....
-5
votes
1 answer

first occurrence code binary search debug in c

int firstOcc(int a[],int m,int x) { int high=m-1,low=0,mid,index=-1; while(low<=high){ mid=(low+high)/2; if(a[mid]x){ mid=high-1;} if(a[mid]==x){ index=mid; …
-6
votes
1 answer

How might I find the number of occurrences of elements in a list in ReasonML?

How might I find the number of occurrences of elements in a list in ReasonML? I'm not exactly sure how to attempt this. Thank you!
1 2 3
28
29