Skip to content

Commit 4541b93

Browse files
changes
1 parent c4bae4c commit 4541b93

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,28 @@
5555
* The role of the user should be admin
5656
* This just return { message: 'Customer record successfully deleted' } if user is admin otherwise
5757
{ message: "Unauthorised access" }
58-
58+
59+
* http://localhost:3000/balanced
60+
* Method: POST
61+
* This API is work only when the user is login when the user will call this API
62+
with JWT token then he/his performe this action
63+
* As per the data structure of balanced or unbalanced string of parenthesis i used stack
64+
to maintain the stack of the string
65+
* Algorithm:
66+
* Store opening anf closing braces into two separeted array
67+
* Read the string from left to right
68+
* Read character from closingBraces array from current character index if exist then
69+
* if stack is empty then return false its means the string is not balanced
70+
* if stack is not empty then pop one element's from stack and check it on openingBraces
71+
array with closingBaces index if the pop-ed character and openingBraces is not same
72+
then return the string is not balanced
73+
* if not character is not exist then push to stack
74+
* continue this process until to reach end of the string
75+
76+
* When string is empty then check if stack is alos empty then return true
77+
else return false
78+
79+
Links: https://drive.google.com/file/d/1zD31rPHAqGhrUMDGCm0CwQCRlC5wxjSl/view?usp=drivesdk
5980

6081
Code Explanation :
6182

0 commit comments

Comments
 (0)