Sort by

recency

|

465 Discussions

|

  • + 0 comments

    def num(): n = int(input()) for _ in range (n): num=input().strip() if len (num)==10 and num[0] in "7,8,9" and num.isdigit(): print("YES") else: print("NO") num()

  • + 0 comments

    import re N=int(input()) for _ in range(N): S=input() if re.match(r'^[789]\d{9}$',S): print("YES") else: print("NO")

  • + 0 comments

    cannot pass one test case. cant understand why.

    n = int(input()) for i in range(n): num = input() if num[0] in ['7','8','9'] and len(num)==10: c = 0 for j in num: if ord(j) not in range(48,58): c += 1 print('NO') if c == 0: print('YES')

    else:
        print('NO')
    
  • + 0 comments

    def insert(self,head,data): temp = Node(data) if head is None: head = temp return head current = head while current.next is not None: current = current.next current.next = temp return head
    Problem solution in java programming. public static Node insert(Node head,int data){ // if list has no elements, return a new node if(head == null){ return new Node(data); }

        // else iterate through list, add node to tail, and return head
        Node tmp = head;
        while(tmp.next != null){
            tmp = tmp.next;
        }
        tmp.next = new Node(data);
    
        return head;
    }
    
  • + 0 comments
    import re
    p = r'^[789]\d{9}$'
    for _ in range(int(input())):
        print("YES" if re.match(p, input()) else "NO")