kunal-kushwaha / DSA-Bootcamp-Java

This repository consists of the code samples, assignments, and notes for the Java data structures & algorithms + interview preparation bootcamp of WeMakeDevs.

Home Page:https://www.youtube.com/playlist?list=PL9gnSGHSqcnr_DxHsP7AW9ftq0AtAyYqJ

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"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)

nri2020 opened this issue · comments

int [] arr = {1,2,3,4,5,6,7,8,9,11,22,33,35,44,55,66,77,88,91};
int target = 88;

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.