Open nri2020 opened 6 months ago
int [] arr = {1,2,3,4,5,6,7,8,9,11,22,33,35,44,55,66,77,88,91}; int target = 88; "C:\Program Files\Java\jdk-19\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.2.4\lib\idea_rt.jar=50036:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.2.4\bin" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath E:\data_structre_algorithm\out\production\Dsa_pw SearchInfyniteArray Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 29 out of bounds for length 19 at SearchInfyniteArray.ans(SearchInfyniteArray.java:14) at SearchInfyniteArray.main(SearchInfyniteArray.java:6)
it is because you have passed a finite length array so when the index value goes out of bound(greater then the length of array) it throws the above error, the given code in the repository is for infinite length array.
int [] arr = {1,2,3,4,5,6,7,8,9,11,22,33,35,44,55,66,77,88,91}; int target = 88;