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.
https://www.youtube.com/playlist?list=PL9gnSGHSqcnr_DxHsP7AW9ftq0AtAyYqJ
16.07k stars 10.45k forks source link

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

Open nri2020 opened 6 months ago

nri2020 commented 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;

nri2020 commented 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)

vinay1719 commented 6 months ago

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.