MCPcopy Create free account
hub / github.com/apna-college/Alpha / firstOccurence

Method firstOccurence

7_RecursionBasics/RecursionBasics.java:61–70  ·  view source on GitHub ↗
(int arr[], int key, int i)

Source from the content-addressed store, hash-verified

59 }
60
61 public static int firstOccurence(int arr[], int key, int i) {
62 if(i == arr.length) {
63 return -1;
64 }
65 if(arr[i] == key) {
66 return i;
67 }
68
69 return firstOccurence(arr, key, i+1);
70 }
71
72 public static int lastOccurence(int arr[], int key, int i) {
73 if(i == arr.length) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected