File tree 1 file changed +22
-1
lines changed
1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 55
55
* The role of the user should be admin
56
56
* This just return { message: 'Customer record successfully deleted' } if user is admin otherwise
57
57
{ 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
59
80
60
81
Code Explanation :
61
82
You can’t perform that action at this time.
0 commit comments