@@ -262,7 +262,7 @@ def isPermutation(self,input1,input2,hint=False):
262
262
return mapp1 == mapp2
263
263
264
264
def isPermutation_hint (self ):
265
- message = """
265
+ message = """
266
266
Two String Permutations
267
267
------------------------------------
268
268
@@ -339,6 +339,64 @@ def URLify(self,input_str,key):
339
339
input2 += key
340
340
return input2
341
341
342
+ def URLify_hint (self ):
343
+ message = """
344
+ Making a URL From a String
345
+ ------------------------------------
346
+
347
+ Purpose : Making a URL by replacing the spaces with a key value entered
348
+ by the user
349
+ Method : string manipulation
350
+
351
+ Time Complexity : Worst Case - O(n), n = length of the string
352
+
353
+ Hint :
354
+ Take a blank string, and add data from the input string to the blank
355
+ string to prepare the final URL
356
+
357
+ Pseudocode :
358
+ --> Take a blank string s2
359
+ --> for i in [0,length of input string]
360
+ if(not a whitespace)
361
+ add to s2
362
+ elif(whitespace and next place is also whitespace)
363
+ return s2
364
+ elif(whitespace and next place not whitespace)
365
+ add the key value to the blank string
366
+
367
+ Visualization:
368
+
369
+ Given String To Make URL :
370
+
371
+ "Python is love"
372
+
373
+ Key : "%20"
374
+
375
+ Break The Given String : /*/ ----> whitespace
376
+
377
+ +--------+-------+----+-------+------+
378
+ | Python | /*/ | is | /*/ | love |
379
+ +--------+-------+----+-------+------+
380
+ ^ ^ ^
381
+ ^ ^ ^
382
+ ^ ^ ^
383
+
384
+ 1 2 3
385
+
386
+ We will take 1, 2 and 3 sucessively and in place of whitespaces we will
387
+ concatenate the key value.
388
+
389
+ Empty String Addition :
390
+
391
+ +-+ +--------+ +-------+ +----+ +-------+ +------+
392
+ | | + | Python | + | %20 | + | is | + | %20 | + | love |
393
+ +-+ +--------+ +-------+ +----+ +-------+ +------+
394
+
395
+ Learn More about String Concatenation Below -
396
+ https://en.wikipedia.org/wiki/Concatenation
397
+ """
398
+ print_msg_box (message )
399
+
342
400
def isPalindromicPermutation (self ,input1 ):
343
401
mapp = {}
344
402
for i in range (len (input1 )):
@@ -413,5 +471,4 @@ def rotateImage(self,img_arr,n):
413
471
img_arr [i ][last ] = top
414
472
415
473
s = string_algorithms ()
416
- a = s .isPermutation ("aabbccdd" ,"abcbccdd" ,True )
417
- print (a )
474
+ s .URLify_hint ()
0 commit comments