Comments (2)
That only happens when i is not zero, because it is in the else statement for if (i == 0)
from ctf.
ok i found the problem was every condition should be enclosed and here is my working code
public static int count(String s) {
int found = 0;
for (int i = 0; i < s.length() - 1; i++) {
if (i == 0){
if (s.charAt(i) == 'a' && s.charAt(i + 1) == 'a'){
found++;
}
}
else{
if(s.charAt(i - 1) != 'a' && s.charAt(i) == 'a' && s.charAt(i + 1) == 'a')
found++;
}
}
return found;
}
thanks for your answer and it's working perfect
from ctf.
Related Issues (20)
- Request for solutions or walk-through HOT 1
- [Ed. note: Table to be added/updated later.] HOT 5
- "WTF is CTF?" section is missing HOT 3
- easy problem HOT 1
- Add a License HOT 1
- Link to CMU Binary Bomb is broken HOT 1
- how to build a Pdf
- Bad links to references from within the repo HOT 6
- which part should i learn first if i want to focus on pentesting HOT 1
- References to finding teams HOT 1
- Malware Analysis and Antivirus course
- As a cybersec guy, should we code casually or spent time seriously on competitive programming? HOT 2
- Changes from PR #40 aren't reflected in the live GitBook HOT 3
- How to install trailofbits/CTF source in kali linux
- wiki URL pointing problem
- about ctf writeup tool
- About CTF Field Guide
- login
- Forgot Username
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ctf.