Announcement

Collapse
No announcement yet.

[Lớp thuật toán hè 2015] Tài liệu và trao đổi buổi 2

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 13520280
    replied
    PHP Code:
    #define MAX 60000
    #define MID 30000

    int singleNumber(intnumsint numsSize) {
        
    inthash = (int*)calloc(sizeof(int),MAX);
        for(
    int i=0i<numsSize;i++)
        {
            
    hash[nums[i]+MID]+=1;
        }
        for(
    int i=0i<MAX;i++)
        {
            if(
    hash[i]==1)
            return 
    i-MID;
        }

    - Tại vì lúc chạy ban đầu bị lỗi do có số âm. Nên chia hash ra: [0,30000): hash số âm. Còn lại hash số không âm.
    - Bài chưa tối ưu do nếu bộ test cực lớn. Cần tối ưu hơn.
    - 8ms
    Last edited by toannv; 07-07-2015, 11:23.

    Leave a comment:


  • [Lớp thuật toán hè 2015] Tài liệu và trao đổi buổi 2

    Ngày mai, phòng máy sẽ mở cửa lúc 9:30 và 10:00 là bắt đầu học nhé các bạn.
    Attached Files
    Last edited by toannv; 07-07-2015, 11:35.

LHQC

Collapse
Working...
X