<jupyter_start><jupyter_text>interview sorted  Fraudulent Activity Notifications<jupyter_code>days=5
expenses=[2, 3, 4, 2, 3, 6, 8, 4, 5]

days2=4
expenses2=[1, 2, 3, 4, 4]
for i in range(days):
    print(i)
    if len(expenses[i:i+days])==days:
        print(expenses[i:i+days])
def quickSort(arr,low,high): 
    if low < high: 
  
        # pi is partitioning index, arr[p] is now 
        # at right place 
        pi = partition(arr,low,high) 
  
        # Separately sort elements before 
        # partition and after partition 
        quickSort(arr, low, pi-1) 
        quickSort(arr, pi+1, high)     
def partition(arr,low,high): 
    i = ( low-1 )         # index of smaller element 
    pivot = arr[high]     # pivot 
  
    for j in range(low , high): 
  
        # If current element is smaller than or 
        # equal to pivot 
        if   arr[j] <= pivot: 
          
            # increment index of smaller element 
            i = i+1 
            arr[i],arr[j] = arr[j],arr[i] 
  
    arr[i+1],arr[high] = arr[high],arr[i+1] 
    return ( i+1 ) 
for i in range(days):
    print(i)
    n=len(expenses[i:i+days])
    array=expenses[i:i+days]
    if n==days:
        quickSort(array,0,n-1)
        print(array)
def findMedian(l):   
    # check for even case 
    l_len = len(l)
    if l_len < 1:
        return None
    if l_len % 2 == 0 :
        return ( l[(l_len-1)//2] + l[(l_len)//2] ) / 2.0
    else:
        return l[(l_len-1)//2]
count=0
for i in range((len(expenses)-days)+1):
    print('\n'+str(i))
    
    
    array=expenses[i:i+days]
    n=len(array)
    
    print(array)
    quickSort(array,0,n-1)
    print(array)
    print(findMedian(array))
    print(count) 
    median=findMedian(array)
    try: 
        if expenses[i+days]>=2*median:
            count+=1
    except:
        pass
print(count)            
def notification(expenses,days):
    count=0
    for i in range((len(expenses)-days)+1):
        
    
    
        array=expenses[i:i+days]
        n=len(array)
    
    
        quickSort(array,0,n-1)
    
    
        median=findMedian(array,n)
        try: 
            if expenses[i+days+1]<=2*median:
                count+=1
        except:
            pass       
    return count
notification(expenses,days)
notification(expenses2,days2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13178294573643412, 'fraction_numerical': 0.02239448751076658, 'mean_word_length': 1.982028241335045, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '424379', 'license': 'MIT', 'n_tokens_mistral': 882, 'n_tokens_neox': 835, 'n_words': 178, 'path': 'hackerRank/.ipynb_checkpoints/interview_sorted-checkpoint.ipynb', 'repo_name': 'emmanuelol/CodingPractice', 'size': '2322'}