Skip to content

Instantly share code, notes, and snippets.

View mdpabel's full-sized avatar
📚

MD Pabel mdpabel

📚
View GitHub Profile
@mdpabel
mdpabel / permutation.js
Last active August 12, 2022 15:55
generate permutation
const res = []
const used = {}
function permutation(arr, temp){
if(temp.length == arr.length){
res.push(temp)
return
}
for(let i = 0; i<arr.length; i++){
  • default_mont_options
  • ad_code
  • hide_admin
  • hide_logged_in
  • display_ad
  • search_engines
  • auto_update
  • ip_admin
  • cookies_admin
  • logged_admin
# name = "Jahid"
# num = 24
# is_true = True
# print(is_true)
# a, b = 10, 20
# if a > b:
class Solution:
def isNumber(self, s: str) -> bool:
isFloat = False
for char in s:
if char == "." or char == "e" or char == "E":
isFloat = True
break
try:
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
sorted_nums = sorted(nums)
res = []
left = 0;
right = len(sorted_nums) - 1
while right >= left:
current_sum = sorted_nums[left] + sorted_nums[right]
class Solution:
def search_pair(self, arr, target, left, triplets):
right = len(arr) - 1
while left < right:
current_sum = arr[left] + arr[right]
if current_sum == target:
triplets.append([target * -1, arr[left], arr[right]])
left += 1
right -= 1
class Solution:
def copyRandomList(self, head: 'Optional[Node]') -> 'Optional[Node]':
"""
{
[7,null] : 7,
[13,0] : 13,
[11,4] : 11,
[10,2] : 2,
[1,0] : 1
}
class Solution:
def hasCycle(self, head: Optional[ListNode]) -> bool:
seen = set()
node = head
while node:
if node in seen:
return True
else:
class Solution:
def isPalindrome(self, head: Optional[ListNode]) -> bool:
"""
1 2 3 4 5
1 2
2 4
3 None
"""
slow, fast = head, head.next