Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"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 this issue Dec 19, 2023 · 2 comments

Comments

@nri2020
Copy link

nri2020 commented Dec 19, 2023

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
Copy link
Author

nri2020 commented Dec 19, 2023

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants