---
# System prepended metadata

title: Palindrome

---

# Palindrome
Write a small function that finds the smallest palindrome number greater than N and for which its square value is also a palindrome.

```python=
def is_Palindrom(num):
    end = len(num)-1
    
    for begin in len(num):
        if num[begin] == num[end]:
            end -= 1
        else
            return False
            
        if end < start: return False
            
    retrun True
    
# O(len(num))

    
def func(num):
    num = int(num)
    while not is_Palindrom(str(num)) and is_Palindrom(str(num**2)): -> # inf loop 
        num += 1
    return num
        
```

# Task scheduler

You have N tasks to run in any order you want.
Each task takes one time step to run.
There must be a minimum of K (cooldown value) time steps between two runs of the same task.
Write a function that returns the sequence of tasks to run in a minimal amount of time steps.

1) tasks = ["A", "A", "B"], K = 3
["A", "B", "", "", "A"]
2) tasks = ["A","A","A","B","B","B"], K = 2
["A", "B", "", "A", "B", "", "A", "B"]
3) tasks = ["A", "B", "B", "C"], K = 4
["B", "A", "C", "", "", "B"]



import collection 

```python=
def func(tasks, K):
    freq_dict = dict(Counter(taks))
    
    task = []
    for key, value in freq_dict:
        if dist_to_prev_is_ok(): // <K
            task.append(key)
        else:
            padding()
            task.append("")
            task.append(key)
        
        
        if freq_dict[key] == 0: 

```
