{"id":20376514,"url":"https://github.com/jaswantsinghh/coding-problems","last_synced_at":"2026-05-28T13:06:06.087Z","repository":{"id":81587591,"uuid":"364311554","full_name":"Jaswantsinghh/Coding-problems","owner":"Jaswantsinghh","description":"Coding problems asked in various companies.","archived":false,"fork":false,"pushed_at":"2021-06-23T15:14:53.000Z","size":94,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-04T21:42:04.961Z","etag":null,"topics":["coding-interviews","competitive-programming","cpp17","dsa","google"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jaswantsinghh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-04T16:01:17.000Z","updated_at":"2021-06-23T15:14:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"bf787da3-2741-4516-82c1-f12a74a99ccf","html_url":"https://github.com/Jaswantsinghh/Coding-problems","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Jaswantsinghh/Coding-problems","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaswantsinghh%2FCoding-problems","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaswantsinghh%2FCoding-problems/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaswantsinghh%2FCoding-problems/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaswantsinghh%2FCoding-problems/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jaswantsinghh","download_url":"https://codeload.github.com/Jaswantsinghh/Coding-problems/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaswantsinghh%2FCoding-problems/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33609316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coding-interviews","competitive-programming","cpp17","dsa","google"],"created_at":"2024-11-15T01:38:04.141Z","updated_at":"2026-05-28T13:06:06.057Z","avatar_url":"https://github.com/Jaswantsinghh.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Coding-problems\n## Amazon\n### Level: Easy\n1. Minimum Cost of ropes  \nThere are given N ropes of different lengths, we need to connect these ropes into one rope. The cost to connect two ropes is equal to sum of their lengths. The task is to connect the ropes with minimum cost.     \nExample 1:  \n``\nInput:   \n``    \n``\nn = 4\n``   \n``   \narr[] = {4, 3, 2, 6}\n``   \n``   \nOutput:\n``   \n``   \n29\n``    \nExplanation:  \nFor example if we are given 4\nropes of lengths 4, 3, 2 and 6. We can\nconnect the ropes in following ways.  \n1) First connect ropes of lengths 2 and 3.\nNow we have three ropes of lengths 4, 6\nand 5.  \n2) Now connect ropes of lengths 4 and 5.\nNow we have two ropes of lengths 6 and 9.  \n3) Finally connect the two ropes and all\nropes have connected.  \nTotal cost for connecting all ropes is 5 + 9 + 15 = 29. This is the optimized cost\nfor connecting ropes. Other ways of\nconnecting ropes would always have same\nor more cost. For example, if we connect\n4 and 6 first (we get three strings of 3,\n2 and 10), then connect 10 and 3 (we get\ntwo strings of 13 and 2). Finally we\nconnect 13 and 2. Total cost in this way\nis 10 + 13 + 15 = 38.   \nExample 2:   \n``\nInput:\n``  \n``  \nn = 5\n``   \n``    \narr[] = {4, 2, 7, 6, 9}\n``   \n``     \nOutput:\n``  \n``   \n62 \n``   \nExplanation:\nFirst, connect ropes 4 and 2, which makes\nthe array {6,7,6,9}. Next, add ropes 6 and\n6, which results in {12,7,9}. Then, add 7\nand 9, which makes the array {12,16}. And\nfinally add these two which gives {28}.\nHence, the total cost is 6 + 12 + 16 + \n28 = 62.\n- #### TAGS - Heap, queue\n   [Solution](Amazon/Easy/1.cpp)\n\n### Level: Medium\n1. Josephus Problem  \n   Given the total number of persons n and a number k which indicates that k-1 persons are skipped and kth person is killed in circle in a fixed direction.  \nThe task is to choose the safe place in the circle so that when you perform these operations starting from 1st place in the circle, you are the last one remaining and survive.   \nExample 1:  \nInput:  \nn = 3 k = 2  \nOutput: 3  \nExplanation: There are 3 persons so   \nskipping 1 person i.e 1st person 2nd   \nperson will be killed. Thus the safe   \nposition is 3.  \nExample 2:    \nInput:  \nn = 5 k = 3   \nOutput: 4    \nExplanation: There are 5 persons so   \nskipping 2 person i.e 3rd person will   \nbe killed. Thus the safe position is 4.   \n- #### TAGS - Recursion, bit manipulation\n  [Solution](Walmart/Medium/1.cpp)   \n  \n### Level: Hard\n1. Burning Tree\n   Given a binary tree and a leaf node called target. Find the minimum time required to burn the complete binary tree if the target is set on fire. It is known that in 1 second all nodes connected to a given node get burned. That is, its left child, right child and parent.  \nExample 1:     \nInput :      \n          1  \n        /   \\  \n      2      3  \n    /  \\      \\  \n   4    5      6  \n       / \\      \\  \n      7   8      9  \n                   \\  \n                   10  \nTarget Node = 8  \nOutput: 7   \nExplanation: If leaf with the value \n8 is set on fire.   \nAfter 1 sec: 5 is set on fire.  \nAfter 2 sec: 2, 7 are set to fire.  \nAfter 3 sec: 4, 1 are set to fire.  \nAfter 4 sec: 3 is set to fire.  \nAfter 5 sec: 6 is set to fire.  \nAfter 6 sec: 9 is set to fire.  \nAfter 7 sec: 10 is set to fire.  \nIt takes 7s to burn the complete tree.  \nExample 2:  \nInput :        \n          1  \n        /   \\  \n      2      3  \n    /  \\      \\  \n   4    5      7  \n  /    /   \n 8    10  \nTarget Node = 10  \nOutput: 5  \n- #### Tags - Tree\n  [Solution](Amazon/Hard/1.cpp)\n\n\n\n\n\n\n\n\n\n\n\n\n## Apple\n### Level: Easy\n1. Implement the function fib(n), which returns the nth number in the Fibonacci sequence, using only O(1) space.   \n   [Solution](Apple/Easy/1.cpp)\n\n\n\n\n\n\n\n\n\n\n\n\n## Flipkart\n### Level: Medium\n1. [Snakes and Ladders](https://en.wikipedia.org/wiki/Snakes_and_ladders) is a game played on a 10 x 10 board, the goal of which is get from square 1 to square 100. On each turn players will roll a six-sided die and move forward a number of spaces equal to the result. If they land on a square that represents a snake or ladder, they will be transported ahead or behind, respectively, to a new square.  \nFind the smallest number of turns it takes to play snakes and ladders.\nFor convenience, here are the squares representing snakes and ladders, and their outcomes:  \n``\nsnakes = {16: 6, 48: 26, 49: 11, 56: 53, 62: 19, 64: 60, 87: 24, 93: 73, 95: 75, 98: 78}\nladders = {1: 38, 4: 14, 9: 31, 21: 42, 28: 84, 36: 44, 51: 67, 71: 91, 80: 100}\n``  \n[Solution](Flipkart/Medium/1.cpp)\n\n### Level: Hard\n1. Burning Tree\n   Given a binary tree and a leaf node called target. Find the minimum time required to burn the complete binary tree if the target is set on fire. It is known that in 1 second all nodes connected to a given node get burned. That is, its left child, right child and parent.  \nExample 1:     \nInput :      \n          1  \n        /   \\  \n      2      3  \n    /  \\      \\  \n   4    5      6  \n       / \\      \\  \n      7   8      9  \n                   \\  \n                   10  \nTarget Node = 8  \nOutput: 7   \nExplanation: If leaf with the value \n8 is set on fire.   \nAfter 1 sec: 5 is set on fire.  \nAfter 2 sec: 2, 7 are set to fire.  \nAfter 3 sec: 4, 1 are set to fire.  \nAfter 4 sec: 3 is set to fire.  \nAfter 5 sec: 6 is set to fire.  \nAfter 6 sec: 9 is set to fire.  \nAfter 7 sec: 10 is set to fire.  \nIt takes 7s to burn the complete tree.  \nExample 2:  \nInput :        \n          1  \n        /   \\  \n      2      3  \n    /  \\      \\  \n   4    5      7  \n  /    /   \n 8    10  \nTarget Node = 10  \nOutput: 5  \n- #### Tags - Tree\n  [Solution](Amazon/Hard/1.cpp)\n\n\n\n\n\n\n\n\n\n\n\n## Google\n### Level: Easy\n1. Implement a PrefixMapSum class with the following methods:  \n   - insert(key: str, value: int): Set a given key's value in the map. If the key already exists, overwrite the value.\n   - sum(prefix: str): Return the sum of all values of keys that begin with a given prefix.\n   For example, you should be able to run the following code:     \n``   \nmapsum.insert(\"columnar\", 3)\n``   \n``  \nassert mapsum.sum(\"col\") == 3 \n``  \n``  \nmapsum.insert(\"column\", 2)\n``  \n``  \nassert mapsum.sum(\"col\") == 5  \n``  \n    [Solution](Google/Easy/1.cpp)\n\n### Level: Hard\n1. [Nth Natural Number](https://practice.geeksforgeeks.org/problems/nth-natural-number/1#)   \n   [Solution](Google/Hard/1.cpp)\n\n\n\n\n\n\n\n## Goldman Sachs\n### Level: Easy\n1. Minimum Cost of ropes  \nThere are given N ropes of different lengths, we need to connect these ropes into one rope. The cost to connect two ropes is equal to sum of their lengths. The task is to connect the ropes with minimum cost.     \nExample 1:  \n``\nInput:   \n``    \n``\nn = 4\n``   \n``   \narr[] = {4, 3, 2, 6}\n``   \n``   \nOutput:\n``   \n``   \n29\n``    \nExplanation:  \nFor example if we are given 4\nropes of lengths 4, 3, 2 and 6. We can\nconnect the ropes in following ways.  \n1) First connect ropes of lengths 2 and 3.\nNow we have three ropes of lengths 4, 6\nand 5.  \n2) Now connect ropes of lengths 4 and 5.\nNow we have two ropes of lengths 6 and 9.  \n3) Finally connect the two ropes and all\nropes have connected.  \nTotal cost for connecting all ropes is 5 + 9 + 15 = 29. This is the optimized cost\nfor connecting ropes. Other ways of\nconnecting ropes would always have same\nor more cost. For example, if we connect\n4 and 6 first (we get three strings of 3,\n2 and 10), then connect 10 and 3 (we get\ntwo strings of 13 and 2). Finally we\nconnect 13 and 2. Total cost in this way\nis 10 + 13 + 15 = 38.   \nExample 2:   \n``\nInput:\n``  \n``  \nn = 5\n``   \n``    \narr[] = {4, 2, 7, 6, 9}\n``   \n``     \nOutput:\n``  \n``   \n62 \n``   \nExplanation:\nFirst, connect ropes 4 and 2, which makes\nthe array {6,7,6,9}. Next, add ropes 6 and\n6, which results in {12,7,9}. Then, add 7\nand 9, which makes the array {12,16}. And\nfinally add these two which gives {28}.\nHence, the total cost is 6 + 12 + 16 + \n28 = 62.\n- #### TAGS - Heap, queue\n   [Solution](Amazon/Easy/1.cpp)\n### Level: Medium\n1. You are given N identical eggs and access to a building with k floors. Your task is to find the lowest floor that will cause an egg to break, if dropped from that floor. Once an egg breaks, it cannot be dropped again. If an egg breaks when dropped from the xth floor, you can assume it will also break when dropped from any floor greater than x.  \nWrite an algorithm that finds the minimum number of trial drops it will take, in the worst case, to identify this floor.\nFor example, if N = 1 and k = 5, we will need to try dropping the egg at every floor, beginning with the first, until we reach the fifth floor, so our solution will be 5.   \n[Solution](Goldman-Sachs/Medium/1.cpp)\n\n## IBM\n### Level: Easy\n1. Given a string with repeated characters, rearrange the string so that no two adjacent characters are the same. If this is not possible, return None.\nFor example, given \"aaabbc\", you could return \"ababac\". Given \"aaab\", return None.  \n[Solution](IBM/Easy/1.cpp)\n\n\n\n\n\n\n\n\n\n\n## Microsoft\n### Level: Easy\n1. Minimum Cost of ropes  \nThere are given N ropes of different lengths, we need to connect these ropes into one rope. The cost to connect two ropes is equal to sum of their lengths. The task is to connect the ropes with minimum cost.     \nExample 1:  \n``\nInput:   \n``    \n``\nn = 4\n``   \n``   \narr[] = {4, 3, 2, 6}\n``   \n``   \nOutput:\n``   \n``   \n29\n``    \nExplanation:  \nFor example if we are given 4\nropes of lengths 4, 3, 2 and 6. We can\nconnect the ropes in following ways.  \n1) First connect ropes of lengths 2 and 3.\nNow we have three ropes of lengths 4, 6\nand 5.  \n2) Now connect ropes of lengths 4 and 5.\nNow we have two ropes of lengths 6 and 9.  \n3) Finally connect the two ropes and all\nropes have connected.  \nTotal cost for connecting all ropes is 5 + 9 + 15 = 29. This is the optimized cost\nfor connecting ropes. Other ways of\nconnecting ropes would always have same\nor more cost. For example, if we connect\n4 and 6 first (we get three strings of 3,\n2 and 10), then connect 10 and 3 (we get\ntwo strings of 13 and 2). Finally we\nconnect 13 and 2. Total cost in this way\nis 10 + 13 + 15 = 38.   \nExample 2:   \n``\nInput:\n``  \n``  \nn = 5\n``   \n``    \narr[] = {4, 2, 7, 6, 9}\n``   \n``     \nOutput:\n``  \n``   \n62 \n``   \nExplanation:\nFirst, connect ropes 4 and 2, which makes\nthe array {6,7,6,9}. Next, add ropes 6 and\n6, which results in {12,7,9}. Then, add 7\nand 9, which makes the array {12,16}. And\nfinally add these two which gives {28}.\nHence, the total cost is 6 + 12 + 16 + \n28 = 62.\n- #### TAGS - Heap, queue\n   [Solution](Amazon/Easy/1.cpp)\n   \n2. Lucky Number\n   Lucky numbers are subset of integers. Rather than going into much theory, let us see the process of arriving at lucky numbers,\nTake the set of integers   \n1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,……    \nFirst, delete every second number, we get following reduced set.    \n1, 3, 5, 7, 9, 11, 13, 15, 17, 19,…………   \nNow, delete every third number, we get   \n1, 3, 7, 9, 13, 15, 19,….….    \nContinue this process indefinitely……    \nAny number that does NOT get deleted due to above process is called “lucky”.    \nExample 1:   \nInput:   \nN = 5  \nOutput: 0   \nExplanation: 5 is not a lucky number    \nas it gets deleted in the second     \niteration.    \nExample 2:   \nInput:   \nN = 19    \nOutput: 1     \nExplanation: 19 is a lucky number        \n   - #### TAGS - Recursion   \n   [Solution](Microsoft/Easy/1.cpp)\n   \n### Level: Medium\n1. The [tower of Hanoi](https://en.wikipedia.org/wiki/Tower_of_Hanoi) is a famous puzzle where we have three rods and N disks. The objective of the puzzle is to move the entire stack to another rod. You are given the number of discs N. Initially, these discs are in the rod 1. You need to print all the steps of discs movement so that all the discs reach the 3rd rod. Also, you need to find the total moves.\nNote: The discs are arranged such that the top disc is numbered 1 and the bottom-most disc is numbered N. Also, all the discs have different sizes and a bigger disc cannot be put on the top of a smaller disc. Refer the provided link to get a better clarity about the puzzle.   \nExample:  \nInput:    \nN = 2  \n- Output:  \nmove disk 1 from rod 1 to rod 2  \nmove disk 2 from rod 1 to rod 3  \nmove disk 1 from rod 2 to rod 3  \n3  \nExplanation: For N=2 , steps will be  \nas follows in the example and total  \n3 steps will be taken.  \n- Input:  \nN = 3  \nOutput:  \nmove disk 1 from rod 1 to rod 3\nmove disk 2 from rod 1 to rod 2\nmove disk 1 from rod 3 to rod 2\nmove disk 3 from rod 1 to rod 3\nmove disk 1 from rod 2 to rod 1\nmove disk 2 from rod 2 to rod 3\nmove disk 1 from rod 1 to rod 3\n7\nExplanation: For N=3 , steps will be\nas follows in the example and total \n7 steps will be taken.\n-  #### TAGS:- Recursion, basic mathematics.  \n   [Solution](Microsoft/Medium/1.cpp)\n\n2. Given a non-negative integer S represented as a string, remove K digits from the number so that the new number is the smallest possible.  \nNote : The given num does not contain any leading zero.     \n  Example 1:    \n``\nInput: \n``   \n``   \nS = \"149811\", K = 3\n``   \n``    \nOutput: 111\n``   \n``   \nExplanation: Remove the three digits \n4, 9, and 8 to form the new number \n111 which is the smallest.\n``        \n  Example 2:     \n``\nInput:    \nS = \"1002991\", K = 3\nOutput: 21\nExplanation: Remove the three digits\n1(leading one), 9, and 9 to form the \nnew number 21(Note that the output \nmust not contain leading zeroes) \nwhich is the smallest.\n``     \n- ####   TAGS - Stack\n    [Solution](Microsoft/Medium/2.cpp)\n\n3. Remove BST keys outside given range.\nGiven a Binary Search Tree (BST) and a range [min, max], remove all keys which are outside the given range. The modified tree should also be BST.   \n- #### Tags - Binary Search Tree  \n   [Solution](Samsung/Medium/1.cpp)\n\n4. Josephus Problem  \n   Given the total number of persons n and a number k which indicates that k-1 persons are skipped and kth person is killed in circle in a fixed direction.  \nThe task is to choose the safe place in the circle so that when you perform these operations starting from 1st place in the circle, you are the last one remaining and survive.   \nExample 1:  \nInput:  \nn = 3 k = 2  \nOutput: 3  \nExplanation: There are 3 persons so   \nskipping 1 person i.e 1st person 2nd   \nperson will be killed. Thus the safe   \nposition is 3.  \nExample 2:    \nInput:  \nn = 5 k = 3   \nOutput: 4    \nExplanation: There are 5 persons so   \nskipping 2 person i.e 3rd person will   \nbe killed. Thus the safe position is 4.   \n- #### TAGS - Recursion, bit manipulation\n  [Solution](Walmart/Medium/1.cpp)\n\n### Level: Hard\n1. Burning Tree\n   Given a binary tree and a leaf node called target. Find the minimum time required to burn the complete binary tree if the target is set on fire. It is known that in 1 second all nodes connected to a given node get burned. That is, its left child, right child and parent.  \nExample 1:     \nInput :      \n          1  \n        /   \\  \n      2      3  \n    /  \\      \\  \n   4    5      6  \n       / \\      \\  \n      7   8      9  \n                   \\  \n                   10  \nTarget Node = 8  \nOutput: 7   \nExplanation: If leaf with the value \n8 is set on fire.   \nAfter 1 sec: 5 is set on fire.  \nAfter 2 sec: 2, 7 are set to fire.  \nAfter 3 sec: 4, 1 are set to fire.  \nAfter 4 sec: 3 is set to fire.  \nAfter 5 sec: 6 is set to fire.  \nAfter 6 sec: 9 is set to fire.  \nAfter 7 sec: 10 is set to fire.  \nIt takes 7s to burn the complete tree.  \nExample 2:  \nInput :        \n          1  \n        /   \\  \n      2      3  \n    /  \\      \\  \n   4    5      7  \n  /    /   \n 8    10  \nTarget Node = 10  \nOutput: 5  \n- #### Tags - Tree\n  [Solution](Amazon/Hard/1.cpp)\n\n2. Recall that the minimum spanning tree is the subset of edges of a tree that connect all its vertices with the smallest possible total edge weight. Given an undirected graph with weighted edges, compute the maximum weight spanning tree.    \n  [Solution](Microsoft/Hard/1.cpp)\n\n## OYO Rooms\n### Level: Easy\n1. Minimum Cost of ropes  \nThere are given N ropes of different lengths, we need to connect these ropes into one rope. The cost to connect two ropes is equal to sum of their lengths. The task is to connect the ropes with minimum cost.     \nExample 1:  \n``\nInput:   \n``    \n``\nn = 4\n``   \n``   \narr[] = {4, 3, 2, 6}\n``   \n``   \nOutput:\n``   \n``   \n29\n``    \nExplanation:  \nFor example if we are given 4\nropes of lengths 4, 3, 2 and 6. We can\nconnect the ropes in following ways.  \n1) First connect ropes of lengths 2 and 3.\nNow we have three ropes of lengths 4, 6\nand 5.  \n2) Now connect ropes of lengths 4 and 5.\nNow we have two ropes of lengths 6 and 9.  \n3) Finally connect the two ropes and all\nropes have connected.  \nTotal cost for connecting all ropes is 5 + 9 + 15 = 29. This is the optimized cost\nfor connecting ropes. Other ways of\nconnecting ropes would always have same\nor more cost. For example, if we connect\n4 and 6 first (we get three strings of 3,\n2 and 10), then connect 10 and 3 (we get\ntwo strings of 13 and 2). Finally we\nconnect 13 and 2. Total cost in this way\nis 10 + 13 + 15 = 38.   \nExample 2:   \n``\nInput:\n``  \n``  \nn = 5\n``   \n``    \narr[] = {4, 2, 7, 6, 9}\n``   \n``     \nOutput:\n``  \n``   \n62 \n``   \nExplanation:\nFirst, connect ropes 4 and 2, which makes\nthe array {6,7,6,9}. Next, add ropes 6 and\n6, which results in {12,7,9}. Then, add 7\nand 9, which makes the array {12,16}. And\nfinally add these two which gives {28}.\nHence, the total cost is 6 + 12 + 16 + \n28 = 62.\n- #### TAGS - Heap, queue\n   [Solution](Amazon/Easy/1.cpp)\n   \n## Samsung\n### Level: Medium\n1. Remove BST keys outside given range.\nGiven a Binary Search Tree (BST) and a range [min, max], remove all keys which are outside the given range. The modified tree should also be BST.   \n- #### Tags - Binary Search Tree  \n   [Solution](Samsung/Medium/1.cpp)\n  \n   \n##  Twitter\n### Level: Medium\n1. Given a list of numbers, create an algorithm that arranges them in order to form the largest possible integer.\n   ### Example Test Case: [10, 7, 76, 415], you should return 77641510.\n   [Solution](Twitter/Medium/1.cpp)\n\n## Walmart\n### Level: Medium\n1. Josephus Problem  \n   Given the total number of persons n and a number k which indicates that k-1 persons are skipped and kth person is killed in circle in a fixed direction.  \nThe task is to choose the safe place in the circle so that when you perform these operations starting from 1st place in the circle, you are the last one remaining and survive.   \nExample 1:  \nInput:  \nn = 3 k = 2  \nOutput: 3  \nExplanation: There are 3 persons so   \nskipping 1 person i.e 1st person 2nd   \nperson will be killed. Thus the safe   \nposition is 3.  \nExample 2:    \nInput:  \nn = 5 k = 3   \nOutput: 4    \nExplanation: There are 5 persons so   \nskipping 2 person i.e 3rd person will   \nbe killed. Thus the safe position is 4.   \n- #### TAGS - Recursion, bit manipulation\n  [Solution](Walmart/Medium/1.cpp)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaswantsinghh%2Fcoding-problems","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaswantsinghh%2Fcoding-problems","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaswantsinghh%2Fcoding-problems/lists"}