
Problem
Solution
Submissions
Bank Account Representing
Certification: Advanced Level
Accuracy: 100%
Submissions: 2
Points: 10
Design a Python class called BankAccount
that represents a basic bank account. The class should have methods to deposit funds, withdraw funds, and check the current balance. The account should not allow withdrawals that would result in a negative balance.
-
Example 1
- Input: account = BankAccount("12345", "John Doe", 1000)
- Output: 1300
-
Example 2
- Input: account = BankAccount("67890", "Jane Smith", 500)
- Output: "Insufficient funds. Current balance: 500"
- Constraints
- Account number must be a non-empty string
- Account holder name must be a non-empty string
- Initial balance must be non-negative
- Time Complexity: O(1) for all operations
- Space Complexity: O(1) for all operations
Editorial
My Submissions
All Solutions
Lang | Status | Date | Code |
---|---|---|---|
You do not have any submissions for this problem. |
User | Lang | Status | Date | Code |
---|---|---|---|---|
No submissions found. |
Solution Hints
- Use instance variables to store account details and balance
- Implement validation in the withdraw method to prevent negative balance
- Return appropriate messages or status for failed operations
- Consider implementing a transaction history (optional)
- Use proper encapsulation principles